[PATCH] rockchip: board: assign up to 3 static Ethernet MAC addresses

MichaIng micha at dietpi.com
Sat Jun 7 19:11:05 CEST 2025


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.

Signed-off-by: MichaIng <micha at dietpi.com>
---
  arch/arm/mach-rockchip/board.c | 4 ++++
  1 file changed, 4 insertions(+)

diff --git a/arch/arm/mach-rockchip/board.c b/arch/arm/mach-rockchip/board.c
index 75d6693e28a..6b0d5715f5c 100644
--- a/arch/arm/mach-rockchip/board.c
+++ b/arch/arm/mach-rockchip/board.c
@@ -357,6 +357,10 @@ int rockchip_setup_macaddr(void)
         /* Make a valid MAC address for ethernet1 */
         mac_addr[5] ^= 0x01;
         eth_env_set_enetaddr("eth1addr", mac_addr);
+
+       /* Make a valid MAC address for ethernet2 */
+       mac_addr[5] ^= 0x03;
+       eth_env_set_enetaddr("eth2addr", mac_addr);
  #endif
         return 0;
  }
--
2.47.2



More information about the U-Boot mailing list