732f7d5a0e5f8d466d530251fb706546e8220bc4
[openwrt/staging/jow.git] / package / boot / uboot-envtools / files / mediatek_mt7622
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 ubootenv_add_mmc_default() {
13 local envdev="$(find_mmc_part "ubootenv" "${1:-mmcblk0}")"
14 ubootenv_add_uci_config "$envdev" "0x0" "0x80000" "0x80000" "1"
15 ubootenv_add_uci_config "$envdev" "0x80000" "0x80000" "0x80000" "1"
16 }
17
18 ubootenv_add_ubi_default() {
19 . /lib/upgrade/nand.sh
20 local envubi=$(nand_find_ubi ubi)
21 local envdev=/dev/$(nand_find_volume $envubi ubootenv)
22 local envdev2=/dev/$(nand_find_volume $envubi ubootenv2)
23 ubootenv_add_uci_config "$envdev" "0x0" "0x1f000" "0x1f000" "1"
24 ubootenv_add_uci_config "$envdev2" "0x0" "0x1f000" "0x1f000" "1"
25 }
26
27 board=$(board_name)
28
29 case "$board" in
30 dlink,eagle-pro-ai-m32-a1|\
31 dlink,eagle-pro-ai-r32-a1)
32 ubootenv_add_uci_config "/dev/mtd3" "0x0" "0x2000" "0x2000"
33 ;;
34 linksys,e8450-ubi)
35 ubootenv_add_ubi_default
36 ;;
37 bananapi,bpi-r64)
38 . /lib/upgrade/platform.sh
39 bootdev="$(platform_get_bootdev)"
40 case "$bootdev" in
41 mmc*)
42 ubootenv_add_mmc_default "${bootdev%p[0-9]*}"
43 ;;
44 ubi*)
45 ubootenv_add_ubi_default
46 ;;
47 esac
48 ;;
49 buffalo,wsr-2533dhp2)
50 ubootenv_add_uci_config "/dev/mtd3" "0x0" "0x1000" "0x20000"
51 ;;
52 ruijie,rg-ew3200gx-pro)
53 ubootenv_add_uci_config "/dev/mtd3" "0x0" "0x20000" "0x20000"
54 ;;
55 ubnt,unifi-6-lr-ubootmod)
56 ubootenv_add_uci_config "/dev/mtd2" "0x0" "0x4000" "0x1000"
57 ;;
58 xiaomi,redmi-router-ax6s)
59 ubootenv_add_uci_config "/dev/mtd3" "0x0" "0x10000" "0x40000"
60 ;;
61 esac
62
63 config_load ubootenv
64 config_foreach ubootenv_add_app_config ubootenv
65
66 exit 0