@@ -4,6 +4,24 @@
. /lib/functions/caldata.sh
+caldata_extract_if_present() {
+ local part=$1
+ local offset=$(($2))
+ local count=$(($3))
+ local mtd
+
+ mtd=$(find_mtd_chardev $part)
+ [ -n "$mtd" ] || caldata_die "no mtd device found for partition $part"
+
+ # Check that the calibration data size in header equals the desired size
+ cal_size=$(dd if=$mtd bs=2 count=1 iflag=skip_bytes skip=$offset conv=swab 2>/dev/null | hexdump -ve '1/2 "%d"')
+
+ [ "$count" = "$cal_size" ] || caldata_die "no calibration data found in $part"
+
+ dd if=$mtd of=/lib/firmware/$FIRMWARE iflag=skip_bytes bs=$count skip=$offset count=1 2>/dev/null || \
+ caldata_die "failed to extract calibration data from $mtd"
+}
+
board=$(board_name)
case "$FIRMWARE" in
@@ -19,7 +37,7 @@ case "$FIRMWARE" in
ath10k_patch_mac $(macaddr_add $(mtd_get_mac_binary art 0x0) +1)
;;
zyxel,nbg6716)
- caldata_extract "art" 0x5000 0x844
+ caldata_extract_if_present "art" 0x5000 0x844
ath10k_patch_mac $(macaddr_add $(mtd_get_mac_ascii u-boot-env ethaddr) +1)
;;
esac
This reimplements a fix for the Zyxel NBG6716 from ar71xx: Some NBG6716 do not have ath10k calibration data in flash, only in chip OTP. To determine if flash has a valid calibration data, the first two bytes telling the length of the calibration data are checked against the requested length. If the lengths match, calibration data is valid and read from flash. Based on: 2ea98fc39b21 ("ar71xx: fix 5 GHz Wi-Fi on NBG6716") Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de> --- This is just a copy-paste job, since I found the relevant patch during looking up stuff for the NBG6716. I don't think that's a particularly nice solution and would be happy if there are better ideas. (We are actually comparing strings of sizes here ...) If there is a nice solution though, one should consider adding that one to generic caldata_extract at some point. This will break extractions with wrong size set; however, if we can and will extract size this way, the size parameter in the function call would be actually obselete. I'd be interested in general feedback on this subject. --- .../etc/hotplug.d/firmware/11-ath10k-caldata | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-)