As evidenced here[1] the device MAC address can be stored at a random
offset in the hard_config partition. Rely on sysfs to update the MAC
address correctly.
To match sticker and vendor OS behavior, WAN MAC is set to the device
base MAC and LAN MAC is incremented from that.
Note: this will trigger a harmless kernel message during boot:
ag71xx
19000000.eth: invalid MAC address, using random address
There is no clean workaround to prevent this message from being emitted.
[1] https://github.com/openwrt/openwrt/pull/2850#issuecomment-
610809021
Signed-off-by: Thibaut VARÈNE <hacks@slashdirt.org>
model = "MikroTik RouterBOARD wAP G-5HacT2HnD";
aliases {
- label-mac-device = ð1;
mdio-gpio1 = &mdio2;
serial0 = &uart;
};
ð1 {
status = "okay";
- mtd-mac-address = <&hard_config 0x10>;
-
pll-data = <0x03000101 0x80000101 0x80001313>;
phy-handle = <&phy0>;
model = "MikroTik RouterBOARD 922UAGS-5HPacD";
aliases {
- label-mac-device = ð0;
led-boot = &led_user;
led-failsafe = &led_user;
led-upgrade = &led_user;
ð0 {
status = "okay";
- mtd-mac-address = <&hard_config 0x10>;
phy-handle = <&phy4>;
pll-data = <0x8f000000 0xa0000101 0xa0001313>;
ath79_setup_macs()
{
local board="$1"
+ local lan_mac=""
+ local wan_mac=""
+ local label_mac=""
+ local mac_base="$(cat /sys/firmware/mikrotik/hard_config/mac_base)"
case "$board" in
+ *)
+ label_mac="$mac_base"
+ wan_mac="$mac_base"
+ lan_mac=$(macaddr_add $mac_base 1)
+ ;;
esac
[ -n "$lan_mac" ] && ucidef_set_interface_macaddr "lan" $lan_mac