[PATCH RFC] cmd: fix net list command

Michael Walle michael at walle.cc
Mon Nov 15 13:11:52 CET 2021

Don't get the MAC address by the environment, but by the platform data
of the udevice. This will fix "net list" if the MAC address is randomly
generated and won't change behavior when linux is booted.

Signed-off-by: Michael Walle <michael at walle.cc>


this is a proposal to fix the "net list" in a way that linux still can have
its own fallback mechanism of MAC addresses even if the bootloader has

The intention is to replace [1], where if I understood correctly, the
intention was to fix "net list".

[1] https://lore.kernel.org/u-boot/3996ba2ee4e6ac136c0802dc0df4ef9b1750157c.1635506067.git.michal.simek@xilinx.com/

 cmd/net.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/cmd/net.c b/cmd/net.c
index 651c1411f4..1df0f4eb99 100644
--- a/cmd/net.c
+++ b/cmd/net.c
@@ -486,14 +486,14 @@ U_BOOT_CMD(
 static int do_net_list(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
 	const struct udevice *current = eth_get_dev();
-	unsigned char env_enetaddr[ARP_HLEN];
 	const struct udevice *dev;
+	struct eth_pdata *pdata;
 	struct uclass *uc;
 	uclass_id_foreach_dev(UCLASS_ETH, dev, uc) {
-		eth_env_get_enetaddr_by_index("eth", dev_seq(dev), env_enetaddr);
-		printf("eth%d : %s %pM %s\n", dev_seq(dev), dev->name, env_enetaddr,
-		       current == dev ? "active" : "");
+		pdata = dev_get_plat(dev);
+		printf("eth%d : %s %pM %s\n", dev_seq(dev), dev->name,
+		       pdata->enetaddr, current == dev ? "active" : "");

More information about the U-Boot mailing list