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>
(cherry picked from commit
e7aaba2587e57dbd157899f7a2215ec6b7af5f89)
Link: https://github.com/openwrt/openwrt/pull/17097
Signed-off-by: Petr Štetiar <ynezz@true.cz>
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"
;;
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"
;;
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)
[ "$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"
+++ /dev/null
-. /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
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)