ipq806x 1.2 KB

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