2 # Copyright (C) 2021 OpenWrt.org
5 [ -e /etc/config/ubootenv ] && exit 0
7 touch /etc/config/ubootenv
9 . /lib/uboot-envtools.sh
14 ubootenv_add_mmc_default() {
15 local envdev="$(find_mmc_part "ubootenv" "${1:-mmcblk0}")"
16 ubootenv_add_uci_config "$envdev" "0x0" "0x40000" "0x40000" "1"
17 ubootenv_add_uci_config "$envdev" "0x40000" "0x40000" "0x40000" "1"
20 ubootenv_add_nor_default() {
21 local envdev="/dev/mtd$(find_mtd_index "u-boot-env")"
22 ubootenv_add_uci_config "$envdev" "0x0" "0x20000" "0x20000" "1"
23 ubootenv_add_uci_config "$envdev" "0x20000" "0x20000" "0x20000" "1"
26 ubootenv_add_ubi_default() {
27 . /lib/upgrade/nand.sh
28 local envubi=$(nand_find_ubi ubi)
29 local envdev=/dev/$(nand_find_volume $envubi ubootenv)
30 local envdev2=/dev/$(nand_find_volume $envubi ubootenv2)
31 ubootenv_add_uci_config "$envdev" "0x0" "0x1f000" "0x1f000" "1"
32 ubootenv_add_uci_config "$envdev2" "0x0" "0x1f000" "0x1f000" "1"
37 ubootenv_add_uci_config "/dev/mtd0" "0x100000" "0x20000" "0x20000"
41 . /lib/upgrade/platform.sh
43 bootdev="$(platform_get_bootdev)"
46 ubootenv_add_ubi_default
49 ubootenv_add_mmc_default "${bootdev%%p[0-9]*}"
52 ubootenv_add_nor_default
57 case "$(cmdline_get_var root)" in
59 ubootenv_add_mmc_default
62 ubootenv_add_ubi_default
67 ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x20000" "0x80000"
73 ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x20000" "0x20000"
81 xiaomi,mi-router-ax3000t-ubootmod|\
82 xiaomi,mi-router-wr30u-ubootmod|\
83 xiaomi,redmi-router-ax6000-ubootmod|\
84 zyxel,ex5601-t0-ubootmod)
85 ubootenv_add_ubi_default
89 local envdev=$(find_mmc_part "u-boot-env")
90 ubootenv_add_uci_config "$envdev" "0x0" "0x80000"
93 ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x80000" "0x20000"
96 local envdev=$(find_mmc_part "ubootenv" "mmcblk0")
97 ubootenv_add_uci_config "$envdev" "0x0" "0x40000" "0x40000" "1"
98 ubootenv_add_uci_config "$envdev" "0x40000" "0x40000" "0x40000" "1"
102 local envdev=/dev/mtd$(find_mtd_index "u-boot-env")
103 ubootenv_add_uci_config "$envdev" "0x0" "0x20000" "0x20000" "1"
106 ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x80000" "0x10000"
108 xiaomi,mi-router-ax3000t|\
109 xiaomi,mi-router-wr30u-stock|\
110 xiaomi,redmi-router-ax6000-stock)
111 ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x10000" "0x20000"
112 ubootenv_add_uci_sys_config "/dev/mtd2" "0x0" "0x10000" "0x20000"
115 local envdev=/dev/mtd$(find_mtd_index "u-boot-env")
116 ubootenv_add_uci_config "$envdev" "0x0" "0x20000" "0x40000" "2"
118 zyxel,ex5700-telenor)
119 ubootenv_add_uci_config "/dev/ubootenv" "0x0" "0x4000" "0x4000" "1"
124 config_foreach ubootenv_add_app_config