82_patch_ath10k 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #!/bin/sh
  2. . /lib/functions/system.sh
  3. . /lib/ar71xx.sh
  4. do_patch_ath10k_firmware() {
  5. local firmware_file="/lib/firmware/ath10k/QCA988X/hw2.0/firmware-5.bin"
  6. # bail out if firmware does not exist
  7. [ -f "$firmware_file" ] || {
  8. return
  9. }
  10. local firmware_md5_orig="fcb2fbd42d73a63fbf603505c718cbde"
  11. local firmware_md5_current="$(md5sum $firmware_file)"
  12. local firmware_md5_current="${firmware_md5_current%% *}"
  13. # verify md5sum before patching
  14. [ "$firmware_md5_orig" != "$firmware_md5_current" ] || {
  15. return
  16. }
  17. # some boards have bogus mac in otp, patch the default mac in the firmware
  18. case $(ar71xx_board_name) in
  19. dgl-5500-a1 | tew-823dru)
  20. local mac
  21. mac=$(mtd_get_mac_ascii nvram wlan1_mac)
  22. cp $firmware_file /tmp/ath10k-firmware.bin
  23. macaddr_2bin $mac | dd of=/tmp/ath10k-firmware.bin \
  24. conv=notrunc bs=1 seek=276 count=6
  25. ;;
  26. esac
  27. [ -f /tmp/ath10k-firmware.bin ] || {
  28. return
  29. }
  30. cp /tmp/ath10k-firmware.bin $firmware_file
  31. rm /tmp/ath10k-firmware.bin
  32. }
  33. check_patch_ath10k_firmware() {
  34. case $(ar71xx_board_name) in
  35. dgl-5500-a1 | tew-823dru)
  36. do_patch_ath10k_firmware
  37. ;;
  38. esac
  39. }
  40. boot_hook_add preinit_main check_patch_ath10k_firmware