2009-02-16 02:19:49     Setting uClinux MAC automatically

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

2009-02-16 02:19:49     Setting uClinux MAC automatically

Patrick Hotz (GERMANY)

Message: 69474   


Good morning Guys,


i have just startet my Blackfin-board and there i have seen that the uClinux-MAC is not the same as the u-boot-MAC......

In my board-config-file i have seen that the MAC is random-generated on booting.


Is there a way to take the u-boot-MAC in uClinux??

How i can make this?




Best Regards,





2009-02-16 03:23:29     Re: Setting uClinux MAC automatically

Mike Frysinger (UNITED STATES)

Message: 69476   


what board exactly are you using




2009-02-16 03:42:50     Re: Setting uClinux MAC automatically

Patrick Hotz (GERMANY)

Message: 69477   




i use a custom board with a TCM-BF537 Coremodul and a Micrel Network-Chip.

The Network-Driver is the "on-chip Ethernet MAC Driver"


U-Boot is 1.1.3 and uCLinux is 2008R1.5








2009-02-16 10:57:31     Re: Setting uClinux MAC automatically

Rob Maris (GERMANY)

Message: 69482   


Hi Patrick,


probably I can help you. With your help I could arrange the TCM board for mapping the full 8M flash. With respect to eth0, I believe there is no special thing to consider. No specific PHY chip must be selected. It was a few days ago that I got it working. However, I believed to remember that there was a generic MII interface checkbox. At this time, upon recalling how I did it, there is nothing like that.


BTW: under device drivers->network device support, I found thernet 1000 Mbit and 10000 Mbit  checked, while 10/100 Mbit was unchecked. I reversed these presets.


Within 10/100 Mbit, I set the appropriate sub-presets (Blackfin on chip MAC support).


When you don't make advances, I'll dig again in my settings.




2009-02-16 11:45:17     Re: Setting uClinux MAC automatically

Rob Maris (GERMANY)

Message: 69483   


as to complete my first reply:

A boot log excerpt, showing "generic PHY"

bfin_mii_bus: probed

bfin_mac: attached PHY driver [Generic PHY] (mii_bus:phy_addr=0:01, irq=-1,


bfin_mac bfin_mac.0: Blackfin on-chip Ethernet MAC driver, Version 1.1




2009-02-16 13:52:27     Re: Setting uClinux MAC automatically

Mike Frysinger (UNITED STATES)

Message: 69487   


i dont really know how the tcm port operted in u-boot-1.1.3.  what you could do is something like:

- use setenv() in the board-specific misc_init_r() function to set the "ethaddr" env var (if it isnt already set)

- update the envvars that get passed to the kernel by doing something like ethaddr=$(ethaddr)

- in the board-specific init function in the kernel, parse the kernel command line and use that to set the mac address


with the next release, this process should be much easier in that the mac can be read via /proc/cmdline and changed via userspace




2009-02-16 18:54:18     Re: Setting uClinux MAC automatically

Steve Strobel (UNITED STATES)

Message: 69492   


It is possible. It seems to me that the cleanest method is for uClinux to read the Blackfin's setup register for the MAC address and use that value if it passes a sanity check. If the sanity check fails, it could try to get the MAC from somewhere else (probably a target-specific thing) or make up a random one. We store the MAC in U-Boot's environment ("set ethaddr xx:xx:xx:xx:xx:xx" then "save").


One challenge I ran into when trying to make it work that way a couple of years ago was that U-Boot didn't set up the Blackfin's MAC address unless you tried to do some kind of network operation (like a ping), but doing a ping with the network cable unplugged caused problems. I think I patched U-Boot to make it set up the MAC register on every startup; that may be standard in more recent versions. I can't remember if I had to patch uClinux or not. I will email a copy of my notes on the issue to you directly in case they have other info that might help.






2009-02-16 19:25:35     Re: Setting uClinux MAC automatically

Mike Frysinger (UNITED STATES)

Message: 69493   


the standard u-boot is settling on is:

- environment is the canonical location

- boards will make sure environment is sane

- no network hardware will be touched unless a network operation is started


so if you want to set the MAC under Linux to match u-boot, you can do what i outlined in the other thread (kernel command line and then parse that either from userspace or board init)




2009-02-17 01:58:09     Re: Setting uClinux MAC automatically

Patrick Hotz (GERMANY)

Message: 69498   


Hi Guys,


thank you very much for your help.

I will try it today and reply if it works....


Have a nice day,