3 # xor multiple hex values of the same length
16 printf "%0${retlen}x" "$ret"
20 echo "ath10cal: " "$*"
30 mtd
=$
(find_mtd_chardev
$part)
32 ath10kcal_die
"no mtd device found for partition $part"
34 dd if=$mtd of
=/lib
/firmware
/$FIRMWARE iflag
=skip_bytes bs
=$count skip
=$offset count
=1 2>/dev
/null || \
35 ath10kcal_die
"failed to extract calibration data from $mtd"
38 ath10kcal_ubi_extract
() {
45 .
/lib
/upgrade
/nand.sh
47 ubidev
=$
(nand_find_ubi
$CI_UBIPART)
48 ubi
=$
(nand_find_volume
$ubidev $part)
50 ath10kcal_die
"no UBI volume found for $part"
52 dd if=/dev
/$ubi of
=/lib
/firmware
/$FIRMWARE iflag
=skip_bytes bs
=$count skip
=$offset count
=1 2>/dev
/null || \
53 ath10kcal_die
"failed to extract from $ubi"
56 ath10kcal_patch_mac_crc
() {
64 [ -z "$mac" ] && return
66 xor_fw_mac
=$
(hexdump -v -n 6 -s $mac_offset -e '/1 "%02x"' /lib
/firmware
/$FIRMWARE)
67 xor_fw_mac
="${xor_fw_mac:0:4} ${xor_fw_mac:4:4} ${xor_fw_mac:8:4}"
69 macaddr_2bin
$mac |
dd of
=/lib
/firmware
/$FIRMWARE conv
=notrunc bs
=1 seek
=6 count
=6
72 xor_mac
="${xor_mac:0:4} ${xor_mac:4:4} ${xor_mac:8:4}"
74 xor_fw_chksum
=$
(hexdump -v -n 2 -s $chksum_offset -e '/1 "%02x"' /lib
/firmware
/$FIRMWARE)
75 xor_fw_chksum
=$
(xor
$xor_fw_chksum $xor_fw_mac $xor_mac)
77 printf "%b" "\x${xor_fw_chksum:0:2}\x${xor_fw_chksum:2:2}" | \
78 dd of
=/lib
/firmware
/$FIRMWARE conv
=notrunc bs
=1 seek
=$chksum_offset count
=2
81 ath10kcal_is_caldata_valid
() {
84 magic
=$
(hexdump -v -n 2 -e '1/1 "%02x"' /lib
/firmware
/$FIRMWARE)
85 [[ "$magic" == "$expected" ]]
89 [ -e /lib
/firmware
/$FIRMWARE ] && exit 0
92 .
/lib
/functions
/system.sh
98 "ath10k/cal-pci-0000:01:00.0.bin")
101 ath10kcal_ubi_extract
"ART" 36864 2116
102 ath10kcal_is_caldata_valid
"4408" || ath10kcal_extract
"ART" 36864 2116
103 ath10kcal_patch_mac_crc $
(macaddr_add $
(get_mac_binary
"/sys/bus/i2c/devices/0-0050/eeprom" 102) +1)
107 "ath10k/pre-cal-pci-0000:01:00.0.bin")
110 ath10kcal_ubi_extract
"Factory" 36864 12064
111 ln -sf /lib
/firmware
/ath10k
/pre-cal-pci-0000\
:00\
:00.0.bin \
112 /lib
/firmware
/ath10k
/QCA9888
/hw2.0
/board.bin
115 ath10kcal_extract
"0:ART" 36864 12064
119 "ath10k/pre-cal-ahb-a000000.wifi.bin")
122 alfa-network
,ap120c-ac |\
126 ath10kcal_extract
"ART" 4096 12064
129 ath10kcal_ubi_extract
"Factory" 4096 12064
133 ath10kcal_ubi_extract
"Factory" 4096 12064
136 /usr
/bin
/fritz_cal_extract
-i 1 -s 0x400 -e 0x207 -l 12064 -o /lib
/firmware
/$FIRMWARE $
(find_mtd_chardev
"urlader_config")
139 ath10kcal_ubi_extract
"ART" 4096 12064
140 ath10kcal_is_caldata_valid
"202f" || ath10kcal_extract
"ART" 4096 12064
141 ath10kcal_patch_mac_crc $
(macaddr_add $
(get_mac_binary
"/sys/bus/i2c/devices/0-0050/eeprom" 102) +2)
145 ath10kcal_extract
"ART" 4096 12064
146 ath10kcal_patch_mac_crc $
(mtd_get_mac_binary dnidata
0)
152 ath10kcal_extract
"0:ART" 4096 12064
156 ath10kcal_extract
"ART" 4096 12064
157 ath10kcal_patch_mac_crc $
(macaddr_add $
(cat /sys
/class
/net
/eth
0/address
) -2)
161 "ath10k/pre-cal-ahb-a800000.wifi.bin")
164 alfa-network
,ap120c-ac |\
168 ath10kcal_extract
"ART" 20480 12064
171 ath10kcal_ubi_extract
"Factory" 20480 12064
175 ath10kcal_ubi_extract
"Factory" 20480 12064
178 /usr
/bin
/fritz_cal_extract
-i 1 -s 0x400 -e 0x208 -l 12064 -o /lib
/firmware
/$FIRMWARE $
(find_mtd_chardev
"urlader_config")
181 ath10kcal_ubi_extract
"ART" 20480 12064
182 ath10kcal_is_caldata_valid
"202f" || ath10kcal_extract
"ART" 20480 12064
183 ath10kcal_patch_mac_crc $
(macaddr_add $
(get_mac_binary
"/sys/bus/i2c/devices/0-0050/eeprom" 102) +3)
187 ath10kcal_extract
"ART" 20480 12064
188 ath10kcal_patch_mac_crc $
(mtd_get_mac_binary dnidata
12)
194 ath10kcal_extract
"0:ART" 20480 12064
198 ath10kcal_extract
"ART" 20480 12064
199 ath10kcal_patch_mac_crc $
(macaddr_add $
(cat /sys
/class
/net
/eth
0/address
) -1)