10-rt2x00-eeprom 883 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. . /lib/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 2>/dev/null || \
  16. rt2x00_eeprom_die "failed to extract from $mtd"
  17. }
  18. FW="/lib/firmware/$FIRMWARE"
  19. [ -e "$FW" ] && exit 0
  20. . /lib/ramips.sh
  21. board=$(ramips_board_name)
  22. case "$FIRMWARE" in
  23. "soc_wmac.eeprom")
  24. case $board in
  25. *)
  26. rt2x00_eeprom_die "Please define mtd-eeprom in $board DTS file!"
  27. ;;
  28. esac
  29. ;;
  30. "rt2x00pci_1_0.eeprom")
  31. case $board in
  32. cy-swr1100)
  33. rt2x00_eeprom_extract "factory" 8192 512
  34. ;;
  35. br-6475nd | rt-n56u | whr-600d | whr-1166d)
  36. rt2x00_eeprom_extract "factory" 32768 512
  37. ;;
  38. esac
  39. ;;
  40. esac