2 # Copyright (C) 2021 OpenWrt.org
5 [ -e /etc/config/ubootenv ] && exit 0
7 touch /etc/config/ubootenv
9 . /lib/uboot-envtools.sh
16 ubootenv_add_uci_config "/dev/mtd0" "0x100000" "0x20000" "0x20000"
19 rootdev="$(cmdline_get_var root)"
20 rootdev="${rootdev##*/}"
21 rootdev="${rootdev%%p[0-9]*}"
24 local envdev=$(find_mmc_part "ubootenv" $rootdev)
25 ubootenv_add_uci_config "$envdev" "0x0" "0x40000" "0x40000" "1"
26 ubootenv_add_uci_config "$envdev" "0x40000" "0x40000" "0x40000" "1"
29 local envdev=/dev/mtd$(find_mtd_index "u-boot-env")
30 ubootenv_add_uci_config "$envdev" "0x0" "0x20000" "0x20000" "1"
31 ubootenv_add_uci_config "$envdev" "0x20000" "0x20000" "0x20000" "1"
34 . /lib/upgrade/nand.sh
35 local envubi=$(nand_find_ubi ubi)
36 local envdev=/dev/$(nand_find_volume $envubi ubootenv)
37 local envdev2=/dev/$(nand_find_volume $envubi ubootenv2)
38 ubootenv_add_uci_config "$envdev" "0x0" "0x1f000" "0x1f000" "1"
39 ubootenv_add_uci_config "$envdev2" "0x0" "0x1f000" "0x1f000" "1"
44 case "$(cmdline_get_var root)" in
46 local envdev=$(find_mmc_part "ubootenv" "mmcblk0")
47 ubootenv_add_uci_config "$envdev" "0x0" "0x40000" "0x40000" "1"
48 ubootenv_add_uci_config "$envdev" "0x40000" "0x40000" "0x40000" "1"
51 . /lib/upgrade/nand.sh
52 local envubi=$(nand_find_ubi ubi)
53 local envdev=/dev/$(nand_find_volume $envubi ubootenv)
54 local envdev2=/dev/$(nand_find_volume $envubi ubootenv2)
55 ubootenv_add_uci_config "$envdev" "0x0" "0x1f000" "0x1f000" "1"
56 ubootenv_add_uci_config "$envdev2" "0x0" "0x1f000" "0x1f000" "1"
64 ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x20000" "0x20000"
72 xiaomi,mi-router-ax3000t-ubootmod|\
73 xiaomi,mi-router-wr30u-ubootmod|\
74 xiaomi,redmi-router-ax6000-ubootmod)
75 . /lib/upgrade/nand.sh
76 local envubi=$(nand_find_ubi ubi)
77 local envdev=/dev/$(nand_find_volume $envubi ubootenv)
78 local envdev2=/dev/$(nand_find_volume $envubi ubootenv2)
79 ubootenv_add_uci_config "$envdev" "0x0" "0x1f000" "0x20000" "1"
80 ubootenv_add_uci_config "$envdev2" "0x0" "0x1f000" "0x20000" "1"
84 local envdev=$(find_mmc_part "u-boot-env")
85 ubootenv_add_uci_config "$envdev" "0x0" "0x80000"
88 ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x80000" "0x20000"
91 local envdev=$(find_mmc_part "ubootenv" "mmcblk0")
92 ubootenv_add_uci_config "$envdev" "0x0" "0x40000" "0x40000" "1"
93 ubootenv_add_uci_config "$envdev" "0x40000" "0x40000" "0x40000" "1"
97 local envdev=/dev/mtd$(find_mtd_index "u-boot-env")
98 ubootenv_add_uci_config "$envdev" "0x0" "0x20000" "0x20000" "1"
101 ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x80000" "0x10000"
103 xiaomi,mi-router-ax3000t|\
104 xiaomi,mi-router-wr30u-112m-nmbm|\
105 xiaomi,mi-router-wr30u-stock|\
106 xiaomi,redmi-router-ax6000-stock)
107 ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x10000" "0x20000"
108 ubootenv_add_uci_sys_config "/dev/mtd2" "0x0" "0x10000" "0x20000"
111 local envdev=/dev/mtd$(find_mtd_index "u-boot-env")
112 ubootenv_add_uci_config "$envdev" "0x0" "0x20000" "0x40000" "2"
114 zyxel,ex5601-t0-ubootmod)
115 . /lib/upgrade/nand.sh
116 local envubi=$(nand_find_ubi ubi)
117 local envdev=/dev/$(nand_find_volume $envubi ubootenv)
118 local envdev2=/dev/$(nand_find_volume $envubi ubootenv2)
119 ubootenv_add_uci_config "$envdev" "0x0" "0x1f000" "0x20000" "1"
120 ubootenv_add_uci_config "$envdev2" "0x0" "0x1f000" "0x20000" "1"
122 zyxel,ex5700-telenor)
123 ubootenv_add_uci_config "/dev/ubootenv" "0x0" "0x4000" "0x4000" "1"
128 config_foreach ubootenv_add_app_config