2 # Copyright (C) 2016 LEDE
5 [ -e /etc/config/ubootenv ] && exit 0
7 touch /etc/config/ubootenv
9 . /lib/uboot-envtools.sh
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})
21 if [ -n "$nor_flash" ]; then
22 ubootenv_size=$mtd_size
24 # size is fixed to 0x40000 in u-boot
28 sectors=$(( $ubootenv_size / $mtd_erase ))
29 sectors=$(printf "0x%x" $sectors )
30 echo /dev/$mtd_dev 0x0 $ubootenv_size $mtd_erase $sectors
34 alfa-network,ap120c-ac|\
35 devolo,magic-2-wifi-next|\
48 ubootenv_add_uci_config "/dev/mtd5" "0x0" "0x10000" "0x10000"
51 ubootenv_add_uci_config "/dev/mtd13" "0x0" "0x10000" "0x10000"
54 ubootenv_add_uci_config "/dev/mtd8" "0x0" "0x10000" "0x10000"
57 ubootenv_add_uci_config "/dev/mtd8" "0x0" "0x40000" "0x20000"
60 ubootenv_add_uci_config "/dev/mtd7" "0x0" "0x20000" "0x20000"
64 ubootenv_add_uci_config "/dev/mtd7" "0x0" "0x40000" "0x20000"
67 ubootenv_add_uci_config "/dev/mtd6" "0x0" "0x40000" "0x10000"
70 ubootenv_add_uci_config "/dev/mtd6" "0x0" "0x10000" "0x10000"
75 config_foreach ubootenv_add_app_config ubootenv