[openwrt/openwrt] mediatek: make use of Acer Predator Connect W6's u-boot environment
LEDE Commits
lede-commits at lists.infradead.org
Sat Nov 23 10:47:16 PST 2024
hauke pushed a commit to openwrt/openwrt.git, branch main:
https://git.openwrt.org/e7aaba2587e57dbd157899f7a2215ec6b7af5f89
commit e7aaba2587e57dbd157899f7a2215ec6b7af5f89
Author: George Oldfort <openwrt at 10099.de>
AuthorDate: Mon Nov 11 10:14:55 2024 +0100
mediatek: make use of Acer Predator Connect W6's u-boot environment
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 at 10099.de>
Link: https://github.com/openwrt/openwrt/pull/16861
Signed-off-by: Hauke Mehrtens <hauke at hauke-m.de>
---
package/boot/uboot-envtools/files/mediatek_filogic | 15 +++++++------
.../filogic/base-files/etc/board.d/02_network | 4 ++++
.../etc/hotplug.d/ieee80211/11_fix_wifi_mac | 7 +++---
.../lib/preinit/05_extract_factory_data.sh | 25 ----------------------
.../base-files/lib/preinit/10_fix_eth_mac.sh | 13 +++++------
5 files changed, 22 insertions(+), 42 deletions(-)
diff --git a/package/boot/uboot-envtools/files/mediatek_filogic b/package/boot/uboot-envtools/files/mediatek_filogic
index 9de1a4d75d..7571af0020 100644
--- a/package/boot/uboot-envtools/files/mediatek_filogic
+++ b/package/boot/uboot-envtools/files/mediatek_filogic
@@ -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"
;;
diff --git a/target/linux/mediatek/filogic/base-files/etc/board.d/02_network b/target/linux/mediatek/filogic/base-files/etc/board.d/02_network
index fff39006da..2bcead8304 100644
--- a/target/linux/mediatek/filogic/base-files/etc/board.d/02_network
+++ b/target/linux/mediatek/filogic/base-files/etc/board.d/02_network
@@ -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)
diff --git a/target/linux/mediatek/filogic/base-files/etc/hotplug.d/ieee80211/11_fix_wifi_mac b/target/linux/mediatek/filogic/base-files/etc/hotplug.d/ieee80211/11_fix_wifi_mac
index 3042858353..f7f00c9a83 100644
--- a/target/linux/mediatek/filogic/base-files/etc/hotplug.d/ieee80211/11_fix_wifi_mac
+++ b/target/linux/mediatek/filogic/base-files/etc/hotplug.d/ieee80211/11_fix_wifi_mac
@@ -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
index 87287a7d1c..0000000000
--- a/target/linux/mediatek/filogic/base-files/lib/preinit/05_extract_factory_data.sh
+++ /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
diff --git a/target/linux/mediatek/filogic/base-files/lib/preinit/10_fix_eth_mac.sh b/target/linux/mediatek/filogic/base-files/lib/preinit/10_fix_eth_mac.sh
index 0497d7dfa2..0d7da89cea 100644
--- a/target/linux/mediatek/filogic/base-files/lib/preinit/10_fix_eth_mac.sh
+++ b/target/linux/mediatek/filogic/base-files/lib/preinit/10_fix_eth_mac.sh
@@ -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)
More information about the lede-commits
mailing list