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 iflag
=skip_bytes bs
=$count skip
=$offset count
=1 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 iflag
=skip_bytes bs
=$count skip
=$offset count
=1 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 oflag
=seek_bytes bs
=6 seek
=6 count
=1
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")
90 comfast
,cf-wr650ac-v1|\
91 comfast
,cf-wr650ac-v2|\
93 ath10kcal_extract
"art" 0x5000 0x844
101 ath10kcal_extract
"art" 0x5000 0x844
102 ath10kcal_patch_mac_crc $
(macaddr_add $
(mtd_get_mac_binary art
0x0) -1)
105 ath10kcal_extract
"art" 0x5000 0x844
106 ath10kcal_patch_mac $
(mtd_get_mac_ascii devdata
"wlan5mac")
108 elecom
,wrc-1750ghbk2-i
)
109 ath10kcal_extract
"art" 0x5000 0x844
112 ath10kcal_extract
"art" 0x5000 0x844
113 ath10kcal_patch_mac $
(mtd_get_mac_ascii u-boot-env athaddr
)
116 iodata
,wn-ac1167dgr|\
117 iodata
,wn-ac1600dgr2
)
118 ath10kcal_extract
"art" 0x5000 0x844
119 ath10kcal_patch_mac $
(macaddr_add $
(mtd_get_mac_ascii u-boot-env ethaddr
) +1)
122 ath10kcal_extract
"art" 0x5000 0x844
123 ath10kcal_patch_mac $
(macaddr_add $
(cat /sys
/class
/net
/eth
0/address
) +1)
127 ath10kcal_extract
"art" 0x5000 0x844
128 ath10kcal_patch_mac $
(macaddr_add $
(mtd_get_mac_binary art
0x0) +1)
131 ath10kcal_extract
"art" 0x5000 0x844
132 ath10kcal_patch_mac $
(macaddr_add $
(mtd_get_mac_binary art
0x0) +2)
135 ath10kcal_extract
"art" 0x5000 0x844
136 ath10kcal_patch_mac_crc $
(mtd_get_mac_text board_data
0x880)
140 ath10kcal_extract
"art" 0x5000 0x844
141 ath10kcal_patch_mac $
(mtd_get_mac_binary art
0xc)
144 ath10kcal_extract
"art" 0x5000 0x844
145 ath10kcal_patch_mac $
(macaddr_add $
(cat /sys
/class
/net
/eth
0/address
) +16)
148 ath10kcal_extract
"radiocfg" 0x5000 0x844
149 ath10kcal_patch_mac_crc $
(mtd_get_mac_ascii devdata wlan5mac
)
151 tplink
,archer-a7-v5|\
152 tplink
,archer-c2-v3|\
153 tplink
,archer-c7-v4|\
154 tplink
,archer-c7-v5|\
155 tplink
,archer-c25-v1
)
156 ath10kcal_extract
"art" 0x5000 0x844
157 ath10kcal_patch_mac $
(macaddr_add $
(mtd_get_mac_binary info
0x8) -1)
159 tplink
,archer-c5-v1|\
161 ath10kcal_extract
"art" 0x5000 0x844
162 ath10kcal_patch_mac $
(macaddr_add $
(mtd_get_mac_binary u-boot
0x1fc00) -1)
164 tplink
,archer-d50-v1
)
165 ath10kcal_extract
"art" 0x5000 0x844
166 ath10kcal_patch_mac $
(macaddr_add $
(mtd_get_mac_binary romfile
0xf100) +2)
169 ath10kcal_extract
"art" 0x5000 0x844
170 ath10kcal_patch_mac $
(macaddr_add $
(mtd_get_mac_binary config
0x10008) +2)
174 ath10kcal_extract
"art" 0x5000 0x844
175 ath10kcal_patch_mac $
(macaddr_add $
(cat /sys
/class
/net
/eth
0/address
) -2)
178 ath10kcal_extract
"art" 0x5000 0x844
179 ath10kcal_patch_mac $
(macaddr_add $
(mtd_get_mac_binary info
0x8) +1)
183 ubnt
,unifiac-mesh-pro|\
186 ubnt
,nanostation-ac|\
187 ubnt
,nanostation-ac-loco|\
189 ath10kcal_extract
"EEPROM" 0x5000 0x844
193 "ath10k/pre-cal-pci-0000:00:00.0.bin")
196 ath10kcal_extract
"art" 0x5000 0x2f20
197 ath10kcal_patch_mac_crc $
(mtd_get_mac_binary art
0x6)
198 ln -sf /lib
/firmware
/ath10k
/pre-cal-pci-0000\
:00\
:00.0.bin \
199 /lib
/firmware
/ath10k
/QCA9888
/hw2.0
/board.bin
200 rm /lib
/firmware
/ath10k
/QCA9888
/hw2.0
/board-2.bin
206 ath10kcal_extract
"art" 0x5000 0x2f20
207 ath10kcal_patch_mac_crc $
(mtd_get_mac_ascii devdata wlan5mac
)
208 ln -sf /lib
/firmware
/ath10k
/pre-cal-pci-0000\
:00\
:00.0.bin \
209 /lib
/firmware
/ath10k
/QCA9888
/hw2.0
/board.bin
213 ath10kcal_extract
"caldata" 0x5000 0x2f20
214 ath10kcal_patch_mac $
(mtd_get_mac_binary caldata
0xc)
217 ath10kcal_extract
"art" 0x5000 0x2f20
218 ath10kcal_patch_mac_crc $
(k2t_get_mac
"5g_mac")
219 ln -sf /lib
/firmware
/ath10k
/pre-cal-pci-0000\
:00\
:00.0.bin \
220 /lib
/firmware
/ath10k
/QCA9888
/hw2.0
/board.bin
222 tplink
,archer-c58-v1|\
223 tplink
,archer-c59-v1|\
224 tplink
,archer-c59-v2|\
225 tplink
,archer-c60-v1|\
226 tplink
,archer-c60-v2|\
228 ath10kcal_extract
"art" 0x5000 0x2f20
229 ath10kcal_patch_mac_crc $
(macaddr_add $
(mtd_get_mac_binary mac
0x8) -1)
230 ln -sf /lib
/firmware
/ath10k
/pre-cal-pci-0000\
:00\
:00.0.bin \
231 /lib
/firmware
/ath10k
/QCA9888
/hw2.0
/board.bin