ramips/mt7621: mikrotik: don't use mtd-mac-address in DTS
authorThibaut VARÈNE <hacks@slashdirt.org>
Mon, 20 Apr 2020 12:35:57 +0000 (14:35 +0200)
committerKoen Vandeputte <koen.vandeputte@ncentric.com>
Fri, 8 May 2020 13:17:18 +0000 (15:17 +0200)
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.

Adjust config so that WAN is base MAC and LAN is base MAC +1 to better
match label and vendor OS.

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

Signed-off-by: Thibaut VARÈNE <hacks@slashdirt.org>
target/linux/ramips/dts/mt7621_mikrotik_routerboard-750gr3.dts
target/linux/ramips/dts/mt7621_mikrotik_routerboard-m11g.dts
target/linux/ramips/dts/mt7621_mikrotik_routerboard-m33g.dts
target/linux/ramips/mt7621/base-files/etc/board.d/02_network

index a075d085565d9451589306c2382b8d9165404bc5..018e83664db81e676647fe4fcc906d67343f597b 100644 (file)
        };
 };
 
-&gmac0 {
-       mtd-mac-address = <&hard_config 0x0010>;
-};
-
 &switch0 {
        ports {
                port@0 {
                port@1 {
                        status = "okay";
                        label = "lan2";
-                       mtd-mac-address = <&hard_config 0x0010>;
-                       mtd-mac-address-increment = <1>;
                };
 
                port@2 {
                        status = "okay";
                        label = "lan3";
-                       mtd-mac-address = <&hard_config 0x0010>;
-                       mtd-mac-address-increment = <2>;
                };
 
                port@3 {
                        status = "okay";
                        label = "lan4";
-                       mtd-mac-address = <&hard_config 0x0010>;
-                       mtd-mac-address-increment = <3>;
                };
 
                port@4 {
                        status = "okay";
                        label = "lan5";
-                       mtd-mac-address = <&hard_config 0x0010>;
-                       mtd-mac-address-increment = <4>;
                };
        };
 };
index 128b8a2816a8c3c479cf2241b2f527f74ef09692..d7c4a457981f140b2ddf3072b1f8fe9e1e92d5b3 100644 (file)
        };
 };
 
-&gmac0 {
-       mtd-mac-address = <&hard_config 0x0010>;
-       mtd-mac-address-increment = <1>;
-};
-
 &switch0 {
        ports {
                port@0 {
index aff2d0e64f4a47815ab674ae72d79c15fcda5094..30bb36a77fc4f51a36ebfb3331ba0e87419524f2 100644 (file)
        };
 };
 
-&gmac0 {
-       mtd-mac-address = <&hard_config 0x0010>;
-       mtd-mac-address-increment = <1>;
-};
-
 &switch0 {
        ports {
                port@0 {
                        status = "okay";
                        label = "wan";
-                       mtd-mac-address = <&hard_config 0x0010>;
-                       mtd-mac-address-increment = <2>;
                };
 
                port@1 {
index 43db9c6f64480bf6b238fa4361b388fe3cc1a655..34be0670858b1e946e2676ab6d6f3ab5659c759d 100755 (executable)
@@ -91,9 +91,12 @@ ramips_setup_macs()
                wan_mac=$(mtd_get_mac_ascii u-boot-env wanaddr)
                label_mac=$wan_mac
                ;;
+       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")
+               wan_mac=$label_mac
+               lan_mac=$(macaddr_add $label_mac 1)
                ;;
        zbtlink,zbt-we1326|\
        zbtlink,zbt-wg3526-16m|\