ipq806x 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #
  2. # Copyright (C) 2016 LEDE
  3. #
  4. [ -e /etc/config/ubootenv ] && exit 0
  5. touch /etc/config/ubootenv
  6. . /lib/uboot-envtools.sh
  7. . /lib/functions.sh
  8. board=$(board_name)
  9. ubootenv_mtdinfo () {
  10. UBOOTENV_PART=$(cat /proc/mtd | grep APPSBLENV)
  11. mtd_dev=$(echo $UBOOTENV_PART | awk '{print $1}' | sed 's/:$//')
  12. mtd_size=$(echo $UBOOTENV_PART | awk '{print "0x"$2}')
  13. mtd_erase=$(echo $UBOOTENV_PART | awk '{print "0x"$3}')
  14. nor_flash=$(find /sys/bus/spi/devices/*/mtd -name ${mtd_dev})
  15. if [ -n "$nor_flash" ]; then
  16. ubootenv_size=$mtd_size
  17. else
  18. # size is fixed to 0x40000 in u-boot
  19. ubootenv_size=0x40000
  20. fi
  21. sectors=$(( $ubootenv_size / $mtd_erase ))
  22. echo /dev/$mtd_dev 0x0 $ubootenv_size $mtd_erase $sectors
  23. }
  24. case "$board" in
  25. askey,rt4230w-rev6)
  26. ubootenv_add_uci_config "/dev/mtd9" "0x0" "0x40000" "0x20000"
  27. ;;
  28. edgecore,ecw5410)
  29. ubootenv_add_uci_config "/dev/mtd11" "0x0" "0x10000" "0x10000"
  30. ;;
  31. linksys,ea7500-v1|\
  32. linksys,ea8500)
  33. ubootenv_add_uci_config "/dev/mtd10" "0x0" "0x20000" "0x20000"
  34. ;;
  35. netgear,r7800)
  36. ubootenv_add_uci_config "/dev/mtd2" "0x0" "0x040000" "0x20000"
  37. ;;
  38. qcom,ipq8064-ap148|\
  39. qcom,ipq8064-db149)
  40. ubootenv_add_uci_config $(ubootenv_mtdinfo)
  41. ;;
  42. ubnt,unifi-ac-hd|\
  43. zyxel,nbg6817)
  44. ubootenv_add_uci_config "/dev/mtdblock9" "0x0" "0x10000" "0x10000"
  45. ;;
  46. esac
  47. config_load ubootenv
  48. config_foreach ubootenv_add_app_config ubootenv
  49. exit 0