ipq806x 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. sectors=$(printf "0x%x" $sectors )
  23. echo /dev/$mtd_dev 0x0 $ubootenv_size $mtd_erase $sectors
  24. }
  25. case "$board" in
  26. arris,tr4400-v2|\
  27. askey,rt4230w-rev6)
  28. ubootenv_add_uci_config "/dev/mtd9" "0x0" "0x40000" "0x20000"
  29. ;;
  30. edgecore,ecw5410)
  31. ubootenv_add_uci_config "/dev/mtd11" "0x0" "0x10000" "0x10000"
  32. ;;
  33. extreme,ap3935)
  34. ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x10000" "0x10000"
  35. ubootenv_add_uci_config "/dev/mtd3" "0x0" "0x10000" "0x10000"
  36. ;;
  37. linksys,ea7500-v1|\
  38. linksys,ea8500)
  39. ubootenv_add_uci_config "/dev/mtd10" "0x0" "0x20000" "0x20000"
  40. ;;
  41. netgear,r7800)
  42. ubootenv_add_uci_config "/dev/mtd2" "0x0" "0x040000" "0x20000"
  43. ;;
  44. nokia,ac400i)
  45. ubootenv_add_uci_config "/dev/mtd20" "0x0" "0x040000" "0x20000"
  46. ;;
  47. qcom,ipq8064-ap148|\
  48. qcom,ipq8064-db149)
  49. ubootenv_add_uci_config $(ubootenv_mtdinfo)
  50. ;;
  51. ubnt,unifi-ac-hd|\
  52. zyxel,nbg6817)
  53. ubootenv_add_uci_config "/dev/mtdblock9" "0x0" "0x10000" "0x10000"
  54. ;;
  55. esac
  56. config_load ubootenv
  57. config_foreach ubootenv_add_app_config ubootenv
  58. exit 0