[OpenWrt-Devel] OpenWrt: read label MAC address for FRITZ!WLAN Repeater 300E
diff mbox series

Message ID 000e01d59954$7241b8b0$56c52a10$@adrianschmutzler.de
State Not Applicable
Headers show
Series
  • [OpenWrt-Devel] OpenWrt: read label MAC address for FRITZ!WLAN Repeater 300E
Related show

Commit Message

Adrian Schmutzler Nov. 12, 2019, 12:26 p.m. UTC
Hi,

I'm currently trying to remove the dependency of label_mac in 02_network from phy setup, i.e. replacing stuff like
$(cat /sys/class/ieee80211/phyX/macaddress)
with extraction from the proper flash location.

One obstacle is the AVM FRITZ!WLAN Repeater 300E, where the calibration data is extracted with
caldata_extract_reverse "urloader" 0x1541 0x440

Is there a sufficiently easy way to get the MAC address out of there _without_ relying on initialized Wifi?
I'm looking for something like
label_mac=$(some_extraction_function "urloader" <some_offset>)
Technically, it should be somewhere in the reversed caldata, shouldn't it?

If this is not possible (with reasonable effort), I would just calculate it based on the lan_mac in 02_network.

Best

Adrian

-----Original Message-----
From: openwrt-devel [mailto:openwrt-devel-bounces@lists.openwrt.org] On Behalf Of Adrian Schmutzler
Sent: Montag, 11. November 2019 00:32
To: openwrt-devel@lists.openwrt.org
Subject: [OpenWrt-Devel] [PATCH 2/2] ath79: read label MAC address from flash instead of using phy0/phy1

This replaces all uses of $(cat /sys/class/ieee80211/phyX/macaddress)
by retrieval from the proper flash locations. This will make
02_network independent of WiFi setup again.

For the AVM FRITZ!WLAN Repeater 300E this replacement is non-trivial.
As it would be the only device in the whole trunk to keep the old
mechanism, this drops label MAC address for this device for now.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>

---

Is there an easy way to retrieve phy0 MAC address from fritz-300e?
Can it by deduced from the caldata extraction by assuming the
standard MAC offset after reverse?
---
 target/linux/ath79/generic/base-files/etc/board.d/02_network | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

 		lan_mac=$(fritz_tffs -n maca -i $(find_mtd_part "tffs
(1)"))

Comments

Mathias Kresin Nov. 13, 2019, 6:22 a.m. UTC | #1
12/11/2019 13:26, Adrian Schmutzler:
> Hi,
> 
> I'm currently trying to remove the dependency of label_mac in 02_network from phy setup, i.e. replacing stuff like
> $(cat /sys/class/ieee80211/phyX/macaddress)
> with extraction from the proper flash location.
> 
> One obstacle is the AVM FRITZ!WLAN Repeater 300E, where the calibration data is extracted with
> caldata_extract_reverse "urloader" 0x1541 0x440
> 
> Is there a sufficiently easy way to get the MAC address out of there _without_ relying on initialized Wifi?
> I'm looking for something like
> label_mac=$(some_extraction_function "urloader" <some_offset>)
> Technically, it should be somewhere in the reversed caldata, shouldn't it?
> 
> If this is not possible (with reasonable effort), I would just calculate it based on the lan_mac in 02_network.
> 
> Best
> 
> Adrian

Hey Adrian,

all mac-addresses can be found in the urlader key value store.

maca                  24:65:11:AE:CB:6B
macb                  24:65:11:AE:CB:6C
macwlan               24:65:11:AE:CB:6D
macdsl                24:65:11:AE:CB:6E

Following the fritz_tffs call in 02_network it will be:

lan=$(fritz_tffs -n maca -i $(find_mtd_part "tffs (1)"))
wlan=$(fritz_tffs -n macwlan -i $(find_mtd_part "tffs (1)"))

FYI, the label mac is macwlan.

Does that answer your question?

Mathias
Adrian Schmutzler Nov. 13, 2019, 12:14 p.m. UTC | #2
> Hey Adrian,
> 
> all mac-addresses can be found in the urlader key value store.
> 
> maca                  24:65:11:AE:CB:6B
> macb                  24:65:11:AE:CB:6C
> macwlan               24:65:11:AE:CB:6D
> macdsl                24:65:11:AE:CB:6E
> 
> Following the fritz_tffs call in 02_network it will be:
> 
> lan=$(fritz_tffs -n maca -i $(find_mtd_part "tffs (1)"))
> wlan=$(fritz_tffs -n macwlan -i $(find_mtd_part "tffs (1)"))
> 
> FYI, the label mac is macwlan.
> 
> Does that answer your question?

Thanks, that's exactly what I needed (and easier than I thought).

Already applied it in https://github.com/openwrt/openwrt/commit/d421a8b9448968de0e3265f5beb469c210a909ab

Adrian

Patch
diff mbox series

diff --git a/target/linux/ath79/generic/base-files/etc/board.d/02_network
b/target/linux/ath79/generic/base-files/etc/board.d/02_network
index 34f6e31047..a8ab07aef5 100755
--- a/target/linux/ath79/generic/base-files/etc/board.d/02_network
+++ b/target/linux/ath79/generic/base-files/etc/board.d/02_network
@@ -292,11 +292,10 @@  ath79_setup_macs()
 	ubnt,nanostation-m|\
 	ubnt,rocket-m|\
 	ubnt,unifi)
-		label_mac=$(cat /sys/class/ieee80211/phy0/macaddress)
+		label_mac=$(mtd_get_mac_binary art 0x1002)
 		;;
 	avm,fritz300e)
 		lan_mac=$(fritz_tffs -n maca -i $(find_mtd_part "tffs
(1)"))
-		label_mac=$(cat /sys/class/ieee80211/phy0/macaddress)
 		;;
 	avm,fritz4020)