[U-Boot] Linux Kernel without Ethernet (missed MAC)

Daniel Gorsulowski Daniel.Gorsulowski at esd.eu
Tue Jan 19 15:50:01 CET 2010


Hi Arno,

Arno Steffen wrote:
> Changing my OMAP EVM board to newest uboot 2009-11 I do have a problem
> with ethernet.
> Although the kernel could be loaded via tftp perfectly, the upcoming
> kernel complains about invalid MAC.
> 
> Kernel command line: mem=128M console=ttyS0,115200n8
> root=/dev/mtdblock8 rw rootfstype=jffs2 ip=dhcp
> ...
On ARM, I solved that problem as follows:

1. Add "ethaddr=$(ethaddr)" to your kernel command line. e.g.:
   mem=128M console=ttyS0,115200n8 ethaddr=$(ethaddr)

2. Apply this patch on linux kernel (approved on v2.6.31):

diff --git a/drivers/net/macb.c b/drivers/net/macb.c
index 92fe36d..cddf67a 100644
--- a/drivers/net/macb.c
+++ b/drivers/net/macb.c
@@ -14,6 +14,7 @@
 #include <linux/kernel.h>
 #include <linux/types.h>
 #include <linux/slab.h>
+#include <linux/string.h>
 #include <linux/init.h>
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
@@ -81,9 +82,14 @@ static void __init macb_get_hwaddr(struct macb *bp)
 	u32 bottom;
 	u16 top;
 	u8 addr[6];
+	char *ptr = NULL;
+	char *ptr_end;
+	char ethaddr[17];
+	int i;

 	bottom = macb_readl(bp, SA1B);
 	top = macb_readl(bp, SA1T);
+	ptr = strstr(boot_command_line, "ethaddr=");

 	addr[0] = bottom & 0xff;
 	addr[1] = (bottom >> 8) & 0xff;
@@ -94,6 +100,16 @@ static void __init macb_get_hwaddr(struct macb *bp)

 	if (is_valid_ether_addr(addr)) {
 		memcpy(bp->dev->dev_addr, addr, sizeof(addr));
+	} else if (ptr) {
+		memcpy(ethaddr, ptr + 8, 17 * sizeof(char));
+		printk(KERN_NOTICE "ethaddr parsed from commandline: %s\n", ethaddr);
+		ptr_end = ethaddr;
+		for (i = 0; i <= 5; i++) {
+			addr[i] = simple_strtol(ptr_end, &ptr_end, 16) |
+					simple_strtol(ptr_end, &ptr_end, 16) << 4;
+			ptr_end++; /* skip ":" in  ethaddr */
+		}
+		memcpy(bp->dev->dev_addr, addr, sizeof(addr));
 	} else {
 		dev_info(&bp->pdev->dev, "invalid hw address, using random\n");
 		random_ether_addr(bp->dev->dev_addr);



More information about the U-Boot mailing list