blob: cc3dc42c9c74bb58cf1c7f76ba704eaf069267d2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
#!/bin/sh
. /lib/functions.sh
. /lib/functions/system.sh
do_patch_ath10k_firmware() {
local firmware_file="/lib/firmware/ath10k/QCA988X/hw2.0/firmware-5.bin"
# bail out if firmware does not exist
[ -f "$firmware_file" ] || return
local mac_offset=276
local mac_length=6
local default_mac="00:03:07:12:34:56"
local current_mac="$(hexdump -v -n $mac_length -s $mac_offset -e '5/1 "%02x:" 1/1 "%02x"' $firmware_file 2>/dev/null)"
# check if mac address was already patched
[ "$default_mac" = "$current_mac" ] || return
# some boards have bogus mac in otp (= directly in the PCIe card's EEPROM).
# we have to patch the default mac in the firmware because we cannot change
# the otp.
case $(board_name) in
dgl-5500-a1|\
tew-823dru)
local mac
mac=$(mtd_get_mac_ascii nvram wlan1_mac)
cp $firmware_file /tmp/ath10k-firmware.bin
macaddr_2bin $mac | dd of=/tmp/ath10k-firmware.bin \
conv=notrunc bs=1 seek=$mac_offset count=$mac_length
;;
esac
[ -f /tmp/ath10k-firmware.bin ] || return
cp /tmp/ath10k-firmware.bin $firmware_file
rm /tmp/ath10k-firmware.bin
}
check_patch_ath10k_firmware() {
case $(board_name) in
dgl-5500-a1|\
tew-823dru)
do_patch_ath10k_firmware
;;
esac
}
boot_hook_add preinit_main check_patch_ath10k_firmware
|