ipq806x: add support for Arris TR4400 v2 / RAC2V1A
[openwrt/openwrt.git] / package / boot / uboot-envtools / files / ipq806x
1 #
2 # Copyright (C) 2016 LEDE
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_mtdinfo () {
15 UBOOTENV_PART=$(cat /proc/mtd | grep APPSBLENV)
16 mtd_dev=$(echo $UBOOTENV_PART | awk '{print $1}' | sed 's/:$//')
17 mtd_size=$(echo $UBOOTENV_PART | awk '{print "0x"$2}')
18 mtd_erase=$(echo $UBOOTENV_PART | awk '{print "0x"$3}')
19 nor_flash=$(find /sys/bus/spi/devices/*/mtd -name ${mtd_dev})
20
21 if [ -n "$nor_flash" ]; then
22 ubootenv_size=$mtd_size
23 else
24 # size is fixed to 0x40000 in u-boot
25 ubootenv_size=0x40000
26 fi
27
28 sectors=$(( $ubootenv_size / $mtd_erase ))
29 echo /dev/$mtd_dev 0x0 $ubootenv_size $mtd_erase $sectors
30 }
31
32 case "$board" in
33 arris,tr4400-v2|\
34 askey,rt4230w-rev6)
35 ubootenv_add_uci_config "/dev/mtd9" "0x0" "0x40000" "0x20000"
36 ;;
37 edgecore,ecw5410)
38 ubootenv_add_uci_config "/dev/mtd11" "0x0" "0x10000" "0x10000"
39 ;;
40 linksys,ea7500-v1|\
41 linksys,ea8500)
42 ubootenv_add_uci_config "/dev/mtd10" "0x0" "0x20000" "0x20000"
43 ;;
44 netgear,r7800)
45 ubootenv_add_uci_config "/dev/mtd2" "0x0" "0x040000" "0x20000"
46 ;;
47 qcom,ipq8064-ap148|\
48 qcom,ipq8064-db149)
49 ubootenv_add_uci_config $(ubootenv_mtdinfo)
50 ;;
51 ubnt,unifi-ac-hd|\
52 zyxel,nbg6817)
53 ubootenv_add_uci_config "/dev/mtdblock9" "0x0" "0x10000" "0x10000"
54 ;;
55 esac
56
57 config_load ubootenv
58 config_foreach ubootenv_add_app_config ubootenv
59
60 exit 0