ipq806x 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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 -i 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. ignitenet,ss-w2-ac2600|\
  38. qcom,ipq8064-ap148|\
  39. qcom,ipq8064-db149)
  40. ubootenv_add_uci_config $(ubootenv_mtdinfo)
  41. ;;
  42. linksys,ea7500-v1|\
  43. linksys,ea8500)
  44. ubootenv_add_uci_config "/dev/mtd10" "0x0" "0x20000" "0x20000"
  45. ;;
  46. netgear,r7800)
  47. ubootenv_add_uci_config "/dev/mtd2" "0x0" "0x040000" "0x20000"
  48. ;;
  49. nokia,ac400i)
  50. ubootenv_add_uci_config "/dev/mtd20" "0x0" "0x040000" "0x20000"
  51. ;;
  52. ubnt,unifi-ac-hd|\
  53. zyxel,nbg6817)
  54. ubootenv_add_uci_config "/dev/mtdblock9" "0x0" "0x10000" "0x10000"
  55. ;;
  56. esac
  57. config_load ubootenv
  58. config_foreach ubootenv_add_app_config ubootenv
  59. exit 0