[OpenWrt-Devel] [PATCH 1/2] ramips: read label MAC address from flash instead of using phy0/phy1

Adrian Schmutzler freifunk at adrianschmutzler.de
Sun Nov 10 18:32:16 EST 2019


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.

Signed-off-by: Adrian Schmutzler <freifunk at adrianschmutzler.de>
---
 .../linux/ramips/mt7620/base-files/etc/board.d/02_network | 6 +++---
 .../linux/ramips/mt7621/base-files/etc/board.d/02_network | 8 ++++----
 .../linux/ramips/mt76x8/base-files/etc/board.d/02_network | 4 ++--
 .../linux/ramips/rt305x/base-files/etc/board.d/02_network | 7 +++++--
 4 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/target/linux/ramips/mt7620/base-files/etc/board.d/02_network b/target/linux/ramips/mt7620/base-files/etc/board.d/02_network
index dfca48e123..1b51f17485 100755
--- a/target/linux/ramips/mt7620/base-files/etc/board.d/02_network
+++ b/target/linux/ramips/mt7620/base-files/etc/board.d/02_network
@@ -288,7 +288,7 @@ ramips_setup_macs()
 	glinet,gl-mt300n|\
 	glinet,gl-mt750)
 		wan_mac=$(macaddr_add "$(cat /sys/class/net/eth0/address)" 1)
-		label_mac=$(cat /sys/class/ieee80211/phy0/macaddress)
+		label_mac=$(mtd_get_mac_binary factory 0x4)
 		;;
 	hiwifi,hc5661|\
 	hiwifi,hc5761|\
@@ -312,11 +312,11 @@ ramips_setup_macs()
 		wan_mac=$(mtd_get_mac_ascii config WAN_MAC_ADDR)
 		;;
 	zbtlink,zbt-we1026-5g-16m)
-		label_mac=$(cat /sys/class/ieee80211/phy1/macaddress)
+		label_mac=$(mtd_get_mac_binary factory 0x4)
 		;;
 	zbtlink,zbt-we1026-h-32m)
 		wan_mac=$(mtd_get_mac_binary factory 0x2e)
-		label_mac=$(cat /sys/class/ieee80211/phy0/macaddress)
+		label_mac=$(mtd_get_mac_binary factory 0x4)
 		;;
 	zyxel,keenetic-omni|\
 	zyxel,keenetic-omni-ii|\
diff --git a/target/linux/ramips/mt7621/base-files/etc/board.d/02_network b/target/linux/ramips/mt7621/base-files/etc/board.d/02_network
index ae03dc71b1..0de3804cdb 100755
--- a/target/linux/ramips/mt7621/base-files/etc/board.d/02_network
+++ b/target/linux/ramips/mt7621/base-files/etc/board.d/02_network
@@ -188,7 +188,7 @@ ramips_setup_macs()
 	asus,rt-ac65p|\
 	asus,rt-ac85p)
 		wan_mac=$(mtd_get_mac_ascii u-boot-env et1macaddr)
-		label_mac=$(cat /sys/class/ieee80211/phy0/macaddress)
+		label_mac=$(mtd_get_mac_binary factory 0x4)
 		;;
 	buffalo,wsr-1166dhp)
 		local index="$(find_mtd_index "board_data")"
@@ -198,7 +198,7 @@ ramips_setup_macs()
 	dlink,dir-860l-b1)
 		lan_mac=$(mtd_get_mac_ascii factory lanmac)
 		wan_mac=$(mtd_get_mac_ascii factory wanmac)
-		label_mac=$(cat /sys/class/ieee80211/phy1/macaddress)
+		label_mac=$(mtd_get_mac_binary radio 0x4)
 		;;
 	edimax,rg21s)
 		lan_mac=$(mtd_get_mac_ascii u-boot-env ethaddr)
@@ -241,12 +241,12 @@ ramips_setup_macs()
 		;;
 	zbtlink,zbt-we1326)
 		wan_mac=$(mtd_get_mac_binary factory 0xe006)
-		label_mac=$(cat /sys/class/ieee80211/phy0/macaddress)
+		label_mac=$(mtd_get_mac_binary factory 0x4)
 		;;
 	zbtlink,zbt-wg3526-16m|\
 	zbtlink,zbt-wg3526-32m)
 		wan_mac=$(macaddr_add "$(cat /sys/class/net/eth0/address)" 1)
-		label_mac=$(cat /sys/class/ieee80211/phy0/macaddress)
+		label_mac=$(mtd_get_mac_binary factory 0x4)
 		;;
 	esac
 
diff --git a/target/linux/ramips/mt76x8/base-files/etc/board.d/02_network b/target/linux/ramips/mt76x8/base-files/etc/board.d/02_network
index 63861c2089..87ce447612 100755
--- a/target/linux/ramips/mt76x8/base-files/etc/board.d/02_network
+++ b/target/linux/ramips/mt76x8/base-files/etc/board.d/02_network
@@ -134,7 +134,7 @@ ramips_setup_macs()
 		;;
 	cudy,wr1000)
 		wan_mac=$(mtd_get_mac_binary factory 0x2e)
-		label_mac=$(cat /sys/class/ieee80211/phy0/macaddress)
+		label_mac=$(mtd_get_mac_binary factory 0x8)
 		;;
 	duzun,dm06|\
 	mediatek,mt7628an-eval-board|\
@@ -192,7 +192,7 @@ ramips_setup_macs()
 		;;
 	vocore,vocore2|\
 	vocore,vocore2-lite)
-		label_mac=$(cat /sys/class/ieee80211/phy0/macaddress)
+		label_mac=$(mtd_get_mac_binary factory 0x8)
 		;;
 	esac
 
diff --git a/target/linux/ramips/rt305x/base-files/etc/board.d/02_network b/target/linux/ramips/rt305x/base-files/etc/board.d/02_network
index 5c110b375e..de71dd6202 100755
--- a/target/linux/ramips/rt305x/base-files/etc/board.d/02_network
+++ b/target/linux/ramips/rt305x/base-files/etc/board.d/02_network
@@ -242,10 +242,13 @@ ramips_setup_macs()
 		lan_mac=$(macaddr_setbit_la "$(cat /sys/class/net/eth0/address)")
 		wan_mac=$(macaddr_add "$lan_mac" 1)
 		;;
-	dlink,dir-615-d|\
+	dlink,dir-615-d)
+		wan_mac=$(macaddr_add "$(cat /sys/class/net/eth0/address)" 1)
+		label_mac=$(mtd_get_mac_binary devdata 0x4004)
+		;;
 	dlink,dir-615-h1)
 		wan_mac=$(macaddr_add "$(cat /sys/class/net/eth0/address)" 1)
-		label_mac=$(cat /sys/class/ieee80211/phy0/macaddress)
+		label_mac=$(mtd_get_mac_binary factory 0x4)
 		;;
 	poray,m3|\
 	poray,m4-4m|\
-- 
2.20.1


_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list