[OpenWrt-Devel] [PATCH v8 2/3] ar71xx: scan nand ubi partition for ath9k eeprom files

Christian Lamparter chunkeey at googlemail.com
Thu Dec 17 13:22:06 EST 2015


From: Chris R Blake <chrisrblake93 at gmail.com>

The MR18 stores the ath9k eeprom values on the NAND.
This patch makes it possible to retrieve the images
from there.

Signed-off-by: Chris R Blake <chrisrblake93 at gmail.com>
---
 package/base-files/files/lib/functions/system.sh        | 17 +++++++++++++++++
 .../base-files/etc/hotplug.d/firmware/10-ath9k-eeprom   | 17 +++++++++++++++++
 2 files changed, 34 insertions(+)

diff --git a/package/base-files/files/lib/functions/system.sh b/package/base-files/files/lib/functions/system.sh
index 8d75a5a..03d7127 100644
--- a/package/base-files/files/lib/functions/system.sh
+++ b/package/base-files/files/lib/functions/system.sh
@@ -41,6 +41,23 @@ mtd_get_mac_binary() {
 	dd bs=1 skip=$offset count=6 if=$part 2>/dev/null | hexdump -v -n 6 -e '5/1 "%02x:" 1/1 "%02x"'
 }
 
+mtd_get_mac_binary_ubi() {
+	local mtdname="$1"
+	local offset="$2"
+
+	. /lib/upgrade/nand.sh
+
+	local ubidev=$(nand_find_ubi $CI_UBIPART)
+	local part=$(nand_find_volume $ubidev $1)
+
+	if [ -z "$part" ]; then
+		echo "mtd_get_mac_binary: ubi volume $mtdname not found!" >&2
+		return
+	fi
+
+	hexdump -v -n 6 -s $offset -e '5/1 "%02x:" 1/1 "%02x"' /dev/$part 2>/dev/null
+}
+
 mtd_get_part_size() {
 	local part_name=$1
 	local first dev size erasesize name
diff --git a/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom b/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom
index 33b1d74..d3f0915 100644
--- a/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom
+++ b/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom
@@ -25,6 +25,23 @@ ath9k_eeprom_extract() {
 		ath9k_eeprom_die "failed to extract from $mtd"
 }
 
+ath9k_ubi_eeprom_extract() {
+	local part=$1
+	local offset=$2
+	local count=$3
+	local ubidev=$(nand_find_ubi $CI_UBIPART)
+	local ubi
+
+	. /lib/upgrade/nand.sh
+
+	ubi=$(nand_find_volume $ubidev $part)
+	[ -n "$ubi" ] || \
+		ath9k_eeprom_die "no UBI volume found for $part"
+
+	dd if=/dev/$ubi of=/lib/firmware/$FIRMWARE bs=1 skip=$offset count=$count 2>/dev/null || \
+		ath9k_eeprom_die "failed to extract from $ubi"
+}
+
 ath9k_patch_firmware_mac() {
 	local mac=$1
 
-- 
2.6.4
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list