050e1173c33393b1bb707807cf5b5c37145102c7
[openwrt/openwrt.git] / package / boot / uboot-envtools / files / mediatek_filogic
1 #
2 # Copyright (C) 2021 OpenWrt.org
3 #
4
5 [ -e /etc/config/ubootenv ] && exit 0
6
7 touch /etc/config/ubootenv
8
9 . /lib/uboot-envtools.sh
10 . /lib/functions.sh
11
12 board=$(board_name)
13
14 case "$board" in
15 bananapi,bpi-r3)
16 rootdev="$(cmdline_get_var root)"
17 rootdev="${rootdev##*/}"
18 rootdev="${rootdev%%p[0-9]*}"
19 case "$rootdev" in
20 mmc*)
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"
24 ;;
25 mtd*)
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"
29 ;;
30 ubi*)
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"
37 ;;
38 esac
39 ;;
40 cmcc,rax3000m)
41 case "$(cmdline_get_var root)" in
42 /dev/mmc*)
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"
46 ;;
47 *)
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"
54 ;;
55 esac
56 ;;
57 cetron,ct3003|\
58 netgear,wax220|\
59 zbtlink,zbt-z8102ax)
60 ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x20000" "0x20000"
61 ;;
62 h3c,magic-nx30-pro|\
63 jcg,q30-pro|\
64 qihoo,360t7|\
65 tplink,tl-xdr4288|\
66 tplink,tl-xdr6086|\
67 tplink,tl-xdr6088|\
68 xiaomi,mi-router-wr30u-ubootmod|\
69 xiaomi,redmi-router-ax6000-ubootmod)
70 . /lib/upgrade/nand.sh
71 local envubi=$(nand_find_ubi ubi)
72 local envdev=/dev/$(nand_find_volume $envubi ubootenv)
73 local envdev2=/dev/$(nand_find_volume $envubi ubootenv2)
74 ubootenv_add_uci_config "$envdev" "0x0" "0x1f000" "0x20000" "1"
75 ubootenv_add_uci_config "$envdev2" "0x0" "0x1f000" "0x20000" "1"
76 ;;
77 glinet,gl-mt2500|\
78 glinet,gl-mt6000)
79 local envdev=$(find_mmc_part "u-boot-env")
80 ubootenv_add_uci_config "$envdev" "0x0" "0x80000"
81 ;;
82 glinet,gl-mt3000)
83 ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x80000" "0x20000"
84 ;;
85 mercusys,mr90x-v1)
86 local envdev=/dev/mtd$(find_mtd_index "u-boot-env")
87 ubootenv_add_uci_config "$envdev" "0x0" "0x20000" "0x20000" "1"
88 ;;
89 ubnt,unifi-6-plus)
90 ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x80000" "0x10000"
91 ;;
92 xiaomi,mi-router-wr30u-112m-nmbm|\
93 xiaomi,mi-router-wr30u-stock|\
94 xiaomi,redmi-router-ax6000-stock)
95 ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x10000" "0x20000"
96 ubootenv_add_uci_sys_config "/dev/mtd2" "0x0" "0x10000" "0x20000"
97 ;;
98 zyxel,ex5601-t0)
99 local envdev=/dev/mtd$(find_mtd_index "u-boot-env")
100 ubootenv_add_uci_config "$envdev" "0x0" "0x20000" "0x40000" "2"
101 ;;
102 zyxel,ex5601-t0-ubootmod)
103 . /lib/upgrade/nand.sh
104 local envubi=$(nand_find_ubi ubi)
105 local envdev=/dev/$(nand_find_volume $envubi ubootenv)
106 local envdev2=/dev/$(nand_find_volume $envubi ubootenv2)
107 ubootenv_add_uci_config "$envdev" "0x0" "0x1f000" "0x20000" "1"
108 ubootenv_add_uci_config "$envdev2" "0x0" "0x1f000" "0x20000" "1"
109 ;;
110 zyxel,ex5700-telenor)
111 ubootenv_add_uci_config "/dev/ubootenv" "0x0" "0x4000" "0x4000" "1"
112 ;;
113 esac
114
115 config_load ubootenv
116 config_foreach ubootenv_add_app_config
117
118 exit 0