mikrotik-caldata.sh 708 B

1234567891011121314151617181920212223242526
  1. # Copyright (C) 2019 Robert Marko <[email protected]>
  2. # Copyright (C) 2019 Roger Pueyo Centelles <[email protected]>
  3. #
  4. # Helper function to extract MAC addresses and calibration data for MikroTik
  5. #
  6. mikrotik_caldata_extract() {
  7. local part=$1
  8. local offset=$(($2))
  9. local count=$(($3))
  10. local mtd
  11. local erdfile="/tmp/erd.bin"
  12. local fwfile="/lib/firmware/${FIRMWARE}"
  13. [ -e $fwfile ] && exit 0
  14. mtd=$(find_mtd_chardev $part)
  15. [ -n "$mtd" ] || caldata_die "no mtd device found for partition $part"
  16. rbextract -e $mtd $erdfile
  17. dd if=$erdfile of=$fwfile iflag=skip_bytes bs=$count skip=$offset count=1 2>/dev/null || \
  18. caldata_die "failed to extract calibration data from $mtd"
  19. rm -f $erdfile
  20. }