Skip to contentSkip to conversation

Linux Kernel without Ethernet (missed MAC)

U-Boot Arno Steffen 6 participants 12 messages Jan 19, 2010 – Jan 20, 2010 Network drivers

lore
Share & tools
lore
#0 lore raw

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
...
loop: module loaded
eth0: LAN9115 (rev 2) at 0x2c000000 IRQ 336
eth0: Invalid ethernet MAC address. Please set using ifconfig i2c /dev entries driver
...
IP-Config: Failed to open eth0
IP-Config: No network devices available.
...
After Linux has booted, I don't have an /dev/ethX device

I already checked this:
http://www.denx.de/wiki/view/DULG/EthernetDoesNotWorkInLinux
but I am not expert enough to see wether the kernel has a bug. In /driver/net/smc911x.c the devinit smc911x_probe will generate the first message that something goes wrong

               if (!is_valid_ether_addr(dev->dev_addr)) {
                       printk("%s: Invalid ethernet MAC address. Please "
                                       "set using ifconfig\n", dev->name);

/driver/net/smc911x.c checks in smc911x_open() the validity of MAC, which seems to fail.
/driver/net/smc911x.c calls SMC_GET_MAC_ADDR which is a macro in /driver/net/smc91x.h

In uboot-env the Mac has been configured.
"Warning: smc911x-0 MAC addresses don't match:
Address in SROM is ff:ff:ff:ff:ff:ff
Address in environment is 00:19:66:cc:44:ee"

Loading via TFTP works
OMAP3_EVM # tftpboot 0x80000000 evm/uImage
smc911x: detected LAN9115 controller
smc911x: phy initialized
smc911x: MAC 00:19:66:cc:44:ee
Using smc911x-0 device
TFTP from server 192.168.90.230; our IP address is 192.168.90.200 Filename 'evm/uImage'.
Load address: 0x80000000
Loading: #################################################################

         #################################################################
         #

done

Best regards
Arno

#1 lore raw
Quoted 9 lines

-----Original Message-----
From: u-boot-bounces at lists.denx.de [mailto:u-boot-bounces at lists.denx.de] On Behalf Of Arno Steffen
Sent: Tuesday, January 19, 2010 3:14 PM
To: u-boot at lists.denx.de
Subject: [U-Boot] Linux Kernel without Ethernet (missed MAC)

Quoted 7 lines

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

Hi Arno

I hope, when you are booting the kernel from media (i.e. NAND/Flash/Sata and not Ethernet) you are getting this problem. u-boot does not perform peripheral h/w initialization by default, u-boot as well as kernel assumes h/w is doing this.

May be in your case, smc91x h/w does not do it on Power on by default.
When you do any network activity prior to kernel boot, device_init is invoked and the MAC address is set and your system works.

Possible Solution: add dummy network command like (ping x.x.x.x) in your auto boot sequence.

Regards..
Prafulla . .

Quoted 1 line

...

#2 lore raw

I think this is a uboot bug.

If this is a kernel bug - where does the kernel gets the mac address from? Is it reading a device register? So it must be set by u-boot. But obviously it isn't there (kernel boot log):
"eth0: LAN9115 (rev 2) at 0x2c000000 IRQ 336
eth0: Invalid ethernet MAC address. Please set using ifconfig"

The problem occures in any boot sequence (nand, network) - so although the uboot initializes the ethernet chip, linux kernel doesn't find the mac-address. So your advice doesn't help.

I am not expert enough to know how it should be. In an older uboot (2008.10) I could solve the problem with any ethernet access in uboot (as you suggested) - then I get ethernet in kernel boot as well.

In 2009.11 it is different - no way to get it working - same kernel. Looks like uboot either doesn't set mac or deletes mac.

Best regards
Arno

2010/1/19 Prafulla Wadaskar <[email protected]>:

Quoted 32 lines
Quoted 9 lines

-----Original Message-----
From: u-boot-bounces at lists.denx.de [mailto:u-boot-bounces at lists.denx.de] On Behalf Of Arno Steffen
Sent: Tuesday, January 19, 2010 3:14 PM
To: u-boot at lists.denx.de
Subject: [U-Boot] Linux Kernel without Ethernet (missed MAC)

Quoted 7 lines

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

Hi Arno

I hope, when you are booting the kernel from media (i.e. NAND/Flash/Sata and not Ethernet) you are getting this problem. u-boot does not perform peripheral h/w initialization by default, u-boot as well as kernel assumes h/w is doing this.

May be in your case, smc91x h/w does not do it on Power on by default.
When you do any network activity prior to kernel boot, device_init is invoked and the MAC address is set and your system works.

Possible Solution: add dummy network command like (ping x.x.x.x) in your auto boot sequence.

Regards..
Prafulla . .

Quoted 1 line

...

#3 lore raw

Dear Arno Steffen,

Quoted 1 line · In message <[email protected]> you…

I think this is a uboot bug.

You sound as is you were really sure about this.

But maybe you did not even read the FAQ, for example
http://www.denx.de/wiki/view/DULG/EthernetDoesNotWorkInLinux ?

And you also did not bother to search the archives, or did you?

Wolfgang Denk

Signature · 6 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
FORTRAN? The syntactically incorrect statement "DO 10 I = 1.10"  will
parse  and  generate  code  creating  a  variable, DO10I, as follows:
"DO10I = 1.10" If that doesn't terrify you, it should.
#9 lore raw
In reply to Arno Steffen

Hi Arno,

Quoted 8 lines · Arno Steffen

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):

