ath79/mikrotik: don't use mtd-mac-address in DTS
authorThibaut VARÈNE <hacks@slashdirt.org>
Sun, 19 Apr 2020 10:09:20 +0000 (12:09 +0200)
committerKoen Vandeputte <koen.vandeputte@ncentric.com>
Fri, 8 May 2020 13:17:17 +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.

To match sticker and vendor OS behavior, WAN MAC is set to the device
base MAC and LAN MAC is incremented from that.

Note: this will trigger a harmless kernel message during boot:
ag71xx 19000000.eth: invalid MAC address, using random address

There is no clean workaround to prevent this message from being emitted.

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

Signed-off-by: Thibaut VARÈNE <hacks@slashdirt.org>
target/linux/ath79/dts/qca9556_mikrotik_routerboard-wap-g-5hact2hnd.dts
target/linux/ath79/dts/qca9558_mikrotik_routerboard-922uags-5hpacd.dts
target/linux/ath79/mikrotik/base-files/etc/board.d/02_network

index a0190760fb893d8fccc852aad0b19d18fa4ede60..feae550039c09b38b995be13216f91438c11cc42 100644 (file)
@@ -11,7 +11,6 @@
        model = "MikroTik RouterBOARD wAP G-5HacT2HnD";
 
        aliases {
-               label-mac-device = &eth1;
                mdio-gpio1 = &mdio2;
                serial0 = &uart;
        };
@@ -53,8 +52,6 @@
 &eth1 {
        status = "okay";
 
-       mtd-mac-address = <&hard_config 0x10>;
-
        pll-data = <0x03000101 0x80000101 0x80001313>;
        phy-handle = <&phy0>;
 
index 7377953f787b93fe6c054000506e982e2393bb5b..391c034dab7472047306709efd1c044ee801bb50 100644 (file)
@@ -11,7 +11,6 @@
        model = "MikroTik RouterBOARD 922UAGS-5HPacD";
 
        aliases {
-               label-mac-device = &eth0;
                led-boot = &led_user;
                led-failsafe = &led_user;
                led-upgrade = &led_user;
@@ -80,7 +79,6 @@
 &eth0 {
        status = "okay";
 
-       mtd-mac-address = <&hard_config 0x10>;
        phy-handle = <&phy4>;
        pll-data = <0x8f000000 0xa0000101 0xa0001313>;
 
index ee795c7496ff4c929f52aa07a745246fca838da8..7f8327f764df19f63aaf978d21e59f6cea073f02 100755 (executable)
@@ -21,8 +21,17 @@ ath79_setup_interfaces()
 ath79_setup_macs()
 {
        local board="$1"
+       local lan_mac=""
+       local wan_mac=""
+       local label_mac=""
+       local mac_base="$(cat /sys/firmware/mikrotik/hard_config/mac_base)"
 
        case "$board" in
+       *)
+               label_mac="$mac_base"
+               wan_mac="$mac_base"
+               lan_mac=$(macaddr_add $mac_base 1)
+               ;;
        esac
 
        [ -n "$lan_mac" ] && ucidef_set_interface_macaddr "lan" $lan_mac