ar71xx: fix 5 GHz Wi-Fi on NBG6716
[openwrt/openwrt.git] / target / linux / ar71xx / base-files / etc / hotplug.d / firmware / 11-ath10k-caldata
index a3d4867b0b7f964320aa793c040e9eac6102bdb1..e6ea873e40b817473f3b321e1c638e9cc8235791 100644 (file)
@@ -18,12 +18,18 @@ ath10kcal_extract() {
        local part=$1
        local offset=$2
        local count=$3
-       local mtd
+       local mtd cal_size
 
        mtd=$(find_mtd_chardev $part)
        [ -n "$mtd" ] || \
                ath10kcal_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 skip=$(( $offset / 2 )) conv=swab 2>/dev/null | hexdump -ve '1/2 "%d"')
+
+       [ "$count" = "$cal_size" ] || \
+               ath10kcal_die "no calibration data found in $part"
+
        dd if=$mtd of=/lib/firmware/$FIRMWARE bs=1 skip=$offset count=$count 2>/dev/null || \
                ath10kcal_die "failed to extract calibration data from $mtd"
 }