drivers/net/macb.c +16 -0
index 92fe36d..cddf67a 100644
@@ -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);
#4 lore raw
In reply to Wolfgang Denk

2010/1/19 Wolfgang Denk <[email protected]>:

Quoted 6 lines

Dear Arno Steffen,

Quoted 1 line · In message <[email protected]> you…

I think this is a uboot bug.

You sound as is you were really sure about this.

I can't be sure, as I don't know how MAC is transfered into kernel (no eprom) - that's what I ask for.
An older versions of uboot it works with the same kernel - so what should I think about it?
At least things have been changed ...

Quoted 3 lines

But maybe you did not even read the FAQ, for example
http://www.denx.de/wiki/view/DULG/EthernetDoesNotWorkInLinux ?

In my first mail
(http://lists.denx.de/pipermail/u-boot/2010-January/066703.html)
I wrote that I have checked this and wrote down what I found out. Probably it is due to my limited experience in this, that's why I asked for help.
A "ifconfig" after boot will not help, as I don't have an eth-device.

Quoted 1 line

And you also did not bother to search the archives, or did you

Call me stupid, I just know this access : http://lists.denx.de/pipermail/u-boot/
This doesn't allow a practial search (at least I don't know how) - sorry. I am working puzzling more than a day with this - so I am not lazy with that. I try my best.

Quoted 1 line

Wolfgang Denk

Best regards
Arno

#10 lore raw
In reply to Daniel Gorsulowski

2010/1/19 Daniel Gorsulowski <[email protected]>:

Quoted 7 lines

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):

Thanks for this idea. I checked the kernel and set in file smsc911x.c in function smc911x_reset()

	dev->dev_addr[0] = 0

to get valid (but not my mac address).

Nevertheless I would prefer to patch the uboot instead of kernel. What I don't understand is: MAC (that is set in uboot - at least if I do a tftp) will disapear.
Is it cleaned up by uboot? Somehow it has worked before ...

Or the other way around: What is the current valid and recommended way to pass mac from uboot to kernel? It should work without patches.

#11 lore raw
In reply to Daniel Gorsulowski

Dear Daniel Gorsulowski,

Quoted 3 lines · In message <[email protected]> you wrote:

1. Add "ethaddr=$(ethaddr)" to your kernel command line. e.g.:

   mem=128M console=ttyS0,115200n8 ethaddr=$(ethaddr)

Please use "ethaddr=${ethaddr}" instead - the $(...) syntax has been deprecated a long, long time ago and will be removed one day.

Best regards,

Wolfgang Denk

Signature · 6 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Blast medicine anyway!  We've learned to tie into every organ in the
human body but one.  The brain!  The brain is what life is all about.
	-- McCoy, "The Menagerie", stardate 3012.4
#6 lore raw
In reply to Arno Steffen

Dear Arno Steffen,

Quoted 3 lines · In message <[email protected]> you…

Call me stupid, I just know this access : http://lists.denx.de/pipermail/u-boot/
This doesn't allow a practial search (at least I don't know how) - sorry.

The U-Boot home page at http://www.denx.de/wiki/U-Boot/WebHome
also lists the gmane archives which allow for all kinds of searching.

Best regards,

Wolfgang Denk

Signature · 4 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Save yourself!  Reboot in 5 seconds!
#7 lore raw
In reply to Arno Steffen

Hi Arno,

Quoted 9 lines
Quoted 2 lines

But maybe you did not even read the FAQ, for example
http://www.denx.de/wiki/view/DULG/EthernetDoesNotWorkInLinux ?

In my first mail
(http://lists.denx.de/pipermail/u-boot/2010-January/066703.html)
I wrote that I have checked this and wrote down what I found out. Probably it is due to my limited experience in this, that's why I asked for help.
A "ifconfig" after boot will not help, as I don't have an eth-device.

I will not comment yet another time on this infamous topic of passing MAC addresses to the Linux kernel in the ARM world - we tried several times to fix this. Usually we were informed that this can be easily (really that's what they tell you on the ARM mailing list) done with an initial ramdisk - even if you want to use an NFS rootfilesystem.

So for your information - you should still have an ethernet interface in Linux, you simply have to assign a mac. Use something like "ifconfig eth0 hw ether xx:xx:xx:xx:xx:xx". Then the interface should work.

Cheers
Detlev

Signature · 9 lines
I've never understood the tendency to pick up tastes because they are popular.
In fact,  I think it is  foolish to do that.  I mean, don't  you know what you
like?  People who  are so weak that  they will take  their tastes  from people
around  them  in  the  desperate  desire  to be  accepted,  I think of them as
cowards.               -- Richard M. Stallman
--
DENX Software Engineering GmbH,      MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich,  Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-40 Fax: (+49)-8142-66989-80 Email: dzu at denx.de
#8 lore raw

I did a small mod in uboot now. After each ethernet-access the interface chip seems to get a soft reset, which deletes the mac address in its registers.

So in smc911x.h (!!!!) in function smc911x_reset I commented the line

// smc911x_reg_write(dev, HW_CFG, HW_CFG_SRST);

It is somehow pitty that kernel (even latest) and uboot doesn't match anymore. As I coudn't find out how does the kernel usually know the mac from, I don't know what part is responsible.
Thanks all of you for your help.