ipq40xx 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. alfa-network,ap120c-ac|\
  27. devolo,magic-2-wifi-next|\
  28. edgecore,ecw5211|\
  29. glinet,gl-a1300 |\
  30. glinet,gl-ap1300|\
  31. glinet,gl-b1300|\
  32. glinet,gl-b2200|\
  33. luma,wrtq-329acn|\
  34. netgear,wac510|\
  35. openmesh,a42|\
  36. openmesh,a62|\
  37. pakedge,wr-1|\
  38. plasmacloud,pa1200|\
  39. plasmacloud,pa2200)
  40. ubootenv_add_uci_config "/dev/mtd5" "0x0" "0x10000" "0x10000"
  41. ;;
  42. aruba,ap-303)
  43. ubootenv_add_uci_config "/dev/mtd13" "0x0" "0x10000" "0x10000"
  44. ;;
  45. aruba,ap-365)
  46. ubootenv_add_uci_config "/dev/mtd8" "0x0" "0x10000" "0x10000"
  47. ;;
  48. buffalo,wtr-m2133hp)
  49. ubootenv_add_uci_config "/dev/mtd8" "0x0" "0x40000" "0x20000"
  50. ;;
  51. linksys,ea6350v3)
  52. ubootenv_add_uci_config "/dev/mtd7" "0x0" "0x20000" "0x20000"
  53. ;;
  54. linksys,ea8300|\
  55. linksys,mr8300)
  56. ubootenv_add_uci_config "/dev/mtd7" "0x0" "0x40000" "0x20000"
  57. ;;
  58. linksys,whw01-v1)
  59. ubootenv_add_uci_config "/dev/mtd6" "0x0" "0x40000" "0x10000"
  60. ;;
  61. zyxel,nbg6617)
  62. ubootenv_add_uci_config "/dev/mtd6" "0x0" "0x10000" "0x10000"
  63. ;;
  64. esac
  65. config_load ubootenv
  66. config_foreach ubootenv_add_app_config ubootenv
  67. exit 0