add D-link DGL-5500 A1 support
[openwrt/openwrt.git] / target / linux / ar71xx / base-files / lib / preinit / 82_patch_ath10k
1 #!/bin/sh
2
3 . /lib/functions/system.sh
4 . /lib/ar71xx.sh
5
6 firmware_file="/lib/firmware/ath10k/QCA988X/hw2.0/firmware-3.bin"
7 firmware_md5_orig="5163aa8de591f80b06c77f22e9777473"
8 firmware_md5_current="$(md5sum $firmware_file)"
9 firmware_md5_current="${firmware_md5_current%% *}"
10
11
12 do_patch_ath10k_firmware() {
13 # verify md5sum before patching
14 [ "firmware_md5_orig" != "firmware_md5_current" ] || {
15 return
16 }
17
18 # some boards have bogus mac in otp, patch the default mac in the firmware
19 case $(ar71xx_board_name) in
20 dgl-5500-a1)
21 local mac
22 mac=$(mtd_get_mac_ascii nvram wlan1_mac)
23
24 cp $firmware_file /tmp/ath10k-firmware.bin
25 macaddr_2bin $mac | dd of=/tmp/ath10k-firmware.bin \
26 conv=notrunc bs=1 seek=280 count=6
27
28 ;;
29 esac
30 [ -f /tmp/ath10k-firmware.bin ] || {
31 return
32 }
33 cp /tmp/ath10k-firmware.bin $firmware_file
34 rm /tmp/ath10k-firmware.bin
35 }
36
37 boot_hook_add preinit_main do_patch_ath10k_firmware