Hi MichaIng,
On 6/7/25 7:11 PM, MichaIng wrote:
[You don't often get email from mi...@dietpi.com. Learn why this is
important at https://aka.ms/LearnAboutSenderIdentification ]
Some SBCs with Rockchip SoC provide 3 Ethernet ports, like the
FriendlyELEC NanoPi R5S and NanoPi R6S. U-Boot assigns already eth*addr
variables to ethernet* device tree node aliases, but for Rockchip
boards, it generates only ethaddr and eth1addr so far.
To allow the assignment of 3 static MAC addresses, with this change,
eth2addr is generated with a logic similar to how eth1addr is generated
already:
- eth1addr is currently derived from ethaddr by inverting the last bit,
which raises or decreases the last hex digit of the MAC address by one.
- Hereby, the eth2addr is derived from the value assigned to eth1addr,
by inverting the last 2 bits. Hence, differs from the first ethaddr by
an inverted second last bit, which raises or decreases the last hex
digit of the MAC address by two. This assures a valid MAC address
assigned to eth2addr, which always differs from ethaddr and eth1addr.
The change has been successfully tested on the NanoPi R5S and NanoPi
R6S: With ethernet[0-2] device tree aliases (correctly) defined, both
boards get 3 static MAC addresses.
What's the number when we'll decide this is too many? I have a board
with 5 Ethernet ports for example :)
You could set the eth2addr in your board file if you wanted instead of
setting it for everybody.
I don't know how far we want to go to avoid defining unused ethXaddr
variables in the environment? We could use of_alias_get_highest_id for
example and generate enough environment variables based on that info?
The change looks ok though, so:
Reviewed-by: Quentin Schulz <quentin.sch...@cherry.de>
Thanks!
Quentin