-
Andreas Gnau authored
Set label MAC address from iopsys-environment.sh which in most cases equates to U-Boot env ethaddr. For platforms that already have a MAC address populated by U-Boot, do not do anything, because in those cases it is possible to rely on OpenWrt's built-in solution of having the label-mac-device alias point to the device-tree node having the MAC address. Signed-off-by:
Andreas Gnau <andreas.gnau@iopsys.eu>
Andreas Gnau authoredSet label MAC address from iopsys-environment.sh which in most cases equates to U-Boot env ethaddr. For platforms that already have a MAC address populated by U-Boot, do not do anything, because in those cases it is possible to rely on OpenWrt's built-in solution of having the label-mac-device alias point to the device-tree node having the MAC address. Signed-off-by:
Andreas Gnau <andreas.gnau@iopsys.eu>
09-set-label-mac 717 B
. /lib/functions/system.sh
. /lib/functions/uci-defaults.sh
. /lib/functions/iopsys-environment.sh
# Ideally, we should use OpenWrt label-mac-device alias in device tree
# but for some platforms with legacy drivers this has not been implemented.
# For those platforms, use iopsys-environment.sh
set_label_macaddr() {
local macaddr
# Use iopsys-environment (fw_printenv usually)
macaddr="$(macaddr_canonicalize "$(get_base_macaddr)")"
[ -n "$macaddr" ] || return
ucidef_set_label_macaddr "$macaddr"
}
mac_addr="$(get_mac_label)"
if [ -n "$mac_addr" ]; then
# do not write MAC to board.json if OpenWrt get_mac_label already has one
exit 0
fi
board_config_update
set_label_macaddr || exit 0
board_config_flush