This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Static MAC address for eth0 on OMAP-L138

Other Parts Discussed in Thread: OMAP-L138, OMAPL138

Hello everybody,

I'm using the OMAP-L138 experimenter kit and everytime I reboot the board, the MAC address changes. The LAN I am connected is protected and they need to know the MAC to give access to the net.

It's really extrange because before start booting linux, the variable ethaddr is the correct one:

U-Boot 2009.01 (Jul 30 2009 - 11:58:01)                                  
                                                                         
DRAM:  64 MB                                                             
In:    serial                                                            
Out:   serial                                                            
Err:   serial                                                            
ARM Clock : 300000000 Hz                                                 
DDR Clock : 300000000 Hz                                                 
Ethernet PHY: GENERIC @ 0x00                                             
Hit any key to stop autoboot:  0                                         
U-Boot > printenv                                                        
bootdelay=3                                                              
baudrate=115200                                                                
bootfile="uImage"                                                              
ethaddr=00:08:ee:03:XX:XX                                                      
bootargs=mem=32M console=ttyS2,115200n8 root=/dev/ram0 rw initrd=0xc1180000,4M f
bootcmd=sf probe 0;sf read 0xc0700000 0x80000 0x200000;sf read 0xc1180000 0x2800
stdin=serial                                                                   
stdout=serial                                                                  
stderr=serial                                                                  
ver=U-Boot 2009.01 (Jul 30 2009 - 11:58:01)                                    
                                                                               
Environment size: 352/65532 bytes                                              
U-Boot >

After booting, I found this with a dmesg:

davinci_emac_probe: using random MAC addr: e6:8f:ef:e6:cb:fd                   
emac-mii: probed

Someone knows what I have to change to set the same MAC address every time I reboot the board?

Thanks in advance.

  • On OMAP-L139 MAC address is stored in the last sector of the SPI flash. It seems that U-Boot is reading the MAC address properly, but, the Linux kernel you are using may not have the support to read the MAC address. You will need https://patchwork.kernel.org/patch/110999/ patch for this. Please note that this patch may not directly apply on the Linux kernel you have.

    Regards, Sudhakar

  • I am also seeing the situation wherein U-Boot reads the MAC from flash but the Linux kernel generates a random one.  (I'm using an OMAP-L138 eXperimenter board.)  But the kernel patch is already applied -- that is, mtd_macc_read() is already present in mtdpart.c, etc.  (I'm using linux-03.20.00.11, which appears to be 2.6.33-rc4.) Right now I can set a fixed addr via ip= in bootargs, but I'll need to use dhcp for our real product boards.  Where else can I check to start determining why the kernel isn't reading the MAC address properly?

    Thank you,

    David E Hollingsworth

  • This happens when MAC address is not present in the SPI flash. U-Boot also may not be reading it. You might have set it once from U-Boot using setenv command and later on that env variable becomes read-only from U-Boot. Try writing the MAC address to last sector of SPI flash. This may solve your problem.

    - Sudhakar

  • It would make sense that U-Boot could be reading a saved setenv for ethaddr, but I believe my SPI flash contains the MAC addr (see below).  This is why I think the kernel isn't reading it; but 'objdump -t vmlinux | grep mtd_macc_read' (on the cross-compiling host) shows it present, so I'm sure the patched source is being used.  Is there something else I can check or do I need to use kgdb to figure this out?

    Thank you,

    David

    U-Boot 2009.01 (Sep 17 2009 - 17:41:56)

    I2C:   ready
    DRAM:  64 MB
    In:    serial
    Out:   serial
    Err:   serial
    ARM Clock : 300000000 Hz
    DDR Clock : 150000000 Hz
    Net:   Ethernet PHY: GENERIC @ 0x00

    Hit any key to stop autoboot:  0
    U-Boot > printenv ethaddr
    ethaddr=00:08:ee:03:d6:ca
    U-Boot > sf probe 0
    8192 KiB M25P64 at 0:0 is now current device
    U-Boot > md.b c0000000 10
    c0000000: 00 12 04 1b 00 22 44 20 68 20 08 b0 c0 31 00 00    ....."D h ...1..
    U-Boot > sf read c0000000 7f0000 10000
    U-Boot > md.b c0000000 10            
    c0000000: 00 08 ee 03 d6 ca ff ff ff ff ff ff ff ff ff ff    ................
    U-Boot >

  • I assume that you have not done any modifications to the 03.20.00.11 release which you are using. Please make sure that you are configuring the kernel using da850_omapl138_defconfig. If you have already done all of this, then I think you need kgdb to debug the issue.

    Regards, Sudhakar

  • I'm having issues with this as well.  How does is the Ethernet MAC address supposed to end up in the SPI Flash "MAC Address" partition?  Is there a U-Boot command I'm not aware of?  Saveenv does not seem to do it.  I have a EEPROM for the MAC address.  I changed the code in U-Boot to read the MAC Address from EEPROM instead of from SPI Flash - I guess I could program the SPI Flash at that point, but that would assume that the location in Linux is not based on the size of the SPI Flash (but it looks like the partition sizes are hard-coded in board-da850-evm.c in static struct mtd_partition spi_flash_partitions).

    The code that reads the MAC Address in Linux is not easy to follow:  it's next to impossible to see where things are declared and initialized without a lot of effort.  Using dump_stack() for example does not show that part->setup(&slave->macc, (void *)part->context) in mtdpart.c calls davinci_get_mac_addr() because davinci_get_mac_addr is in struct mtd_partition_spi_flash_partitions[] under "MAC Address" in board-da850-evm.c. So the text message in:

    pr_info("Read MAC addr from EEPROM: %pM\n", mac_addr); (in common.c)

    Is not correct - it's reading from the MAC Address partition in SPI Flash (offset 0 in the MAC Address partition), which is not initialized as noted above.  I see two possible solutions:

    1.  Change U-Boot to write to the SPI Flash MAC Address partition.  Not a good option if the SPI Flash size is changed - both u-Boot and board-da850-evm.c would have to be kept in sync.

    2.  Change davinci_get_mac_addr() in common.c to actually read from the EEPROM and not SPI Flash, and write to the SPI Flash MAC Address partition if they are not the same (that way the change is contained entirely in davinci_get_mac_addr()).

    I think #2 is better, unless, as I've mentioned, U-Boot has automated commands to write the MAC address in the correct place in SPI Flash.  If not, can you point me to examples of how to read from EEPROM in Linux?  I looked at this, but not all of the header files are in 03.20.00.12:

    http://e2e.ti.com/support/dsp/omap_applications_processors/f/42/p/31158/108461.aspx

    Missing header files are <sys/ioctl.h> and <asm/arch-davinci/i2c.h>.