10-rt2x00-eeprom 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #!/bin/sh
  2. rt2x00_eeprom_die() {
  3. echo "rt2x00 eeprom: " "$*"
  4. exit 1
  5. }
  6. rt2x00_eeprom_extract() {
  7. local part=$1
  8. local offset=$2
  9. local count=$3
  10. local mtd
  11. . /etc/functions.sh
  12. mtd=$(find_mtd_part $part)
  13. [ -n "$mtd" ] || \
  14. rt2x00_eeprom_die "no mtd device found for partition $part"
  15. dd if=$mtd of=/lib/firmware/$FIRMWARE bs=1 skip=$offset count=$count || \
  16. rt2x00_eeprom_die "failed to extract from $mtd"
  17. }
  18. [ -e /lib/firmware/$FIRMWARE ] && exit 0
  19. case "$FIRMWARE" in
  20. "RT288X.eeprom" | \
  21. "RT305X.eeprom")
  22. . /lib/ramips.sh
  23. local board=$(ramips_board_name)
  24. case $board in
  25. dir-300-b1 | \
  26. dir-600-b1 | \
  27. dir-600-b2)
  28. rt2x00_eeprom_extract "devdata" 16384 272
  29. ;;
  30. rt-g32-b1)
  31. rt2x00_eeprom_extract "devconf" 0 272
  32. ;;
  33. f5d8235-v2)
  34. rt2x00_eeprom_extract "u-boot" 262144 272
  35. ;;
  36. argus-atp52b | \
  37. fonera20n | \
  38. hw550-3g | \
  39. mofi3500-3gn | \
  40. pwh2004 | \
  41. nbg-419n | \
  42. nw718 | \
  43. rt-n15 | \
  44. v22rw-2x2 | \
  45. wcr150gn | \
  46. whr-g300n | \
  47. wr512-3gn)
  48. rt2x00_eeprom_extract "factory" 0 272
  49. ;;
  50. *)
  51. rt2x00_eeprom_die "board $board is not supported yet"
  52. ;;
  53. esac
  54. ;;
  55. esac