[U-Boot] [PATCH] fdt_support: Fixup 'ethernet' aliases not ending in digits

Tuomas Tynkkynen tuomas at tuxera.com
Fri Mar 17 19:44:59 UTC 2017


The Raspberry Pi device tree files since Linux v4.9 have a "ethernet"
alias pointing to the on-board Ethernet device node. However,
U-Boot's fdt_fixup_ethernet() (and the kernel's of_alias_scan()) only
looks at ethernet aliases ending in digits. Make it also check the
"ethernet" alias.

Without this Linux isn't told of the MAC address provided by the
RPI firmware and the ethernet device is always assigned a random MAC
address.

The device trees themselves can't be fixed as someone is already
depending on the "ethernet" alias:
https://github.com/raspberrypi/firmware/issues/613

Signed-off-by: Tuomas Tynkkynen <tuomas at tuxera.com>
---
 common/fdt_support.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/common/fdt_support.c b/common/fdt_support.c
index 55d4d6f6d4..6e509b38e5 100644
--- a/common/fdt_support.c
+++ b/common/fdt_support.c
@@ -496,7 +496,15 @@ void fdt_fixup_ethernet(void *fdt)
 
 		path = fdt_getprop_by_offset(fdt, offset, &name, NULL);
 		if (!strncmp(name, "ethernet", len)) {
-			i = trailing_strtol(name);
+			/*
+			 * Some device trees (bcm2835) have an alias without
+			 * the number at end. Support that as well.
+			 */
+			if (!strcmp(name, "ethernet"))
+				i = 0;
+			else
+				i = trailing_strtol(name);
+
 			if (i != -1) {
 				if (i == 0)
 					strcpy(mac, "ethaddr");
-- 
2.11.1



More information about the U-Boot mailing list