ipq807x: use devinfo MAC for Linksys MX4200
authorPaweł Owoc <frut3k7@gmail.com>
Sat, 6 Jan 2024 16:05:40 +0000 (17:05 +0100)
committerChristian Marangi <ansuelsmth@gmail.com>
Mon, 15 Jan 2024 15:52:08 +0000 (16:52 +0100)
Some devices (MX42CF) have a wrong MAC address configuration. The correct one is located only on the devinfo partition.

Signed-off-by: Paweł Owoc <frut3k7@gmail.com>
target/linux/qualcommax/ipq807x/base-files/etc/board.d/02_network
target/linux/qualcommax/ipq807x/base-files/etc/hotplug.d/ieee80211/11_fix_wifi_mac

index 1e0719cf005ddfc4aaf061346be29718244262d2..f38c4b6698446e43bf06ae14229cc5f76e9f759e 100644 (file)
@@ -57,9 +57,33 @@ ipq807x_setup_interfaces()
        esac
 }
 
+ipq807x_setup_macs()
+{
+       local board="$1"
+       local lan_mac=""
+       local wan_mac=""
+       local label_mac=""
+
+       case "$board" in
+               linksys,mx4200v1|\
+               linksys,mx4200v2)
+                       label_mac=$(mtd_get_mac_ascii devinfo hw_mac_addr)
+                       for i in $(seq 3 5); do
+                               [ "$(mtd_get_mac_ascii u_env eth${i}addr)" != "$label_mac" ] && lan_mac=$label_mac
+                       done
+                       [ "$(mtd_get_mac_ascii u_env eth2addr)" != "$label_mac" ] && wan_mac=$label_mac
+               ;;
+       esac
+
+       [ -n "$lan_mac" ] && ucidef_set_interface_macaddr "lan" $lan_mac
+       [ -n "$wan_mac" ] && ucidef_set_interface_macaddr "wan" $wan_mac
+       [ -n "$label_mac" ] && ucidef_set_label_macaddr $label_mac
+}
+
 board_config_update
 board=$(board_name)
 ipq807x_setup_interfaces $board
+ipq807x_setup_macs $board
 board_config_flush
 
 exit 0
index f951d925ab9e7122aa6bb076fe86c8135ddc3d10..343e42d6346e1e39082562f5a74fa46e16e19a07 100644 (file)
@@ -18,6 +18,13 @@ case "$board" in
                [ "$PHYNBR" = "0" ] && macaddr_add $(get_mac_label)  8 > /sys${DEVPATH}/macaddress
                [ "$PHYNBR" = "1" ] && macaddr_add $(get_mac_label) 16 > /sys${DEVPATH}/macaddress
                ;;
+       linksys,mx4200v1|\
+       linksys,mx4200v2)
+               label_mac=$(mtd_get_mac_ascii devinfo hw_mac_addr)
+               [ "$PHYNBR" = "0" ] && macaddr_add $label_mac 2 > /sys${DEVPATH}/macaddress
+               [ "$PHYNBR" = "1" ] && macaddr_add $label_mac 1 > /sys${DEVPATH}/macaddress
+               [ "$PHYNBR" = "2" ] && macaddr_add $label_mac 3 > /sys${DEVPATH}/macaddress
+               ;;
        zte,mf269)
                [ "$PHYNBR" = "0" ] && macaddr_add $(get_mac_label) 2 > /sys${DEVPATH}/macaddress
                [ "$PHYNBR" = "1" ] && macaddr_add $(get_mac_label) 3 > /sys${DEVPATH}/macaddress