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