Missing eth1addr for Banana Pi BPI-R3

Daniel Golle daniel at makrotopia.org
Fri Jul 5 04:35:20 CEST 2024


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-r3-sd.dts?ref_type=heads#L78

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/mediatek/base-files/etc/uci-defaults/99_fwenv-store-ethaddr.sh;h=e9cb4f921d9aedd82550d0cc8935687135ec83a3;hb=HEAD

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...


More information about the U-Boot mailing list