ramips: mt7621: use flash location for wan_mac in 02_network
authorAdrian Schmutzler <freifunk@adrianschmutzler.de>
Sun, 8 Dec 2019 12:42:39 +0000 (13:42 +0100)
committerAdrian Schmutzler <freifunk@adrianschmutzler.de>
Thu, 12 Dec 2019 12:11:28 +0000 (13:11 +0100)
This uses the flash locations instead of eth0 MAC address to
calculate MAC address increments for WAN.

The change will make the MAC address setup of a particular device
more obvious and removes the dependency of 02_network on the eth0
initialization.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
target/linux/ramips/mt7621/base-files/etc/board.d/02_network

index e7e225a148618a18af3c376938b3110d10c5a909..2828cf67dc50847a5e56ad91d053506c8de62cce 100755 (executable)
@@ -147,30 +147,21 @@ ramips_setup_macs()
        local label_mac=""
 
        case $board in
-       adslr,g7|\
+       adslr,g7)
+               wan_mac=$(macaddr_add "$(mtd_get_mac_binary factory 0xe00c)" 1)
+               ;;
        afoundry,ew1200|\
        asiarf,ap7621-001|\
        asiarf,ap7621-nv1|\
        firefly,firewrt|\
        gehua,ghl-r-001|\
-       mediatek,ap-mt7621a-v60|\
-       mikrotik,rb750gr3|\
-       mikrotik,rbm33g|\
        mqmaker,witi|\
-       mtc,wr1201|\
-       netgear,r6220|\
-       netgear,wndr3700-v5|\
-       storylink,sap-g3200u3|\
-       telco-electronics,x1|\
        totolink,a7000r|\
-       ubiquiti,edgerouterx|\
-       ubiquiti,edgerouterx-sfp|\
        unielec,u7621-06-16m|\
        unielec,u7621-06-64m|\
-       xiaoyu,xy-c5|\
        xzwifi,creativebox-v1|\
        zbtlink,zbt-wg2626)
-               wan_mac=$(macaddr_add "$(cat /sys/class/net/eth0/address)" 1)
+               wan_mac=$(macaddr_add "$(mtd_get_mac_binary factory 0xe000)" 1)
                ;;
        alfa-network,quad-e4g|\
        asus,rt-ac57u|\
@@ -215,17 +206,36 @@ ramips_setup_macs()
                wan_mac=$(macaddr_add "$lan_mac" 1)
                ;;
        iodata,wn-ax1167gr|\
-       iodata,wn-gx300gr)
+       iodata,wn-gx300gr|\
+       mtc,wr1201|\
+       netgear,r6220|\
+       netgear,wndr3700-v5|\
+       xiaoyu,xy-c5)
                wan_mac=$(macaddr_add "$(mtd_get_mac_binary factory 0x4)" 1)
                ;;
        iodata,wnpr2600g)
                wan_mac=$(mtd_get_mac_ascii u-boot-env wanaddr)
                label_mac=$wan_mac
                ;;
+       mediatek,ap-mt7621a-v60)
+               wan_mac=$(macaddr_add "$(mtd_get_mac_binary factory 0x5)" 1)
+               ;;
+       mikrotik,rb750gr3|\
+       mikrotik,rbm33g)
+               wan_mac=$(macaddr_add "$(mtd_get_mac_binary hard_config 0x10)" 2)
+               ;;
        netgear,r6260|\
        netgear,r6350|\
        netgear,r6850)
-               wan_mac=$(macaddr_add "$(cat /sys/class/net/eth0/address)" 2)
+               wan_mac=$(macaddr_add "$(mtd_get_mac_binary factory 0x4)" 2)
+               ;;
+       storylink,sap-g3200u3|\
+       telco-electronics,x1)
+               wan_mac=$(macaddr_add "$(mtd_get_mac_binary factory 0xe006)" 1)
+               ;;
+       ubiquiti,edgerouterx|\
+       ubiquiti,edgerouterx-sfp)
+               wan_mac=$(macaddr_add "$(mtd_get_mac_binary factory 0x22)" 1)
                ;;
        wevo,11acnas|\
        wevo,w2914ns-v2)
@@ -249,7 +259,7 @@ ramips_setup_macs()
                ;;
        zbtlink,zbt-wg3526-16m|\
        zbtlink,zbt-wg3526-32m)
-               wan_mac=$(macaddr_add "$(cat /sys/class/net/eth0/address)" 1)
+               wan_mac=$(macaddr_add "$(mtd_get_mac_binary factory 0xe000)" 1)
                label_mac=$(mtd_get_mac_binary factory 0x4)
                ;;
        esac