mediatek: store random MAC address in U-Boot env on first boot
authorDaniel Golle <daniel@makrotopia.org>
Tue, 11 Jan 2022 12:58:50 +0000 (12:58 +0000)
committerDaniel Golle <daniel@makrotopia.org>
Sun, 23 Jan 2022 20:20:47 +0000 (20:20 +0000)
For devboards without a MAC address assigned from factory, store
the random MAC in U-Boot env on first boot to make it persistent.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
target/linux/mediatek/base-files/etc/uci-defaults/99_fwenv-store-ethaddr.sh [new file with mode: 0644]

diff --git a/target/linux/mediatek/base-files/etc/uci-defaults/99_fwenv-store-ethaddr.sh b/target/linux/mediatek/base-files/etc/uci-defaults/99_fwenv-store-ethaddr.sh
new file mode 100644 (file)
index 0000000..b078b8f
--- /dev/null
@@ -0,0 +1,14 @@
+[ ! -e /etc/fw_env.config ] && exit 0
+
+. /lib/functions.sh
+
+case "$(board_name)" in
+bananapi,bpi-r2|\
+bananapi,bpi-r64|\
+unielec,u7623-02)
+       [ -z "$(fw_printenv -n ethaddr 2>/dev/null)" ] &&
+               fw_setenv ethaddr "$(cat /sys/class/net/eth0/address)"
+       ;;
+esac
+
+exit 0