
On Fri, Jul 05, 2024 at 11:05:31AM +1000, Leith Bade wrote:
Hi,
I have been investigating how to stop the MAC addresses on my Banana Pi BPI-R3 from changing on every boot.
It appears the ethaddr and eth1addr environment variables are used for this purpose as they are randomly generated on first boot, then become fixed after being saved to the environment storage.
However on my BPI-R3 I only see ethaddr which corresponds to the MT7530 switch device. There is no eth1addr for the other Ethernet device which is the SFP port. Thus Linux keeps generating a new MAC address for the SFP port.
How do I get U-boot to generate eth1addr and assign a permanent MAC address to the SFP port?
Sadly U-Boot as of today only supports only a single Ethernet MAC with the MediaTek driver, with no actual DSA switch driver:
https://source.denx.de/u-boot/u-boot/-/blob/master/arch/arm/dts/mt7986a-bpi-...
So from U-Boot's perspective there is currently only a single Ethernet device, and hence also CONFIG_NET_RANDOM_ETHADDR will only set 'ethaddr', and only the MAC address of Ethernet MAC pointed to by the 'ethernet0' alias in the device tree will be assigned.
When using OpenWrt, we are dealing with this differently: The random address generated by Linux is made persistent on first boot for both ethernet devices:
https://git.openwrt.org/?p=openwrt/openwrt.git;a=blob;f=target/linux/mediate...
And eventhough U-Boot at this point knows nothing about there being more than one Ethernet MAC it still sets the address stored in eth1addr for the Ethernet MAC pointed to by the 'ethernet1' alias.
However, to let U-Boot do that for you, we would need to change the Ethernet driver in U-Boot to expose all MACs rather than just one of them.
Christian Marangi (Ansuel) has been working on decreasing the gap between U-Boot and Linux, however, when it comes to the Ethernet driver this means quite a bit of work...