From 7173a52f6aea971ae90610f10fd2f184dd29755c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Pawe=C5=82=20Owoc?= Date: Sat, 6 Jan 2024 17:05:40 +0100 Subject: [PATCH] ipq807x: use devinfo MAC for Linksys MX4200 MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Some devices (MX42CF) have a wrong MAC address configuration. The correct one is located only on the devinfo partition. Signed-off-by: Paweł Owoc --- .../ipq807x/base-files/etc/board.d/02_network | 24 +++++++++++++++++++ .../etc/hotplug.d/ieee80211/11_fix_wifi_mac | 7 ++++++ 2 files changed, 31 insertions(+) diff --git a/target/linux/qualcommax/ipq807x/base-files/etc/board.d/02_network b/target/linux/qualcommax/ipq807x/base-files/etc/board.d/02_network index 1e0719cf005..f38c4b66984 100644 --- a/target/linux/qualcommax/ipq807x/base-files/etc/board.d/02_network +++ b/target/linux/qualcommax/ipq807x/base-files/etc/board.d/02_network @@ -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 diff --git a/target/linux/qualcommax/ipq807x/base-files/etc/hotplug.d/ieee80211/11_fix_wifi_mac b/target/linux/qualcommax/ipq807x/base-files/etc/hotplug.d/ieee80211/11_fix_wifi_mac index f951d925ab9..343e42d6346 100644 --- a/target/linux/qualcommax/ipq807x/base-files/etc/hotplug.d/ieee80211/11_fix_wifi_mac +++ b/target/linux/qualcommax/ipq807x/base-files/etc/hotplug.d/ieee80211/11_fix_wifi_mac @@ -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 -- 2.30.2