ipq40xx 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #!/bin/sh
  2. #
  3. # Copyright (C) 2016 LEDE
  4. #
  5. [ -e /etc/config/ubootenv ] && exit 0
  6. touch /etc/config/ubootenv
  7. . /lib/uboot-envtools.sh
  8. . /lib/functions.sh
  9. board=$(board_name)
  10. ubootenv_mtdinfo () {
  11. UBOOTENV_PART=$(cat /proc/mtd | grep APPSBLENV)
  12. mtd_dev=$(echo $UBOOTENV_PART | awk '{print $1}' | sed 's/:$//')
  13. mtd_size=$(echo $UBOOTENV_PART | awk '{print "0x"$2}')
  14. mtd_erase=$(echo $UBOOTENV_PART | awk '{print "0x"$3}')
  15. nor_flash=$(find /sys/bus/spi/devices/*/mtd -name ${mtd_dev})
  16. if [ -n "$nor_flash" ]; then
  17. ubootenv_size=$mtd_size
  18. else
  19. # size is fixed to 0x40000 in u-boot
  20. ubootenv_size=0x40000
  21. fi
  22. sectors=$(( $ubootenv_size / $mtd_erase ))
  23. echo /dev/$mtd_dev 0x0 $ubootenv_size $mtd_erase $sectors
  24. }
  25. case "$board" in
  26. alfa-network,ap120c-ac |\
  27. glinet,gl-b1300 |\
  28. openmesh,a42 |\
  29. openmesh,a62)
  30. ubootenv_add_uci_config "/dev/mtd5" "0x0" "0x10000" "0x10000"
  31. ;;
  32. linksys,ea6350v3)
  33. ubootenv_add_uci_config "/dev/mtd7" "0x0" "0x20000" "0x20000"
  34. ;;
  35. linksys,ea8300)
  36. ubootenv_add_uci_config "/dev/mtd7" "0x0" "0x40000" "0x20000"
  37. ;;
  38. zyxel,nbg6617)
  39. ubootenv_add_uci_config "/dev/mtd6" "0x0" "0x10000" "0x10000"
  40. ;;
  41. esac
  42. config_load ubootenv
  43. config_foreach ubootenv_add_app_config ubootenv
  44. exit 0