FAQ •  Search •  Register •  Login 

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 10 posts ] 
Author Message
 Post subject: Ethernet problems on SAM9G20
PostPosted: Mon Aug 13, 2012 2:46 pm 
Offline

Joined: Fri Aug 10, 2012 4:22 pm
Posts: 5
Location: Switzerland
Good Morning
We are running a 2.6.36-rc3 Kernel with the AT91 patches on a custom At91SAM9G20 board using a KSZ8041NL from Micrel as ethernet IC. Since this is a custom board we edited the CPU and board configuration files to match our setup. The important settings are: PA23 and PA24 are used for the network interface, TWI is disabled as we are using slot A for our microSD-card. RMII is disabled, PA0 is used as IRQ. For visualization i've uploaded a part of our schematic. http://img98.imageshack.us/img98/2717/ethernet.png

During the boot process the interface is recognized and the Atmel MACB driver is loaded. Additionally the "eth0" device is created. However after bringing it up it does not recognize the cable connecting it to the LAN. The link status remains "down" and the LEDs stay off. I've uploaded the output of a number of diagnostic tools from this situation, find it here: http://pastebin.com/iD9M0Z6Y

Accidentially we discovered that when autonegotiation is disabled for eth0, a link is established with 10Mbits but it is not possible to transmit or recieve packets. Unfortunately we don't have an explanation for this behavior.
When using a wireless USB-adaptor connections are possible. In addition powering the board without bootloaders present causes the LEDs of the ethernet interface to flash, which leads us to the conclusion that the error must be related to the drivers used for the PHY.

As we currently aren't sure where to continue I'd highly appreciate any pointers or ideas about where to look for the problem or how to solve it. Maybe there are others who experienced similar problems... Thanks in advance! :)

Edit: Updated image. The upload quota of this board seems to be full...


Top
 Profile  
 
 Post subject: Re: Ethernet problems on SAM9G20
PostPosted: Tue Aug 14, 2012 1:10 am 
Offline

Joined: Thu Apr 19, 2007 10:15 pm
Posts: 702
Location: USA
zfr wrote:
During the boot process the interface is recognized and the Atmel MACB driver is loaded.

Considering that AT91 uses a multi-stage boot sequence, that's a broad statement.

Seems like you really need to confirm that the HW is fully operational before worrying about networking in Linux. You could use U-Boot to test out the Ethernet interface. Make sure that the MAC address and IP address are defined as environment variables. U-Boot has ping, tftp and sntp capabilities. Its memory read & write commands can be used to examine and modify device registers.

Getting networking functional in U-Boot is not wasted work. The tftp capability is invaluable for quickly loading a freshly-built kernel into RAM for testing. There's no need to write the kernel image to flash like when using SAM-BA to transfer kernel images.

Quote:
Accidentially we discovered that when autonegotiation is disabled for eth0, a link is established with 10Mbits but it is not possible to transmit or recieve packets.

Your ethtool diagnostic output does show only
    10baseT/Half
    10baseT/Full
    100baseT/Half
as the "supported" and "advertised" modes for eth0. But the interface reports that it's configured for 100Mb/s and full duplex. That's a discrepancy.

Regards


Top
 Profile  
 
 Post subject: Re: Ethernet problems on SAM9G20
PostPosted: Wed Aug 15, 2012 2:07 pm 
Offline

Joined: Fri Aug 10, 2012 4:22 pm
Posts: 5
Location: Switzerland
Hello blue_z, thanks for your reply
blue_z wrote:
zfr wrote:
During the boot process the interface is recognized and the Atmel MACB driver is loaded.

Considering that AT91 uses a multi-stage boot sequence, that's a broad statement.

In other words, you suggest that the problem might be in an earlier booting stage than the kernel?

blue_z wrote:
Getting networking functional in U-Boot is not wasted work. The tftp capability is invaluable for quickly loading a freshly-built kernel into RAM for testing. There's no need to write the kernel image to flash like when using SAM-BA to transfer kernel images.

The thing is that we are not using uboot or any external memories except SDRAM and microSD. The RomBoot loads the bootloader from SDcard which loads the kernel. There was some work neccessary but it works out. It might be possible to get the bootloader to load an uboot image instead of the kernel... I'll have a look at that.

blue_z wrote:
Your ethtool diagnostic output does show only
    10baseT/Half
    10baseT/Full
    100baseT/Half
as the "supported" and "advertised" modes for eth0. But the interface reports that it's configured for 100Mb/s and full duplex. That's a discrepancy.

Indeed. The 100Mb/s and full duplex seems to be some sort of default value. After setting the values to something else, like 10Mb/s-FD, it is no longer possible to set the interface to 100Mb/s-FD.

Regards
zfr


Top
 Profile  
 
 Post subject: Re: Ethernet problems on SAM9G20
PostPosted: Wed Aug 15, 2012 3:49 pm 
Offline

Joined: Sat Oct 30, 2010 6:04 pm
Posts: 877
I believe Blue's point is that you need to validate your hardware first outside Linux, either using uBoot or direct-to-metal, and then when you get that working apply that knowledge to the Linux kernel/drivers.


Top
 Profile  
 
 Post subject: Re: Ethernet problems on SAM9G20
PostPosted: Wed Aug 15, 2012 6:15 pm 
Offline

