2 # Copyright (C) 2021 OpenWrt.org
5 [ -e /etc/config/ubootenv ] && exit 0
7 touch /etc/config/ubootenv
9 . /lib/uboot-envtools.sh
16 rootdev="$(cmdline_get_var root)"
17 rootdev="${rootdev##*/}"
18 rootdev="${rootdev%%p[0-9]*}"
21 local envdev=$(find_mmc_part "ubootenv" $rootdev)
22 ubootenv_add_uci_config "$envdev" "0x0" "0x40000" "0x40000" "1"
23 ubootenv_add_uci_config "$envdev" "0x40000" "0x40000" "0x40000" "1"
26 local envdev=/dev/mtd$(find_mtd_index "u-boot-env")
27 ubootenv_add_uci_config "$envdev" "0x0" "0x20000" "0x20000" "1"
28 ubootenv_add_uci_config "$envdev" "0x20000" "0x20000" "0x20000" "1"
31 . /lib/upgrade/nand.sh
32 local envubi=$(nand_find_ubi ubi)
33 local envdev=/dev/$(nand_find_volume $envubi ubootenv)
34 local envdev2=/dev/$(nand_find_volume $envubi ubootenv2)
35 ubootenv_add_uci_config "$envdev" "0x0" "0x1f000" "0x1f000" "1"
36 ubootenv_add_uci_config "$envdev2" "0x0" "0x1f000" "0x1f000" "1"
41 case "$(cmdline_get_var root)" in
43 local envdev=$(find_mmc_part "ubootenv" "mmcblk0")
44 ubootenv_add_uci_config "$envdev" "0x0" "0x40000" "0x40000" "1"
45 ubootenv_add_uci_config "$envdev" "0x40000" "0x40000" "0x40000" "1"
48 . /lib/upgrade/nand.sh
49 local envubi=$(nand_find_ubi ubi)
50 local envdev=/dev/$(nand_find_volume $envubi ubootenv)
51 local envdev2=/dev/$(nand_find_volume $envubi ubootenv2)
52 ubootenv_add_uci_config "$envdev" "0x0" "0x1f000" "0x1f000" "1"
53 ubootenv_add_uci_config "$envdev2" "0x0" "0x1f000" "0x1f000" "1"
61 ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x20000" "0x20000"
69 xiaomi,mi-router-wr30u-ubootmod|\
70 xiaomi,redmi-router-ax6000-ubootmod)
71 . /lib/upgrade/nand.sh
72 local envubi=$(nand_find_ubi ubi)
73 local envdev=/dev/$(nand_find_volume $envubi ubootenv)
74 local envdev2=/dev/$(nand_find_volume $envubi ubootenv2)
75 ubootenv_add_uci_config "$envdev" "0x0" "0x1f000" "0x20000" "1"
76 ubootenv_add_uci_config "$envdev2" "0x0" "0x1f000" "0x20000" "1"
80 local envdev=$(find_mmc_part "u-boot-env")
81 ubootenv_add_uci_config "$envdev" "0x0" "0x80000"
84 ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x80000" "0x20000"
88 local envdev=/dev/mtd$(find_mtd_index "u-boot-env")
89 ubootenv_add_uci_config "$envdev" "0x0" "0x20000" "0x20000" "1"
92 ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x80000" "0x10000"
94 xiaomi,mi-router-wr30u-112m-nmbm|\
95 xiaomi,mi-router-wr30u-stock|\
96 xiaomi,redmi-router-ax6000-stock)
97 ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x10000" "0x20000"
98 ubootenv_add_uci_sys_config "/dev/mtd2" "0x0" "0x10000" "0x20000"
101 local envdev=/dev/mtd$(find_mtd_index "u-boot-env")
102 ubootenv_add_uci_config "$envdev" "0x0" "0x20000" "0x40000" "2"
104 zyxel,ex5601-t0-ubootmod)
105 . /lib/upgrade/nand.sh
106 local envubi=$(nand_find_ubi ubi)
107 local envdev=/dev/$(nand_find_volume $envubi ubootenv)
108 local envdev2=/dev/$(nand_find_volume $envubi ubootenv2)
109 ubootenv_add_uci_config "$envdev" "0x0" "0x1f000" "0x20000" "1"
110 ubootenv_add_uci_config "$envdev2" "0x0" "0x1f000" "0x20000" "1"
112 zyxel,ex5700-telenor)
113 ubootenv_add_uci_config "/dev/ubootenv" "0x0" "0x4000" "0x4000" "1"
118 config_foreach ubootenv_add_app_config