3 .
/lib
/functions
/k2t.sh
5 # xor multiple hex values of the same length
18 printf "%0${retlen}x" "$ret"
22 echo "ath10cal: " "$*"
26 ath10kcal_from_file
() {
31 dd if=$source of
=/lib
/firmware
/$FIRMWARE bs
=1 skip
=$offset count
=$count 2>/dev
/null || \
32 ath10kcal_die
"failed to extract calibration data from $source"
41 mtd
=$
(find_mtd_chardev
$part)
43 ath10kcal_die
"no mtd device found for partition $part"
45 dd if=$mtd of
=/lib
/firmware
/$FIRMWARE bs
=1 skip
=$offset count
=$count 2>/dev
/null || \
46 ath10kcal_die
"failed to extract calibration data from $mtd"
49 ath10kcal_patch_mac
() {
52 [ -z "$mac" ] && return
54 macaddr_2bin
$mac |
dd of
=/lib
/firmware
/$FIRMWARE conv
=notrunc bs
=1 seek
=6 count
=6
57 ath10kcal_patch_mac_crc
() {
65 xor_fw_mac
=$
(hexdump -v -n 6 -s $mac_offset -e '/1 "%02x"' /lib
/firmware
/$FIRMWARE)
66 xor_fw_mac
="${xor_fw_mac:0:4} ${xor_fw_mac:4:4} ${xor_fw_mac:8:4}"
68 ath10kcal_patch_mac
"$mac" && {
70 xor_mac
="${xor_mac:0:4} ${xor_mac:4:4} ${xor_mac:8:4}"
72 xor_fw_chksum
=$
(hexdump -v -n 2 -s $chksum_offset -e '/1 "%02x"' /lib
/firmware
/$FIRMWARE)
73 xor_fw_chksum
=$
(xor
$xor_fw_chksum $xor_fw_mac $xor_mac)
75 printf "%b" "\x${xor_fw_chksum:0:2}\x${xor_fw_chksum:2:2}" | \
76 dd of
=/lib
/firmware
/$FIRMWARE conv
=notrunc bs
=1 seek
=$chksum_offset count
=2
80 [ -e /lib
/firmware
/$FIRMWARE ] && exit 0
83 .
/lib
/functions
/system.sh
88 "ath10k/cal-pci-0000:00:00.0.bin")
95 ath10kcal_extract
"art" 20480 2116
96 ath10kcal_patch_mac_crc $
(macaddr_add $
(mtd_get_mac_binary art
0) -1)
99 ath10kcal_extract
"art" 20480 2116
100 ath10kcal_patch_mac $
(mtd_get_mac_ascii devdata
"wlan5mac")
102 elecom
,wrc-1750ghbk2-i
)
103 ath10kcal_extract
"ART" 20480 2116
109 ath10kcal_extract
"art" 20480 2116
110 ath10kcal_patch_mac $
(macaddr_add $
(cat /sys
/class
/net
/eth
0/address
) +1)
112 iodata
,wn-ac1167dgr|\
113 iodata
,wn-ac1600dgr2
)
114 ath10kcal_extract
"art" 20480 2116
115 ath10kcal_patch_mac $
(macaddr_add $
(mtd_get_mac_ascii u-boot-env ethaddr
) +1)
118 ath10kcal_extract
"art" 20480 2116
119 ath10kcal_patch_mac_crc $
(mtd_get_mac_text board_data
2176)
122 ath10kcal_extract
"art" 20480 2116
123 ath10kcal_patch_mac $
(mtd_get_mac_binary art
12)
126 ath10kcal_extract
"ART" 20480 2116
127 ath10kcal_patch_mac $
(macaddr_add $
(cat /sys
/class
/net
/eth
0/address
) +16)
130 ath10kcal_extract
"ART" 20480 2116
131 ath10kcal_patch_mac $
(macaddr_add $
(cat /sys
/class
/net
/eth
0/address
) -1)
133 tplink
,archer-c5-v1|\
135 ath10kcal_extract
"art" 20480 2116
136 ath10kcal_patch_mac $
(macaddr_add $
(cat /sys
/class
/net
/eth
1/address
) -1)
138 tplink
,archer-a7-v5|\
139 tplink
,archer-c7-v4|\
141 ath10kcal_extract
"art" 20480 2116
142 ath10kcal_patch_mac $
(macaddr_add $
(cat /sys
/class
/net
/eth
0/address
) -1)
146 ubnt
,unifiac-mesh-pro|\
148 ubnt
,nanostation-ac|\
149 ubnt
,nanostation-ac-loco|\
151 ath10kcal_extract
"EEPROM" 20480 2116
155 "ath10k/pre-cal-pci-0000:00:00.0.bin")
158 ath10kcal_extract
"art" 20480 12064
159 ath10kcal_patch_mac_crc $
(k2t_get_mac
"5g_mac")
160 ln -sf /lib
/firmware
/ath10k
/pre-cal-pci-0000\
:00\
:00.0.bin \
161 /lib
/firmware
/ath10k
/QCA9888
/hw2.0
/board.bin
163 tplink
,archer-c58-v1|\
164 tplink
,archer-c59-v1|\
166 ath10kcal_extract
"art" 20480 12064
167 ath10kcal_patch_mac_crc $
(macaddr_add $
(mtd_get_mac_binary mac
8) -1)
168 ln -sf /lib
/firmware
/ath10k
/pre-cal-pci-0000\
:00\
:00.0.bin \
169 /lib
/firmware
/ath10k
/QCA9888
/hw2.0
/board.bin