2009-06-22 10:00:03     MAC address setting

Document created by Aaronwu Employee on Sep 24, 2013
Version 1Show Document
  • View in full screen mode

2009-06-22 10:00:03     MAC address setting

Tim Shearer (UNITED STATES)

Message: 76128   

 

Hi,

 

Using a cm-bf537e based board, with 2009R1 (toolchain and kernel).  I searched the forum for similar issues, but couldn't find a solution.

 

I'm having some difficulty seeing how u-boot passes the MAC address variable over to the kernel.  This arose because previously I was using an older issue of u-boot (2007R1), and I recently updated to 2009R1.

 

I have found that, if using the older u-boot, whatever value is stored in the env. variable ethaddr is successfully passed through to u-boot.  The network interface is always automatically configured with the correct MAC address.

 

U-boot appears to obtain the correct value of MAC during boot, but it's just not handed over in the same manner as the older release (correct MAC shown below).

 

 

U-Boot 2008.10-svn11276 (ADI-2009R1-rc2) (Jun 19 2009 - 17:42:00)

 

CPU:   ADSP bf537-0.2 (Detected Rev: 0.3) (bypass boot)

Board: Bluetechnix CM-BF537E board

       Support: http://www.bluetechnix.at/

Clock: VCO: 525 MHz, Core: 525 MHz, System: 131.250 MHz

RAM:   32 MB

Flash: Device ID of the Flash is 890016

Flash Memory Start 0x20000000

Memory Map for the Flash

0x20000000 - 0x203FFFFF Single Flash Chip (4MB)

Using PF4 as a 2M bank switch

Please type command flinfo for information on Sectors

4 MB

*** Note copy env from flash

In:    serial

Out:   serial

Err:   serial

Net:   ethernet initialisation

Blackfin EMAC

MAC:   00:19:A5:00:00:5D

Hit any key to stop autoboot:  0

 

 

However, using u-boot 2009R1 causes the following line to appear in the linux boot log:

arch/blackfin/mach-bf537/boards/cm_bf537.c:bfin_get_ether_addr: Setting Ethernet MAC to a random one

 

 

Plus, obviously, eth0 is configured with the wrong MAC address.

 

I can see that the MAC address config in u-boot has moved from the board.c file into the net driver, but I can't see any other significant changes.  I tried passing the mac address through the kernel command line (hwaddr=xx:xx:xx:xx:xx:) but no dice.

 

I'd be grateful for any suggestions!

 

Thanks,

 

Tim

QuoteReplyEditDelete

 

 

2009-06-22 10:04:59     Re: MAC address setting

Mike Frysinger (UNITED STATES)

Message: 76129   

 

please review the documentation:

http://www.denx.de/wiki/view/DULG/EthernetDoesNotWorkInLinux

QuoteReplyEditDelete

 

 

2009-06-22 10:14:44     Re: MAC address setting

Tim Shearer (UNITED STATES)

Message: 76132   

 

Woah, wish I knew that page was there at 4:00pm Friday!

 

I wasn't aware of this: "And U-Boot shall not touch any hardware it does not access itself. If you don't use the ethernet interface in U-Boot, it won't be initialized by U-Boot."

 

Thanks Mike,

 

Tim

QuoteReplyEditDelete

 

 

2009-06-22 10:18:36     Re: MAC address setting

Mike Frysinger (UNITED STATES)

Message: 76133   

 

if you choose to do it in the kernel, the Blackfin MAC driver under Linux has a bfin_get_ether_addr() call back.  for the cm-bf537, it simply generates a random MAC.  i guess we could fix it to try and fetch ethaddr from the u-boot env directly ...

 

it's defined in arch/blackfin/mach-bf537/boards/cm_bf537.c

QuoteReplyEditDelete

 

 

2009-06-22 15:10:05     Re: MAC address setting

Tim Shearer (UNITED STATES)

Message: 76146   

 

I found it was pretty straightforward to slightly hack u-boot so it initializes the MAC every time it boots, regardless of whether we use the network interface or not.

 

