4 .
/lib
/functions
/k2t.sh
11 ath10kcal_from_file
() {
16 dd if=$source of
=/lib
/firmware
/$FIRMWARE iflag
=skip_bytes bs
=$count skip
=$offset count
=1 2>/dev
/null || \
17 ath10kcal_die
"failed to extract calibration data from $source"
26 mtd
=$
(find_mtd_chardev
$part)
28 ath10kcal_die
"no mtd device found for partition $part"
30 dd if=$mtd of
=/lib
/firmware
/$FIRMWARE iflag
=skip_bytes bs
=$count skip
=$offset count
=1 2>/dev
/null || \
31 ath10kcal_die
"failed to extract calibration data from $mtd"
34 ath10kcal_patch_mac
() {
37 [ -z "$mac" ] && return
39 macaddr_2bin
$mac |
dd of
=/lib
/firmware
/$FIRMWARE conv
=notrunc oflag
=seek_bytes bs
=6 seek
=6 count
=1
42 ath10kcal_patch_mac_crc
() {
50 xor_fw_mac
=$
(hexdump -v -n 6 -s $mac_offset -e '/1 "%02x"' /lib
/firmware
/$FIRMWARE)
51 xor_fw_mac
="${xor_fw_mac:0:4} ${xor_fw_mac:4:4} ${xor_fw_mac:8:4}"
53 ath10kcal_patch_mac
"$mac" && {
55 xor_mac
="${xor_mac:0:4} ${xor_mac:4:4} ${xor_mac:8:4}"
57 xor_fw_chksum
=$
(hexdump -v -n 2 -s $chksum_offset -e '/1 "%02x"' /lib
/firmware
/$FIRMWARE)
58 xor_fw_chksum
=$
(xor
$xor_fw_chksum $xor_fw_mac $xor_mac)
60 printf "%b" "\x${xor_fw_chksum:0:2}\x${xor_fw_chksum:2:2}" | \
61 dd of
=/lib
/firmware
/$FIRMWARE conv
=notrunc bs
=1 seek
=$chksum_offset count
=2
65 [ -e /lib
/firmware
/$FIRMWARE ] && exit 0
67 .
/lib
/functions
/system.sh
72 "ath10k/cal-pci-0000:00:00.0.bin")
74 comfast
,cf-wr650ac-v1|\
75 comfast
,cf-wr650ac-v2|\
77 ath10kcal_extract
"art" 0x5000 0x844
85 ath10kcal_extract
"art" 0x5000 0x844
86 ath10kcal_patch_mac_crc $
(macaddr_add $
(mtd_get_mac_binary art
0x0) -1)
89 ath10kcal_extract
"art" 0x5000 0x844
90 ath10kcal_patch_mac $
(mtd_get_mac_ascii devdata
"wlan5mac")
92 elecom
,wrc-1750ghbk2-i
)
93 ath10kcal_extract
"art" 0x5000 0x844
96 ath10kcal_extract
"art" 0x5000 0x844
97 ath10kcal_patch_mac $
(mtd_get_mac_ascii u-boot-env athaddr
)
100 iodata
,wn-ac1167dgr|\
101 iodata
,wn-ac1600dgr2
)
102 ath10kcal_extract
"art" 0x5000 0x844
103 ath10kcal_patch_mac $
(macaddr_add $
(mtd_get_mac_ascii u-boot-env ethaddr
) +1)
106 ath10kcal_extract
"art" 0x5000 0x844
107 ath10kcal_patch_mac $
(macaddr_add $
(cat /sys
/class
/net
/eth
0/address
) +1)
111 ath10kcal_extract
"art" 0x5000 0x844
112 ath10kcal_patch_mac $
(macaddr_add $
(mtd_get_mac_binary art
0x0) +1)
115 ath10kcal_extract
"art" 0x5000 0x844
116 ath10kcal_patch_mac $
(macaddr_add $
(mtd_get_mac_binary art
0x0) +2)
119 ath10kcal_extract
"art" 0x5000 0x844
120 ath10kcal_patch_mac_crc $
(mtd_get_mac_text board_data
0x880)
124 ath10kcal_extract
"art" 0x5000 0x844
125 ath10kcal_patch_mac $
(mtd_get_mac_binary art
0xc)
128 ath10kcal_extract
"art" 0x5000 0x844
129 ath10kcal_patch_mac $
(macaddr_add $
(cat /sys
/class
/net
/eth
0/address
) +16)
132 ath10kcal_extract
"radiocfg" 0x5000 0x844
133 ath10kcal_patch_mac_crc $
(mtd_get_mac_ascii devdata wlan5mac
)
135 tplink
,archer-a7-v5|\
136 tplink
,archer-c2-v3|\
137 tplink
,archer-c7-v4|\
138 tplink
,archer-c7-v5|\
139 tplink
,archer-c25-v1
)
140 ath10kcal_extract
"art" 0x5000 0x844
141 ath10kcal_patch_mac $
(macaddr_add $
(mtd_get_mac_binary info
0x8) -1)
143 tplink
,archer-c5-v1|\
145 ath10kcal_extract
"art" 0x5000 0x844
146 ath10kcal_patch_mac $
(macaddr_add $
(mtd_get_mac_binary u-boot
0x1fc00) -1)
148 tplink
,archer-d50-v1
)
149 ath10kcal_extract
"art" 0x5000 0x844
150 ath10kcal_patch_mac $
(macaddr_add $
(mtd_get_mac_binary romfile
0xf100) +2)
153 ath10kcal_extract
"art" 0x5000 0x844
154 ath10kcal_patch_mac $
(macaddr_add $
(mtd_get_mac_binary config
0x10008) +2)
158 ath10kcal_extract
"art" 0x5000 0x844
159 ath10kcal_patch_mac $
(macaddr_add $
(cat /sys
/class
/net
/eth
0/address
) -2)
162 ath10kcal_extract
"art" 0x5000 0x844
163 ath10kcal_patch_mac $
(macaddr_add $
(mtd_get_mac_binary info
0x8) +1)
167 ubnt
,unifiac-mesh-pro|\
170 ubnt
,nanostation-ac|\
171 ubnt
,nanostation-ac-loco|\
173 ath10kcal_extract
"EEPROM" 0x5000 0x844
177 "ath10k/pre-cal-pci-0000:00:00.0.bin")
180 ath10kcal_extract
"art" 0x5000 0x2f20
181 ath10kcal_patch_mac_crc $
(mtd_get_mac_binary art
0x6)
182 ln -sf /lib
/firmware
/ath10k
/pre-cal-pci-0000\
:00\
:00.0.bin \
183 /lib
/firmware
/ath10k
/QCA9888
/hw2.0
/board.bin
184 rm /lib
/firmware
/ath10k
/QCA9888
/hw2.0
/board-2.bin
190 ath10kcal_extract
"art" 0x5000 0x2f20
191 ath10kcal_patch_mac_crc $
(mtd_get_mac_ascii devdata wlan5mac
)
192 ln -sf /lib
/firmware
/ath10k
/pre-cal-pci-0000\
:00\
:00.0.bin \
193 /lib
/firmware
/ath10k
/QCA9888
/hw2.0
/board.bin
197 ath10kcal_extract
"caldata" 0x5000 0x2f20
198 ath10kcal_patch_mac $
(mtd_get_mac_binary caldata
0xc)
201 ath10kcal_extract
"art" 0x5000 0x2f20
202 ath10kcal_patch_mac_crc $
(k2t_get_mac
"5g_mac")
203 ln -sf /lib
/firmware
/ath10k
/pre-cal-pci-0000\
:00\
:00.0.bin \
204 /lib
/firmware
/ath10k
/QCA9888
/hw2.0
/board.bin
206 tplink
,archer-c58-v1|\
207 tplink
,archer-c59-v1|\
208 tplink
,archer-c59-v2|\
209 tplink
,archer-c60-v1|\
210 tplink
,archer-c60-v2|\
212 ath10kcal_extract
"art" 0x5000 0x2f20
213 ath10kcal_patch_mac_crc $
(macaddr_add $
(mtd_get_mac_binary mac
0x8) -1)
214 ln -sf /lib
/firmware
/ath10k
/pre-cal-pci-0000\
:00\
:00.0.bin \
215 /lib
/firmware
/ath10k
/QCA9888
/hw2.0
/board.bin