mediatek: make use of Acer Predator Connect W6's u-boot environment
authorGeorge Oldfort <openwrt@10099.de>
Mon, 11 Nov 2024 09:14:55 +0000 (10:14 +0100)
committerHauke Mehrtens <hauke@hauke-m.de>
Sat, 23 Nov 2024 18:33:42 +0000 (19:33 +0100)
In order to prepare OpenWrt support for other Acer W6 devices and to adapt
the procedure to read and set mac addresses which other devices of the same
target are using (instead of needing an additional script and creating an
additional structure in the file system), this commit
- reads device mac addresses from u-boot environment
- avoids the detour via the file system to set the mac addresses
- drops redundant file /lib/preinit/05_extract_factory_data.sh

The idea and the implementation were thankfully taken from PR #16410.

This is the second of four commits into which the original commit was split
to make reviews easier and more targeted.

Signed-off-by: George Oldfort <openwrt@10099.de>
Link: https://github.com/openwrt/openwrt/pull/16861
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
package/boot/uboot-envtools/files/mediatek_filogic
target/linux/mediatek/filogic/base-files/etc/board.d/02_network
target/linux/mediatek/filogic/base-files/etc/hotplug.d/ieee80211/11_fix_wifi_mac
target/linux/mediatek/filogic/base-files/lib/preinit/05_extract_factory_data.sh [deleted file]
target/linux/mediatek/filogic/base-files/lib/preinit/10_fix_eth_mac.sh

index 9de1a4d75ddc9614add444c8e57d6616adf01b3d..7571af002094eabebe077acd886a3c6c3e2844fa 100644 (file)
@@ -49,6 +49,14 @@ xiaomi,redmi-router-ax6000-ubootmod|\
 zyxel,ex5601-t0-ubootmod)
        ubootenv_add_ubi_default
        ;;
+acer,predator-w6|\
+glinet,gl-mt2500|\
+glinet,gl-mt6000|\
+glinet,gl-x3000|\
+glinet,gl-xe3000)
+       local envdev=$(find_mmc_part "u-boot-env")
+       ubootenv_add_uci_config "$envdev" "0x0" "0x80000"
+       ;;
 asus,rt-ax59u)
        ubootenv_add_uci_config "/dev/mtd0" "0x100000" "0x20000" "0x20000"
        ;;
@@ -89,13 +97,6 @@ dlink,aquila-pro-ai-m30-a1)
 gatonetworks,gdsp)
        ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x10000" "0x10000"
        ;;
-glinet,gl-x3000|\
-glinet,gl-xe3000|\
-glinet,gl-mt2500|\
-glinet,gl-mt6000)
-       local envdev=$(find_mmc_part "u-boot-env")
-       ubootenv_add_uci_config "$envdev" "0x0" "0x80000"
-       ;;
 glinet,gl-mt3000)
        ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x80000" "0x20000"
        ;;
index fff39006da82bc00a8c1d5dbd31265d15ff84ca1..2bcead83045912f7e41f8f2908900d5ceea9c053 100644 (file)
@@ -132,6 +132,10 @@ mediatek_setup_macs()
        local label_mac=""
 
        case $board in
+       acer,predator-w6)
+               wan_mac=$(mmc_get_mac_ascii u-boot-env WANMAC)
+               lan_mac=$(mmc_get_mac_ascii u-boot-env LANMAC)
+               ;;
        bananapi,bpi-r3|\
        bananapi,bpi-r3-mini|\
        bananapi,bpi-r4)
index 3042858353a7cfd90a5295c9f2c1ce49bb61f0d9..f7f00c9a83bd7162d641ba0ef01b1a325af5552d 100644 (file)
@@ -18,10 +18,9 @@ case "$board" in
                [ "$PHYNBR" = "1" ] && macaddr_setbit_la $addr > /sys${DEVPATH}/macaddress
                ;;
        acer,predator-w6)
-               key_path="/var/qcidata/data"
-               [ "$PHYNBR" = "0" ] && cat $key_path/2gMAC > /sys${DEVPATH}/macaddress
-               [ "$PHYNBR" = "1" ] && cat $key_path/6gMAC > /sys${DEVPATH}/macaddress
-               [ "$PHYNBR" = "2" ] && cat $key_path/5gMAC > /sys${DEVPATH}/macaddress
+               [ "$PHYNBR" = "0" ] && mmc_get_mac_ascii u-boot-env 2gMAC > /sys${DEVPATH}/macaddress
+               [ "$PHYNBR" = "1" ] && mmc_get_mac_ascii u-boot-env 6gMAC > /sys${DEVPATH}/macaddress
+               [ "$PHYNBR" = "2" ] && mmc_get_mac_ascii u-boot-env 5gMAC > /sys${DEVPATH}/macaddress
                ;;
        asus,rt-ax59u)
                CI_UBIPART="UBI_DEV"
diff --git a/target/linux/mediatek/filogic/base-files/lib/preinit/05_extract_factory_data.sh b/target/linux/mediatek/filogic/base-files/lib/preinit/05_extract_factory_data.sh
deleted file mode 100644 (file)
index 87287a7..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-. /lib/functions/system.sh
-
-predator_w6_factory_extract() {
-       local mmc_part
-
-       mmc_part="$(find_mmc_part qcidata)"
-
-       mkdir -p /var/qcidata/data
-       mkdir -p /var/qcidata/mount
-
-       mount -r "$mmc_part" /var/qcidata/mount
-
-       cp /var/qcidata/mount/factory/*MAC "/var/qcidata/data/"
-       umount "/var/qcidata/mount"
-}
-
-preinit_extract_factory() {
-       case $(board_name) in
-       acer,predator-w6)
-               predator_w6_factory_extract
-               ;;
-       esac
-}
-
-boot_hook_add preinit_main preinit_extract_factory
index 0497d7dfa2474ff1dbed6a91d763f603eff38d17..0d7da89ceaabf5084372a3cedf90a02ca67eb616 100644 (file)
@@ -3,12 +3,13 @@
 preinit_set_mac_address() {
        case $(board_name) in
        acer,predator-w6)
-               key_path="/var/qcidata/data"
-               ip link set dev lan1 address "$(cat $key_path/LANMAC)"
-               ip link set dev lan2 address "$(cat $key_path/LANMAC)"
-               ip link set dev lan3 address "$(cat $key_path/LANMAC)"
-               ip link set dev game address "$(cat $key_path/LANMAC)"
-               ip link set dev eth1 address "$(cat $key_path/WANMAC)"
+               $(mmc_get_mac_ascii u-boot-env WANMAC)
+               $(mmc_get_mac_ascii u-boot-env LANMAC)
+               ip link set dev lan1 address "$lan_mac"
+               ip link set dev lan2 address "$lan_mac"
+               ip link set dev lan3 address "$lan_mac"
+               ip link set dev game address "$lan_mac"
+               ip link set dev eth1 address "$wan_mac"
                ;;
        asus,tuf-ax4200|\
        asus,tuf-ax6000)