uboot-envtools: mediatek_filogic: update bpi-r3
[openwrt/staging/dangole.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 cetron,ct3003|\
67 netgear,wax220|\
68 zbtlink,zbt-z8102ax|\
69 zbtlink,zbt-z8103ax)
70 ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x20000" "0x20000"
71 ;;
72 h3c,magic-nx30-pro|\
73 jcg,q30-pro|\
74 qihoo,360t7|\
75 tplink,tl-xdr4288|\
76 tplink,tl-xdr6086|\
77 tplink,tl-xdr6088|\
78 xiaomi,mi-router-ax3000t-ubootmod|\
79 xiaomi,mi-router-wr30u-ubootmod|\
80 xiaomi,redmi-router-ax6000-ubootmod|\
81 zyxel,ex5601-t0-ubootmod)
82 ubootenv_add_ubi_default
83 ;;
84 glinet,gl-mt2500|\
85 glinet,gl-mt6000)
86 local envdev=$(find_mmc_part "u-boot-env")
87 ubootenv_add_uci_config "$envdev" "0x0" "0x80000"
88 ;;
89 glinet,gl-mt3000)
90 ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x80000" "0x20000"
91 ;;
92 jdcloud,re-cp-03)
93 local envdev=$(find_mmc_part "ubootenv" "mmcblk0")
94 ubootenv_add_uci_config "$envdev" "0x0" "0x40000" "0x40000" "1"
95 ubootenv_add_uci_config "$envdev" "0x40000" "0x40000" "0x40000" "1"
96 ;;
97 mercusys,mr90x-v1|\
98 routerich,ax3000)
99 local envdev=/dev/mtd$(find_mtd_index "u-boot-env")
100 ubootenv_add_uci_config "$envdev" "0x0" "0x20000" "0x20000" "1"
101 ;;
102 ubnt,unifi-6-plus)
103 ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x80000" "0x10000"
104 ;;
105 xiaomi,mi-router-ax3000t|\
106 xiaomi,mi-router-wr30u-stock|\
107 xiaomi,redmi-router-ax6000-stock)
108 ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x10000" "0x20000"
109 ubootenv_add_uci_sys_config "/dev/mtd2" "0x0" "0x10000" "0x20000"
110 ;;
111 zyxel,ex5601-t0)
112 local envdev=/dev/mtd$(find_mtd_index "u-boot-env")
113 ubootenv_add_uci_config "$envdev" "0x0" "0x20000" "0x40000" "2"
114 ;;
115 zyxel,ex5700-telenor)
116 ubootenv_add_uci_config "/dev/ubootenv" "0x0" "0x4000" "0x4000" "1"
117 ;;
118 esac
119
120 config_load ubootenv
121 config_foreach ubootenv_add_app_config
122
123 exit 0