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.

Not able to pass MAC address from uboot to kernel

Other Parts Discussed in Thread: PMP

On DM816x i am trying to pass the MAC address to the kernel.

On uboot i modified the MAC address, now i want to pass that MAC address to linux kernel eth0 interface, but linux kernel always takes the MAC address which is not passed by uboot. How exactly i can do that?

I tried following bootargs, after loading the kernel image and ramdisk at particular location

TI8168_EVM# setenv ethaddr 02:01:03:01:01:01

TI8168_EVM#setenv bootargs 'console=ttyO0,115200n8 root=/dev/ram rw initrd=0x81000000,128M  eth=$(ethaddr) mem=512M'

TI8168_EVM#setenv bootcmd 'bootm 0x80800000'

after booting linux, when i run ifconfig, it is not showing different MAC address of eth0

Would somebody please suggest, how to fix this..

  • Hi Saurin,

    From the above steps every thing looks ok. Try saving it (saveenv) and reset and issue print ethaddr at

    u-boot prompt and see that you get the same MAC address. Refer this link for setting MAC address.

    Thx,

    --Prabhakar Lad

  • Hi Prabhakar,

    thanks for your reply,

    Please note that we are using PCIe boot, we don't have any flash connected in our custom Netra board. so saveenv will not have any effect, we are getting MAC address in OCMC memory from PCIe Rootcomplex. and that MAC address is used in setting ethaddr environment variable, when we pass ethaddr to kernel via bootargs, kernel override the MAC address.

    Regards,

    Saurin

  • Hi Saurin,

    Ok. Can you print the bootlog, when linux comes up it prints the command line can you check

    that if it is the same as what you passed?

    Thx,

    --Prabhakar Lad

  • Hi Prabhakar,

    From Linux kernel i kept printk for MAC address printing, it prints the different MAC address(Not the MAC address we passed from uboot), however in booting log i can see that MAC address passed properly with bootargs, but when ethernet driver initialize it prints the differnt mac address

    -Saurin

  • Hi Saurin,

    So looks like the ethernet driver is not taking the MAC address from bootargs. So you need to look

    at the ethernet driver and see from it does it take the MAC address.

    Thx,

    --Prabhakar Lad

  • Hi Saurin,

    Can you provide your environment variables and bootlog with "ifconfig from console"

    Regards

    AnilKumar

    Please mark this Forum post as answered via the Verify Answer button below if it helps answer your question.  Thanks!

  • Hi Anil,

    Here is the detail

    TI8168#printenv
    bootdelay=3
    baudrate=115200
    autoload=no
    verify=yes
    addip=setenv bootargs ${bootargs} ip=${ipaddr}:${nfsserver}:${gatewayip}:${subnetmask}:${hostname}:eth0:off eth=${ethaddr}
    ethaddr=02:01:03:01:01:01
    ethact=DaVinci EMAC
    ipaddr=10.194.58.86
    gatewayip=10.194.58.1
    subnetmask=255.255.255.0
    serverip=10.194.58.126
    ncip=10.194.58.126
    bootargs=console=ttyO0,115200n8 root=/dev/ram rw initrd=0x81000000,128M mem=512M
    bootcmd=setenv hostname cloverdale;tftp 0x80800000 uImage; tftp 0x81000000 128mb.gz;run addip; bootm 0x80800000
    ver=U-Boot 2010.06 (May 20 2012 - 23:50:46)

    Environment size: 839/8188 bytes


    TI8168#boot                     

    ## Booting kernel from Legacy Image at 80800000 ...
       Image Name:   Linux-2.6.37
       Image Type:   ARM Linux Kernel Image (uncompressed)
       Data Size:    2259424 Bytes = 2.2 MiB
       Load Address: 80008000
       Entry Point:  80008000
       Verifying Checksum ... OK
       Loading Kernel Image ... OK
    OK

    Starting kernel ...

    Linux version 2.6.37 (root@netradev-desktop) (gcc version 4.3.3 (Sourcery G++ Lite 2009q1-203) ) #27 Tue May 22 00:00:52 PDT 2012
    CPU: ARMv7 Processor [413fc082] revision 2 (ARMv7), cr=10c53c7f
    CPU: VIPT nonaliasing data cache, VIPT aliasing instruction cache
    Machine: ti8168evm
    reserved size = 0 at 0
    Memory policy: ECC disabled, Data cache writeback
    OMAP chip is TI8168 1.1
    Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 130048
    Kernel command line: console=ttyO0,115200n8 root=/dev/ram rw initrd=0x81000000,128M mem=512M ip=10.194.58.86::10.194.58.1:255.255.255.0:cloverdale:eth0:off eth=02:01:03:01:01:01
    PID hash table entries: 2048 (order: 1, 8192 bytes)
    Dentry cache hash table entries: 65536 (order: 6, 262144 bytes)
    Inode-cache hash table entries: 32768 (order: 5, 131072 bytes)
    Memory: 512MB = 512MB total
    Memory: 383840k/383840k available, 140448k reserved, 0K highmem
    Virtual kernel memory layout:
        vector  : 0xffff0000 - 0xffff1000   (   4 kB)
        fixmap  : 0xfff00000 - 0xfffe0000   ( 896 kB)
        DMA     : 0xffc00000 - 0xffe00000   (   2 MB)
        vmalloc : 0xe0800000 - 0xf8000000   ( 376 MB)
        lowmem  : 0xc0000000 - 0xe0000000   ( 512 MB)
        modules : 0xbf000000 - 0xc0000000   (  16 MB)
          .init : 0xc0008000 - 0xc0034000   ( 176 kB)
          .text : 0xc0034000 - 0xc0447000   (4172 kB)
          .data : 0xc0448000 - 0xc0485920   ( 247 kB)
    SLUB: Genslabs=11, HWalign=64, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
    NR_IRQS:407
    IRQ: Found an INTC at 0xfa200000 (revision 5.0) with 128 interrupts
    Total of 128 interrupts on 1 active controller
    GPMC revision 6.0
    Trying to install interrupt handler for IRQ400
    Trying to install interrupt handler for IRQ401
    Trying to install interrupt handler for IRQ402
    Trying to install interrupt handler for IRQ403
    Trying to install interrupt handler for IRQ404
    Trying to install interrupt handler for IRQ405
    Trying to install interrupt handler for IRQ406
    Trying to install type control for IRQ407
    Trying to set irq flags for IRQ407
    OMAP clockevent source: GPTIMER1 at 27000000 Hz
    Console: colour dummy device 80x30
    Calibrating delay loop... 986.31 BogoMIPS (lpj=4931584)
    pid_max: default: 32768 minimum: 301
    Security Framework initialized
    Mount-cache hash table entries: 512
    CPU: Testing write buffer coherency: ok
    devtmpfs: initialized
    omap_voltage_early_init: voltage driver support not added
    regulator: core version 0.5
    regulator: dummy:
    NET: Registered protocol family 16
    OMAP GPIO hardware version 0.1
    OMAP GPIO hardware version 0.1
    omap_mux_init: Add partition: #1: core, flags: 0
    _omap_mux_get_by_name: Could not find signal i2c2_scl.i2c2_scl
    _omap_mux_get_by_name: Could not find signal i2c2_sda.i2c2_sda
    registered ti816x_vpss device
    pm_dbg_init: only OMAP3 supported
    Registered ti81xx_fb device
    ti816x_pcie: Invoking PCI BIOS...
    ti816x_pcie: Setting up Host Controller...
    ti816x_pcie: Register base mapped @0xe0820000
    ti816x_pcie: Starting PCI scan...
    PCI: bus0: Fast back to back transfers disabled
    PCI: bus1: Fast back to back transfers enabled
    pci 0000:00:00.0: PCI bridge to [bus 01-01]
    pci 0000:00:00.0:   bridge window [io  disabled]
    pci 0000:00:00.0:   bridge window [mem disabled]
    pci 0000:00:00.0:   bridge window [mem pref disabled]
    PCI: enabling device 0000:00:00.0 (0142 -> 0143)
    bio: create slab <bio-0> at 0
    vgaarb: loaded
    SCSI subsystem initialized
    usbcore: registered new interface driver usbfs
    usbcore: registered new interface driver hub
    usbcore: registered new device driver usb
    omap_i2c omap_i2c.1: bus 1 rev4.0 at 100 kHz
    omap_i2c omap_i2c.2: bus 2 rev4.0 at 100 kHz
    Advanced Linux Sound Architecture Driver Version 1.0.23.
    Switching to clocksource gp timer
    musb-hdrc: version 6.0, host, debug=0
    musb-hdrc musb-hdrc.0: dma type: dma-cppi41
    registerd cppi-dma Intr @ IRQ 17
    Cppi41 Init Done
    musb-hdrc: kernel must blacklist external hubs
    musb-hdrc musb-hdrc.0: MUSB HDRC host driver
    musb-hdrc musb-hdrc.0: new USB bus registered, assigned bus number 1
    usb usb1: New USB device found, idVendor=1d6b, idProduct=0002
    usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
    usb usb1: Product: MUSB HDRC host driver
    usb usb1: Manufacturer: Linux 2.6.37 musb-hcd
    usb usb1: SerialNumber: musb-hdrc.0
    hub 1-0:1.0: USB hub found
    hub 1-0:1.0: 1 port detected
    musb-hdrc musb-hdrc.0: USB Host mode controller at e080c000 using DMA, IRQ 18
    musb-hdrc musb-hdrc.1: dma type: dma-cppi41
    musb-hdrc: kernel must blacklist external hubs
    musb-hdrc musb-hdrc.1: MUSB HDRC host driver
    musb-hdrc musb-hdrc.1: new USB bus registered, assigned bus number 2
    usb usb2: New USB device found, idVendor=1d6b, idProduct=0002
    usb usb2: New USB device strings: Mfr=3, Product=2, SerialNumber=1
    usb usb2: Product: MUSB HDRC host driver
    usb usb2: Manufacturer: Linux 2.6.37 musb-hcd
    usb usb2: SerialNumber: musb-hdrc.1
    hub 2-0:1.0: USB hub found
    hub 2-0:1.0: 1 port detected
    musb-hdrc musb-hdrc.1: USB Host mode controller at e081e800 using DMA, IRQ 19
    NET: Registered protocol family 2
    IP route cache hash table entries: 4096 (order: 2, 16384 bytes)
    TCP established hash table entries: 16384 (order: 5, 131072 bytes)
    TCP bind hash table entries: 16384 (order: 4, 65536 bytes)
    TCP: Hash tables configured (established 16384 bind 16384)
    TCP reno registered
    UDP hash table entries: 256 (order: 0, 4096 bytes)
    UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
    NET: Registered protocol family 1
    RPC: Registered udp transport module.
    RPC: Registered tcp transport module.
    RPC: Registered tcp NFSv4.1 backchannel transport module.
    Trying to unpack rootfs image as initramfs...
    rootfs image is not initramfs (no cpio magic); looks like an initrd
    Freeing initrd memory: 131072K
    NetWinder Floating Point Emulator V0.97 (double precision)
    sr1_fck HVT rate = 125000000
    sr2_fck SVT rate = 125000000
    SR NTarget value for HVT 0x998390
    SR NTarget value for SVT 0xaabbd6
    SmartReflex Driver initialized
    omap-iommu omap-iommu.0: ducati registered
    omap-iommu omap-iommu.1: sys registered
    msgmni has been set to 1005
    io scheduler noop registered
    io scheduler deadline registered
    io scheduler cfq registered (default)
    Serial: 8250/16550 driver, 4 ports, IRQ sharing enabled
    omap_uart.0: ttyO0 at MMIO 0x48020000 (irq = 72) is a OMAP UART0
    console [ttyO0] enabled
    omap_uart.1: ttyO1 at MMIO 0x48022000 (irq = 73) is a OMAP UART1
    omap_uart.2: ttyO2 at MMIO 0x48024000 (irq = 74) is a OMAP UART2
    brd: module loaded
    loop: module loaded
    ahci ahci.0: forcing PORTS_IMPL to 0x3
    ahci ahci.0: AHCI 0001.0100 32 slots 2 ports 3 Gbps 0x3 impl platform mode
    ahci ahci.0: flags: ncq sntf pm led clo only pmp pio slum part ccc
    scsi0 : ahci_platform
    scsi1 : ahci_platform
    ata1: SATA max UDMA/133 mmio [mem 0x4a140000-0x4a150fff] port 0x100 irq 16
    ata2: SATA max UDMA/133 mmio [mem 0x4a140000-0x4a150fff] port 0x180 irq 16
    usbcore: registered new interface driver cdc_ether
    usbcore: registered new interface driver dm9601
    Initializing USB Mass Storage driver...
    usbcore: registered new interface driver usb-storage
    USB Mass Storage support registered.
    mice: PS/2 mouse device common for all mice
    i2c /dev entries driver
    Linux video capture interface: v2.00
    usbcore: registered new interface driver uvcvideo
    USB Video Class driver (v1.0.0)
    OMAP Watchdog Timer Rev 0x00: initial timeout 60 sec
    PSTATE 1ff0000
    usbcore: registered new interface driver usbhid
    usbhid: USB HID core driver
    usbcore: registered new interface driver snd-usb-audio
    1-0018 supply IOVDD not found, using dummy regulator
    1-0018 supply DVDD not found, using dummy regulator
    1-0018 supply AVDD not found, using dummy regulator
    1-0018 supply DRVDD not found, using dummy regulator
    asoc: tlv320aic3x-hifi <-> davinci-mcasp.2 mapping ok
    ALSA device list:
      #0: TI81XX EVM
    TCP cubic registered
    NET: Registered protocol family 17
    VFP support v0.3: implementor 41 architecture 3 part 30 variant c rev 3
    omap_voltage_late_init: Voltage driver support not added
    ata2: SATA link down (SStatus 0 SControl 300)
    ata1: SATA link down (SStatus 0 SControl 300)
    net eth0: no phy, defaulting to 1000/full
         host=cloverdale, domain=, nis-domain=(none),
         bootserver=255.255.255.255, rootserver=255.255.255.255, rootpath=
    RAMDISK: gzip image found at block 0
    VFS: Mounted root (ext2 filesystem) on device 1:0.
    devtmpfs: mounted
    Freeing init memory: 176K
    INIT: version 2.86 booting
    Starting udev
    udevd (51): /proc/51/oom_adj is deprecated, please use /proc/51/oom_score_adj instead.
    Remounting root file system...
    Caching udev devnodes
    Populating dev cachemv: cannot rename '/tmp/devices': No such file or directory
    logger: mount: mounting tmpfs on /media/ram failed: No such file or directory
    ALSA: Restoring mixer settings...
    hwclock: can't open '/dev/misc/rtc': No such file or directory
    Wed Apr  6 00:18:00 UTC 2011
    hwclock: can't open '/dev/misc/rtc': No such file or directory
    INIT: Entering runlevel: 5
    Starting system message bus: dbus.
    Starting telnet daemon.
    Starting syslogd/klogd: done

     _____                    _____           _         _
    |  _  |___ ___ ___ ___   |  _  |___ ___  |_|___ ___| |_
    |     |  _| .'| . | . |  |   __|  _| . | | | -_|  _|  _|
    |__|__|_| |__,|_  |___|  |__|  |_| |___|_| |___|___|_|
                  |___|                    |___|

    Arago Project http://arago-project.org dm816x-evm ttyO0

    Arago 2011.02 dm816x-evm ttyO0

    dm816x-evm login: root
    root@dm816x-evm:~# ifconfig
    eth0      Link encap:Ethernet  HWaddr 40:5F:C2:71:9B:7C
              inet addr:10.194.58.86  Bcast:10.194.58.255  Mask:255.255.255.0
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              RX packets:14 errors:0 dropped:0 overruns:0 frame:0
              TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:1000
              RX bytes:1483 (1.4 KiB)  TX bytes:0 (0.0 B)
              Interrupt:40

    lo        Link encap:Local Loopback
              inet addr:127.0.0.1  Mask:255.0.0.0
              UP LOOPBACK RUNNING  MTU:16436  Metric:1
              RX packets:0 errors:0 dropped:0 overruns:0 frame:0
              TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:0
              RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
    root@dm816x-evm:~#

  • I don't think the "eth=" kernel command line parameter is standard Linux. I can't find support for it in the Arago Linux SCBP git. Did you add support for it? Grep for a __setup() call that takes an "eth" argument. As coded, the mac address is read from the control registers in devices.c.

  • Hi

    "eth=" command line argument is depreciated from the standard Linux kernel.

    Mac address reading logic is done in the arch/arm/mach-omap2/devices.c file. This logic can be modified to have custom mac id from eeprom or i2c so that custom mac id is used in kernel emac driver.

    with regards

    Mugunthan V N

  • Hi,

    As suggested, i applied patch in drivers/net/davinci_emac.c for getting "eth=" argument.

    Thanks for helping me.

    Regards,

    Saurin

  • Hi,

    I have similar issue, My card doesn't have a EEPROM. I cannot read the EEPROM for MAC address in kernel.

    Can you show me your patch? I am new about how the kernel get argument from the boot command line.

    Thank you in advance!

    Jin

  • Jin

    You can refer to the file in the below link and implement the same for adding MAC address in Driver
    http://lxr.linux.no/#linux+v3.5.4/net/ipv4/ipconfig.c#L1624

    Regards
    Mugunthan V N

  • Thanks a lot!

    Jin

  • Hi,

    I have similar issue with TCI6614 platform. I plan to pass MAC address from uboot to the kernel. Could you post the patch here?

    Regards

    Shailender

  • Hi Shailender,

    I fixed using following patch.

    drivers/net/davinci_emac.c
    @@ -59,11 +59,13 @@
    +#include <linux/string.h>
    @
    @ -1787,6 +1805,12 @@
            struct device *emac_dev;
            struct cpdma_params dma_params;
     
    +      unsigned char addr[6];
    +      char *ptr = NULL;
    +      char *ptr_end;
    +      char eth[17];
    +      Int mac_byte_counter;
     
    @@ -1818,7 +1842,23 @@
          
            /* MAC addr and PHY mask , RMII enable info from platform_data */
    -       memcpy(priv->mac_addr, pdata->mac_addr, 6);
    +
    +      ptr = strstr(boot_command_line, "eth=");
    +      if (ptr) {
    +       memcpy(eth, ptr + 4, 17 * sizeof(char));
    +       printk(KERN_NOTICE "ethaddr parsed from commandline: %s\n", eth);
    +       ptr_end = eth;
    +       for (mac_byte_counter = 0; mac_byte_counter <= 5; mac_byte_counter ++) {
    +               addr[mac_byte_counter] = simple_strtol(ptr_end, &ptr_end, 16) | simple_strtol(ptr_end, &ptr_end, 16) << 4;
    +               ptr_end++; /* skip ":" in  eth*/
    +              }
    +     }
    +memcpy(priv->mac_addr, addr, sizeof(addr));
    +memcpy(pdata->mac_addr, addr, sizeof(addr));