Joined: Fri Aug 10, 2012 4:22 pm
Posts: 5
Location: Switzerland
yeah, that's what i'm currently trying to do by getting uboot to work.
I will post an update regarding this in a while.


Top
 Profile  
 
 Post subject: Re: Ethernet problems on SAM9G20
PostPosted: Wed Aug 15, 2012 9:18 pm 
Offline

Joined: Thu Apr 19, 2007 10:15 pm
Posts: 702
Location: USA
zfr wrote:
The thing is that we are not using uboot


Then that might create a new possibility for the cause of your network issues. The Linux depends on U-Boot for some board setup as well as loading the kernel. But at least in the earlier days of AT91, the MAC and PHY had to be fully initialized by U-Boot if you wanted to use Ethernet in Linux. This dependency may have been unintentional. But it seemed as if the macb.c driver in Linux was not expecting the Ethernet HW to be in a full quiescent state, e.g. post-reset. At the very least the MAC address was expected by Linux to already be written to the HW. There is code in macb.c to "reset" & init the MAC and to write out the MAC address, but back in those days, I relied on U-Boot to initialize the Ethernet HW. Things could have changed for version 2.6.36.

Regards


Top
 Profile  
 
 Post subject: Re: Ethernet problems on SAM9G20
PostPosted: Wed Aug 15, 2012 11:33 pm 
Offline

Joined: Wed Feb 14, 2007 11:17 am
Posts: 96
Quote:
But at least in the earlier days of AT91, the MAC and PHY had to be fully initialized by U-Boot if you wanted to use Ethernet in Linux. This dependency may have been unintentional. But it seemed as if the macb.c driver in Linux was not expecting the Ethernet HW to be in a full quiescent state, e.g. post-reset.


Yes, it is due to the Ethernet phy that has not its inputs well configured just after power on reset: The "input + pull-up" default status of gpio on AT91 is the cause of that behavior. So, a new reset of the Ethernet phy is needed after having put the proper state on gpio that are going to drive this component.

I guess that a different set of pull-down resistors or a different Ethernet phy on a custom board can solve this kind of issue...
Another point: if you need to report this procedure in another bootloader than u-boot, it can be fairly easy.

Best regards,


Top
 Profile  
 
 Post subject: Re: Ethernet problems on SAM9G20
PostPosted: Thu Aug 16, 2012 12:42 am 
Offline

Joined: Fri Aug 10, 2012 4:22 pm
Posts: 5
Location: Switzerland
blue_z wrote:
it seemed as if the macb.c driver in Linux was not expecting the Ethernet HW to be in a full quiescent state, e.g. post-reset.

nferre wrote:
Yes, it is due to the Ethernet phy that has not its inputs well configured just after power on reset: The "input + pull-up" default status of gpio on AT91 is the cause of that behavior. So, a new reset of the Ethernet phy is needed after having put the proper state on gpio that are going to drive this component.


Thank you both for pointing this out as I wasn't aware that pre-linux initialization of the PHY is required. It indeed is quite likely that the bootloader is not correctly initializing the PHY.
We'll revise the bootloader where neccessary, I will let you know how it works.
If we can't get it to work with the Bootloader as it is now, would it be a difficult task to extract the routines that initialize the PHY from uboot?

best regards


Top
 Profile  
 
 Post subject: Re: Ethernet problems on SAM9G20
PostPosted: Thu Aug 16, 2012 4:50 am 
Offline

Joined: Thu Apr 19, 2007 10:15 pm
Posts: 702
Location: USA
zfr wrote:
If we can't get it to work with the Bootloader as it is now, would it be a difficult task to extract the routines that initialize the PHY from uboot?


[Since Nicolas hasn't responded yet, I'll give it a shot.]

There's probably no reason to add network initialization to your bootloader if it is intended to access only the SD card. Nicolas didn't write anything, but I've always assumed that the omitted initialization was an oversight rather than something deliberate or required. After all, it looks like a lot of the U-Boot initialization code is replicated in Linux code; if this Linux port really was to be dependent on U-Boot for some of the device initialization, then more of this startup code could have been omitted from Linux.

The U-Boot initialization code you probably have to inspect are the board module and the PHY driver (in your /board directory), and the MAC driver in the /cpu directory. If your PHY is significantly different from any existing driver, then you might be in for a challenge.

The Linux code for comparison is among the board's _devices file in /arch/arm/mach-at91, the MAC driver in /drivers, and the PHY driver in /drivers/phy. You probably have (or should have) custom board files, but the MAC driver is Atmel's for ARM and AVR32, and the PHY driver is generic (not arch specific) code. If you find the "missing" (PHY?) initialization you need, consider hacking them into your board's devices file.

Regards


Top
 Profile  
 
 Post subject: Re: Ethernet problems on SAM9G20
PostPosted: Sat Aug 18, 2012 11:10 pm 
Offline

Joined: Fri Aug 10, 2012 4:22 pm
Posts: 5
Location: Switzerland
Hello again
We managed to resolve our problem thanks to the explanations given by blue_z and nferre.
The bootloader was indeed the cause of our problems, we had to modify and rewrite portions of it to correctly reset/initialize our PHY and to assign it a MAC.
Now we get a 100Mbit-FD link and access to the network, which is nice but interesting as ethtool still thinks that 100 half duplex is the limit.
Thanks again and i guess this topic can be marked [solved]
regards


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: exyn and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: