4 .
/lib
/functions
/system.sh
6 do_patch_ath10k_firmware
() {
7 local firmware_file
="/lib/firmware/ath10k/QCA988X/hw2.0/firmware-5.bin"
9 # bail out if firmware does not exist
10 [ -f "$firmware_file" ] ||
return
14 local default_mac
="00:03:07:12:34:56"
15 local current_mac
="$(hexdump -v -n $mac_length -s $mac_offset -e '5/1 "%02x
:" 1/1 "%02x
"' $firmware_file 2>/dev/null)"
17 # check if mac address was already patched
18 [ "$default_mac" = "$current_mac" ] ||
return
20 # some boards have bogus mac in otp (= directly in the PCIe card's EEPROM).
21 # we have to patch the default mac in the firmware because we cannot change
27 mac
=$
(mtd_get_mac_ascii nvram wlan1_mac
)
29 cp $firmware_file /tmp
/ath10k-firmware.bin
30 macaddr_2bin
$mac |
dd of
=/tmp
/ath10k-firmware.bin \
31 conv
=notrunc bs
=1 seek
=$mac_offset count
=$mac_length
35 [ -f /tmp
/ath10k-firmware.bin
] ||
return
37 cp /tmp
/ath10k-firmware.bin
$firmware_file
38 rm /tmp
/ath10k-firmware.bin
41 check_patch_ath10k_firmware
() {
45 do_patch_ath10k_firmware
50 boot_hook_add preinit_main check_patch_ath10k_firmware