[OpenWrt-Devel] [PATCH v2 14/14] ramips/mt7621: mikrotik: don't use mtd-mac-address in DTS

Thibaut VARÈNE hacks at slashdirt.org
Mon Apr 20 09:35:03 EDT 2020


As evidenced here[1] the device MAC address can be stored at a random
offset in the hard_config partition. Rely on sysfs to update the MAC
address correctly.

[1] https://github.com/openwrt/openwrt/pull/2850#issuecomment-610809021

Signed-off-by: Thibaut VARÈNE <hacks at slashdirt.org>
---
 target/linux/ramips/dts/mt7621_mikrotik_routerboard-750gr3.dts | 7 -------
 target/linux/ramips/dts/mt7621_mikrotik_routerboard-m11g.dts   | 5 -----
 target/linux/ramips/dts/mt7621_mikrotik_routerboard-m33g.dts   | 7 -------
 target/linux/ramips/mt7621/base-files/etc/board.d/02_network   | 4 +++-
 4 files changed, 3 insertions(+), 20 deletions(-)

diff --git a/target/linux/ramips/dts/mt7621_mikrotik_routerboard-750gr3.dts b/target/linux/ramips/dts/mt7621_mikrotik_routerboard-750gr3.dts
index 3f37155f24..755c5ec932 100644
--- a/target/linux/ramips/dts/mt7621_mikrotik_routerboard-750gr3.dts
+++ b/target/linux/ramips/dts/mt7621_mikrotik_routerboard-750gr3.dts
@@ -129,18 +129,11 @@
 	};
 };
 
-&gmac0 {
-	mtd-mac-address = <&hard_config 0x0010>;
-	mtd-mac-address-increment = <1>;
-};
-
 &switch0 {
 	ports {
 		port at 0 {
 			status = "okay";
 			label = "wan";
-			mtd-mac-address = <&hard_config 0x0010>;
-			mtd-mac-address-increment = <2>;
 		};
 
 		port at 1 {
diff --git a/target/linux/ramips/dts/mt7621_mikrotik_routerboard-m11g.dts b/target/linux/ramips/dts/mt7621_mikrotik_routerboard-m11g.dts
index bd58aea951..37a1312f52 100644
--- a/target/linux/ramips/dts/mt7621_mikrotik_routerboard-m11g.dts
+++ b/target/linux/ramips/dts/mt7621_mikrotik_routerboard-m11g.dts
@@ -138,11 +138,6 @@
 	};
 };
 
-&gmac0 {
-	mtd-mac-address = <&hard_config 0x0010>;
-	mtd-mac-address-increment = <1>;
-};
-
 &switch0 {
 	ports {
 		port at 0 {
diff --git a/target/linux/ramips/dts/mt7621_mikrotik_routerboard-m33g.dts b/target/linux/ramips/dts/mt7621_mikrotik_routerboard-m33g.dts
index 19e1a71e99..03bc489380 100644
--- a/target/linux/ramips/dts/mt7621_mikrotik_routerboard-m33g.dts
+++ b/target/linux/ramips/dts/mt7621_mikrotik_routerboard-m33g.dts
@@ -162,18 +162,11 @@
 	};
 };
 
-&gmac0 {
-	mtd-mac-address = <&hard_config 0x0010>;
-	mtd-mac-address-increment = <1>;
-};
-
 &switch0 {
 	ports {
 		port at 0 {
 			status = "okay";
 			label = "wan";
-			mtd-mac-address = <&hard_config 0x0010>;
-			mtd-mac-address-increment = <2>;
 		};
 
 		port at 1 {
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 252f9f1dda..91ced8ede7 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
@@ -92,7 +92,9 @@ ramips_setup_macs()
 	mikrotik,routerboard-750gr3|\
 	mikrotik,routerboard-m11g|\
 	mikrotik,routerboard-m33g)
-		label_mac=$(mtd_get_mac_binary hard_config 0x10)
+		label_mac=$(cat "/sys/firmware/mikrotik/hard_config/mac_base")
+		lan_mac=$(macaddr_add $label_mac 1)
+		wan_mac=$(macaddr_add $label_mac 2)
 		;;
 	zbtlink,zbt-we1326|\
 	zbtlink,zbt-wg3526-16m|\
-- 
2.11.0


_______________________________________________
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