1050277292a2c9789c4efe61ce28c18a55dcc747
[openwrt/staging/wigyori.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 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"
18 }
19
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"
24 }
25
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"
33 }
34
35 case "$board" in
36 asus,rt-ax59u)
37 ubootenv_add_uci_config "/dev/mtd0" "0x100000" "0x20000" "0x20000"
38 ;;
39 bananapi,bpi-r3)
40 rootdev="$(cmdline_get_var root)"
41 rootdev="${rootdev##*/}"
42 rootdev="${rootdev%%p[0-9]*}"
43 case "$rootdev" in
44 mmc*)
45 ubootenv_add_mmc_default
46 ;;
47 mtd*)
48 ubootenv_add_nor_default
49 ;;
50 ubi*)
51 ubootenv_add_ubi_default
52 ;;
53 esac
54 ;;
55 bananapi,bpi-r4)
56 . /lib/upgrade/platform.sh
57
58 bootdev="$(platform_get_bootdev)"
59 case "$bootdev" in
60 ubi*)
61 ubootenv_add_ubi_default
62 ;;
63 mmc*)
64 ubootenv_add_mmc_default "${bootdev%%p[0-9]*}"
65 ;;
66 esac
67 ;;
68 cmcc,rax3000m)
69 case "$(cmdline_get_var root)" in
70 /dev/mmc*)
71 ubootenv_add_mmc_default
72 ;;
73 *)
74 ubootenv_add_ubi_default
75 ;;
76 esac
77 ;;
78 comfast,cf-e393ax)
79 ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x20000" "0x80000"
80 ;;
81 cetron,ct3003|\
82 netgear,wax220|\
83 zbtlink,zbt-z8102ax|\
84 zbtlink,zbt-z8103ax)
85 ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x20000" "0x20000"
86 ;;
87 h3c,magic-nx30-pro|\
88 jcg,q30-pro|\
89 qihoo,360t7|\
90 tplink,tl-xdr4288|\
91 tplink,tl-xdr6086|\
92 tplink,tl-xdr6088|\
93 xiaomi,mi-router-ax3000t-ubootmod|\
94 xiaomi,mi-router-wr30u-ubootmod|\
95 xiaomi,redmi-router-ax6000-ubootmod|\
96 zyxel,ex5601-t0-ubootmod)
97 ubootenv_add_ubi_default
98 ;;
99 glinet,gl-mt2500|\
100 glinet,gl-mt6000)
101 local envdev=$(find_mmc_part "u-boot-env")
102 ubootenv_add_uci_config "$envdev" "0x0" "0x80000"
103 ;;
104 glinet,gl-mt3000)
105 ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x80000" "0x20000"
106 ;;
107 jdcloud,re-cp-03)
108 local envdev=$(find_mmc_part "ubootenv" "mmcblk0")
109 ubootenv_add_uci_config "$envdev" "0x0" "0x40000" "0x40000" "1"
110 ubootenv_add_uci_config "$envdev" "0x40000" "0x40000" "0x40000" "1"
111 ;;
112 mercusys,mr90x-v1|\
113 routerich,ax3000)
114 local envdev=/dev/mtd$(find_mtd_index "u-boot-env")
115 ubootenv_add_uci_config "$envdev" "0x0" "0x20000" "0x20000" "1"
116 ;;
117 ubnt,unifi-6-plus)
118 ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x80000" "0x10000"
119 ;;
120 xiaomi,mi-router-ax3000t|\
121 xiaomi,mi-router-wr30u-stock|\
122 xiaomi,redmi-router-ax6000-stock)
123 ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x10000" "0x20000"
124 ubootenv_add_uci_sys_config "/dev/mtd2" "0x0" "0x10000" "0x20000"
125 ;;
126 zyxel,ex5601-t0)
127 local envdev=/dev/mtd$(find_mtd_index "u-boot-env")
128 ubootenv_add_uci_config "$envdev" "0x0" "0x20000" "0x40000" "2"
129 ;;
130 zyxel,ex5700-telenor)
131 ubootenv_add_uci_config "/dev/ubootenv" "0x0" "0x4000" "0x4000" "1"
132 ;;
133 esac
134
135 config_load ubootenv
136 config_foreach ubootenv_add_app_config
137
138 exit 0