summaryrefslogtreecommitdiffstats
path: root/target/linux/ath79/base-files
diff options
context:
space:
mode:
authorAdrian Schmutzler <freifunk@adrianschmutzler.de>2020-02-17 20:16:17 +0100
committerAdrian Schmutzler <freifunk@adrianschmutzler.de>2020-02-17 20:23:59 +0100
commitdc145de4be7b737bd7e37f4a79fc6e36833691b9 (patch)
treea22350ff7fbc8b94a3607a0daa80d22768b7b9f0 /target/linux/ath79/base-files
parentd2b8ccb1c04def81224da6f42f644c7d239b9986 (diff)
downloadopenwrt-dc145de4be7b737bd7e37f4a79fc6e36833691b9.tar.gz
openwrt-dc145de4be7b737bd7e37f4a79fc6e36833691b9.tar.bz2
openwrt-dc145de4be7b737bd7e37f4a79fc6e36833691b9.zip
ath79: move mikrotik-caldata.sh to target base-files
Mikrotik devices will be found in both generic and nand subtargets. The file mikrotik-caldata.sh, currently used in generic, contains a few lines of code that would need to be duplicated for nand support. Instead of duplicating it, move it to target base-files, as size impact is small and the maintenance gain should outweigh it. This is changed separately to make life easier for the people currently working on Mikrotik NAND support. Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
Diffstat (limited to 'target/linux/ath79/base-files')
-rw-r--r--target/linux/ath79/base-files/lib/functions/mikrotik-caldata.sh21
1 files changed, 21 insertions, 0 deletions
diff --git a/target/linux/ath79/base-files/lib/functions/mikrotik-caldata.sh b/target/linux/ath79/base-files/lib/functions/mikrotik-caldata.sh
new file mode 100644
index 0000000000..9c4016ee5d
--- /dev/null
+++ b/target/linux/ath79/base-files/lib/functions/mikrotik-caldata.sh
@@ -0,0 +1,21 @@
+# Copyright (C) 2019 Robert Marko <robimarko@gmail.com>
+# Copyright (C) 2019 Roger Pueyo Centelles <roger.pueyo@guifi.net>
+#
+# Helper function to extract MAC addresses and calibration data for MikroTik
+#
+
+mikrotik_caldata_extract() {
+ local part=$1
+ local offset=$(($2))
+ local count=$(($3))
+ local mtd
+ local erdfile="/lib/firmware/erd.bin"
+
+ mtd=$(find_mtd_chardev $part)
+ [ -n "$mtd" ] || caldata_die "no mtd device found for partition $part"
+
+ rbextract -e $mtd $erdfile
+
+ dd if=$erdfile 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"
+}