ipq806x 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. linksys,ea8500)
  27. ubootenv_add_uci_config "/dev/mtd10" "0x0" "0x20000" "0x20000"
  28. ;;
  29. netgear,r7800)
  30. ubootenv_add_uci_config "/dev/mtd2" "0x0" "0x040000" "0x20000"
  31. ;;
  32. qcom,ipq8064-ap148 |\
  33. qcom,ipq8064-db149)
  34. ubootenv_add_uci_config $(ubootenv_mtdinfo)
  35. ;;
  36. zyxel,nbg6817)
  37. ubootenv_add_uci_config "/dev/mtdblock9" "0x0" "0x10000" "0x10000"
  38. ;;
  39. esac
  40. config_load ubootenv
  41. config_foreach ubootenv_add_app_config ubootenv
  42. exit 0