I added a call to bfin_EMAC_setup_addr(bd)  at the end of the bfin_EMAC_initialize() function in drivers/net/bfin_mac.c.

 

 

 

QuoteReplyEditDelete

 

 

2009-06-22 15:29:54     Re: MAC address setting

Mike Frysinger (UNITED STATES)

Message: 76147   

 

you shouldnt touch the driver.  if you want to use that kind of hack, do it in your board's board_eth_init() function.

QuoteReplyEditDelete

 

 

2009-07-01 16:51:19     Re: MAC address setting

Steve Strobel (UNITED STATES)

Message: 76607   

 

Mike Frysinger wrote:

> if you choose to do it in the kernel, the Blackfin MAC driver

> under Linux has a bfin_get_ether_addr() call back.  for the

> cm-bf537, it simply generates a random MAC.  i guess we could

> fix it to try and fetch ethaddr from the u-boot env directly ...

 

That would work well.  Is there already code to read the U-Boot environment from any of the various places it might be stored (parallel or SPI flash, etc)?

 

Tim Shearer wrote:

> I found it was pretty straightforward to slightly hack u-boot so

> it initializes the MAC every time it boots, regardless of whether

> we use the network interface or not.

>

> I added a call to bfin_EMAC_setup_addr(bd)  at the end of the

> bfin_EMAC_initialize() function in drivers/net/bfin_mac.c.

 

I originally tried to force U-Boot to set the MAC by doing a ping to a dummy address.  It worked when the system was started while connected to our LAN, but it caused (possibly unrelated) problems when the system was started with the ethernet cable unplugged.  So I, like you, hacked U-Boot to make it always set the MAC.

 

Mike Frysinger wrote:

> you shouldnt touch the driver.  if you want to use that kind of hack,

> do it in your board's board_eth_init() function.

 

The method I used to make U-Boot always set the MAC (done in function board_init_r() in board.c) is not very nice.  Ideally I think there would be a way to define a symbol in include/configs/my-target.h that would cause the MAC to always get set.  I understand that it might violate the "And U-Boot shall not touch any hardware it does not access itself. If you don't use the ethernet interface in U-Boot, it won't be initialized by U-Boot." principle documented at http://www.denx.de/wiki/view/DULG/EthernetDoesNotWorkInLinux, but it would be better than each of us hacking U-Boot in a different way.

 

Steve

 

 

P.S.  You can find some related discussion in the forum archives at

 

http://blackfin.uclinux.org/gf/project/u-boot/forum/?action=ForumBrowse&forum_id=51&_forum_action=ForumMessageBrowse&thread_id=25626

 

and

 

http://blackfin.uclinux.org/gf/project/u-boot/forum/?action=ForumBrowse&forum_id=51&_forum_sort_by=most_recent_date&_forum_sort_order=desc&_forum_action=ForumMessageBrowse&thread_id=23849

QuoteReplyEditDelete

 

 

2009-10-30 16:01:33     Re: MAC address setting

Øyvind Kaurstad (NORWAY)

Message: 81922   

 

I've run into the same issue, and I find it quite annoying. While I can understand why the u-boot maintainers want to leave any "unused" hardware untouched, I can also understand the kernel people who wants the mac address pre-programmed into the hardware when the kernel boots.

 

I would rather have this done by u-boot, and I don't mind adding a hack to my own board specific code. The obvious choice is to call the bfin_EMAC_setup_addr-function from my board init code, but for some reason that function is declared as static in the driver header file (but not in the c-file), so to make that function accessible I would have to "hack" the driver anyway to remove the static declaration. Why is the function prototype different in the header filer? Is this intentional?

 

I could of course just write the registers myself, but using the aforementioned function feels more "correct", in a sense.

 

I'm using the 2009R1-RC3 version of u-boot, btw.

 

Regards

 

-Øyvind

QuoteReplyEditDelete

 

 

2009-10-30 16:23:41     Re: MAC address setting

Mike Frysinger (UNITED STATES)

Message: 81923   

 

the static has already been removed in newer versions

Attachments

    Outcomes