mirror of
https://github.com/Ysurac/openmptcprouter.git
synced 2025-02-15 04:42:02 +00:00
71 lines
1.5 KiB
Bash
71 lines
1.5 KiB
Bash
#!/bin/sh
|
|
|
|
ath10kcal_die() {
|
|
echo "ath10cal: " "$*"
|
|
exit 1
|
|
}
|
|
|
|
ath10kcal_extract() {
|
|
local part=$1
|
|
local offset=$2
|
|
local count=$3
|
|
local mtd
|
|
|
|
mtd=$(find_mtd_chardev $part)
|
|
[ -n "$mtd" ] || \
|
|
ath10kcal_die "no mtd device found for partition $part"
|
|
|
|
dd if=$mtd of=/lib/firmware/$FIRMWARE iflag=skip_bytes bs=$count skip=$offset count=1 2>/dev/null || \
|
|
ath10kcal_die "failed to extract calibration data from $mtd"
|
|
}
|
|
|
|
ensure_correct_art() {
|
|
# NOTE(rytis): Hardcoded hashes for 64 KiB file, filled with zeroes (md5b0) and ones (md5b1).
|
|
local md5b0="fcd6bcb56c1689fcef28b57c22475bad"
|
|
local md5b1="ecb99e6ffea7be1e5419350f725da86b"
|
|
local artdir="/dev/mtd12"
|
|
local bindir="/usr/share/art/art_rutx.bin"
|
|
local md5art="$(md5sum $artdir)"
|
|
md5art="${md5art%% *}"
|
|
local devicename="$(mnf_info -n)"
|
|
devicename="${devicename:0:6}"
|
|
|
|
if [ "$devicename" != "RUTX08" ] && [ "$devicename" != "RUTX09" ]; then
|
|
if [ "$md5art" == "$md5b0" ] || [ "$md5art" == "$md5b1" ] && [ -e "$bindir" ]; then
|
|
mtd write $bindir $artdir
|
|
fi
|
|
else
|
|
if [ "$md5art" != "$md5b0" ] && [ "$md5art" != "$md5b1" ]; then
|
|
mtd erase $artdir
|
|
fi
|
|
fi
|
|
}
|
|
|
|
[ -e /lib/firmware/$FIRMWARE ] && exit 0
|
|
|
|
. /lib/functions.sh
|
|
. /lib/functions/system.sh
|
|
|
|
board=$(board_name)
|
|
|
|
ensure_correct_art
|
|
|
|
case "$FIRMWARE" in
|
|
"ath10k/pre-cal-ahb-a000000.wifi.bin")
|
|
case "$board" in
|
|
teltonika,rutx)
|
|
ath10kcal_extract "0:ART" 4096 12064
|
|
;;
|
|
esac
|
|
;;
|
|
"ath10k/pre-cal-ahb-a800000.wifi.bin")
|
|
case "$board" in
|
|
teltonika,rutx)
|
|
ath10kcal_extract "0:ART" 20480 12064
|
|
;;
|
|
esac
|
|
;;
|
|
*)
|
|
exit 1
|
|
;;
|
|
esac
|