829ce4e1f923cf129fe7b815612064719351c432
[openwrt/staging/stintel.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 bananapi,bpi-r4)
41 . /lib/upgrade/platform.sh
42
43 bootdev="$(platform_get_bootdev)"
44 case "$bootdev" in
45 ubi*)
46 ubootenv_add_ubi_default
47 ;;
48 mmc*)
49 ubootenv_add_mmc_default "${bootdev%%p[0-9]*}"
50 ;;
51 mtd*)
52 ubootenv_add_nor_default
53 ;;
54 esac
55 ;;
56 cmcc,rax3000m)
57 case "$(cmdline_get_var root)" in
58 /dev/mmc*)
59 ubootenv_add_mmc_default
60 ;;
61 *)
62 ubootenv_add_ubi_default
63 ;;
64 esac
65 ;;
66 comfast,cf-e393ax)
67 ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x20000" "0x80000"
68 ;;
69 cetron,ct3003|\
70 netgear,wax220|\
71 zbtlink,zbt-z8102ax|\
72 zbtlink,zbt-z8103ax)
73 ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x20000" "0x20000"
74 ;;
75 h3c,magic-nx30-pro|\
76 jcg,q30-pro|\
77 qihoo,360t7|\
78 tplink,tl-xdr4288|\
79 tplink,tl-xdr6086|\
80 tplink,tl-xdr6088|\
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
86 ;;
87 glinet,gl-mt2500|\
88 glinet,gl-mt6000)
89 local envdev=$(find_mmc_part "u-boot-env")
90 ubootenv_add_uci_config "$envdev" "0x0" "0x80000"
91 ;;
92 glinet,gl-mt3000)
93 ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x80000" "0x20000"
94 ;;
95 jdcloud,re-cp-03)
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"
99 ;;
100 mercusys,mr90x-v1|\
101 routerich,ax3000)
102 local envdev=/dev/mtd$(find_mtd_index "u-boot-env")
103 ubootenv_add_uci_config "$envdev" "0x0" "0x20000" "0x20000" "1"
104 ;;
105 ubnt,unifi-6-plus)
106 ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x80000" "0x10000"
107 ;;
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"
113 ;;
114 zyxel,ex5601-t0)
115 local envdev=/dev/mtd$(find_mtd_index "u-boot-env")
116 ubootenv_add_uci_config "$envdev" "0x0" "0x20000" "0x40000" "2"
117 ;;
118 zyxel,ex5700-telenor)
119 ubootenv_add_uci_config "/dev/ubootenv" "0x0" "0x4000" "0x4000" "1"
120 ;;
121 esac
122
123 config_load ubootenv
124 config_foreach ubootenv_add_app_config
125
126 exit 0