ipq40xx: fix up Linksys WHW01 board name, device definition
[openwrt/openwrt.git] / package / boot / uboot-envtools / files / ipq40xx
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 sectors=$(printf "0x%x" $sectors )
30 echo /dev/$mtd_dev 0x0 $ubootenv_size $mtd_erase $sectors
31 }
32
33 case "$board" in
34 alfa-network,ap120c-ac|\
35 devolo,magic-2-wifi-next|\
36 edgecore,ecw5211|\
37 glinet,gl-a1300 |\
38 glinet,gl-ap1300|\
39 glinet,gl-b1300|\
40 glinet,gl-b2200|\
41 luma,wrtq-329acn|\
42 netgear,wac510|\
43 openmesh,a42|\
44 openmesh,a62|\
45 pakedge,wr-1|\
46 plasmacloud,pa1200|\
47 plasmacloud,pa2200)
48 ubootenv_add_uci_config "/dev/mtd5" "0x0" "0x10000" "0x10000"
49 ;;
50 aruba,ap-303)
51 ubootenv_add_uci_config "/dev/mtd13" "0x0" "0x10000" "0x10000"
52 ;;
53 aruba,ap-365)
54 ubootenv_add_uci_config "/dev/mtd8" "0x0" "0x10000" "0x10000"
55 ;;
56 buffalo,wtr-m2133hp)
57 ubootenv_add_uci_config "/dev/mtd8" "0x0" "0x40000" "0x20000"
58 ;;
59 linksys,ea6350v3)
60 ubootenv_add_uci_config "/dev/mtd7" "0x0" "0x20000" "0x20000"
61 ;;
62 linksys,ea8300|\
63 linksys,mr8300)
64 ubootenv_add_uci_config "/dev/mtd7" "0x0" "0x40000" "0x20000"
65 ;;
66 linksys,whw01)
67 ubootenv_add_uci_config "/dev/mtd6" "0x0" "0x40000" "0x10000"
68 ;;
69 zyxel,nbg6617)
70 ubootenv_add_uci_config "/dev/mtd6" "0x0" "0x10000" "0x10000"
71 ;;
72 esac
73
74 config_load ubootenv
75 config_foreach ubootenv_add_app_config ubootenv
76
77 exit 0