uboot-envtools: filogic: add support for BananaPi R4 PoE
[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-r3-mini|\
41 bananapi,bpi-r4|\
42 bananapi,bpi-r4-poe|\
43 jdcloud,re-cp-03)
44 . /lib/upgrade/common.sh
45
46 bootdev="$(fitblk_get_bootdev)"
47 case "$bootdev" in
48 ubi*)
49 ubootenv_add_ubi_default
50 ;;
51 mmc*)
52 ubootenv_add_mmc_default "${bootdev%%p[0-9]*}"
53 ;;
54 mtd*)
55 ubootenv_add_nor_default
56 ;;
57 esac
58 ;;
59 cmcc,rax3000m)
60 case "$(cmdline_get_var root)" in
61 /dev/mmc*)
62 ubootenv_add_mmc_default
63 ;;
64 *)
65 ubootenv_add_ubi_default
66 ;;
67 esac
68 ;;
69 comfast,cf-e393ax)
70 ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x20000" "0x80000"
71 ;;
72 cetron,ct3003|\
73 edgecore,eap111|\
74 netgear,wax220|\
75 zbtlink,zbt-z8102ax|\
76 zbtlink,zbt-z8103ax)
77 ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x20000" "0x20000"
78 ;;
79 dlink,aquila-pro-ai-m30-a1)
80 ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x40000" "0x40000"
81 ;;
82 h3c,magic-nx30-pro|\
83 jcg,q30-pro|\
84 netcore,n60|\
85 qihoo,360t7|\
86 tplink,tl-xdr4288|\
87 tplink,tl-xdr6086|\
88 tplink,tl-xdr6088|\
89 xiaomi,mi-router-ax3000t-ubootmod|\
90 xiaomi,mi-router-wr30u-ubootmod|\
91 xiaomi,redmi-router-ax6000-ubootmod|\
92 zyxel,ex5601-t0-ubootmod)
93 ubootenv_add_ubi_default
94 ;;
95 glinet,gl-mt2500|\
96 glinet,gl-mt6000)
97 local envdev=$(find_mmc_part "u-boot-env")
98 ubootenv_add_uci_config "$envdev" "0x0" "0x80000"
99 ;;
100 glinet,gl-mt3000)
101 ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x80000" "0x20000"
102 ;;
103 mercusys,mr90x-v1|\
104 routerich,ax3000)
105 local envdev=/dev/mtd$(find_mtd_index "u-boot-env")
106 ubootenv_add_uci_config "$envdev" "0x0" "0x20000" "0x20000" "1"
107 ;;
108 openembed,som7981)
109 ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x80000" "0x80000"
110 ubootenv_add_uci_sys_config "/dev/mtd3" "0x0" "0x100000" "0x100000"
111 ;;
112 ubnt,unifi-6-plus)
113 ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x80000" "0x10000"
114 ;;
115 xiaomi,mi-router-ax3000t|\
116 xiaomi,mi-router-wr30u-stock|\
117 xiaomi,redmi-router-ax6000-stock)
118 ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x10000" "0x20000"
119 ubootenv_add_uci_sys_config "/dev/mtd2" "0x0" "0x10000" "0x20000"
120 ;;
121 zyxel,ex5601-t0)
122 local envdev=/dev/mtd$(find_mtd_index "u-boot-env")
123 ubootenv_add_uci_config "$envdev" "0x0" "0x20000" "0x40000" "2"
124 ;;
125 zyxel,ex5700-telenor)
126 ubootenv_add_uci_config "/dev/ubootenv" "0x0" "0x4000" "0x4000" "1"
127 ;;
128 esac
129
130 config_load ubootenv
131 config_foreach ubootenv_add_app_config
132
133 exit 0