element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      • Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Vietnam
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Avnet Boards Forums
  • Products
  • Dev Tools
  • Avnet & Tria Boards Community
  • Avnet Boards Forums
  • More
  • Cancel
Avnet Boards Forums
Avnet Boards General Passing MAC address to kernel via Device Tree Blob
  • Forum
  • Documents
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Avnet Boards Forums to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Not Answered
  • Replies 7 replies
  • Subscribers 353 subscribers
  • Views 8983 views
  • Users 0 members are here
Related

Passing MAC address to kernel via Device Tree Blob

Former Member
Former Member over 12 years ago

Good morning everyone,

in our lab, we have several ZedBoards of which some obtain an IP address from a DHCP server based on their MAC address and some of them use a fixed IP address (no DHCP).

Based on my experience with other embedded Linux boards, the straight forward solution to achieve this would be to generate an individual device tree source (DTS) file for each board containing
- the specific MAC address and
- the specific boot arguments for the kernel to either turn on DHCP or to assign a specific fixed IP address.

According to the Embedded Linux Hands-on Tutorial and the Embedded Linux Development Guide, it is recommended to set the MAC address of the ethernet port of the ZedBoard via U-Boot (zynq_zed.h). However, it is also mentioned that the MAC address can be set via DTS file. To do so, the MAC address assignment in the U-Boot configuration needs to be deleted.

Now to my problem:
If I now boot the ZedBoard with such a configuration, the MAC address of the system differs from the address specified in the DTS file. More precisely, the first 4 Bytes are equal to the specified address but the last 2 Bytes are always zero.
Example:
AA:BB:CC:DD:11:FF -> AA:BB:CC:DD:00:00

If the MAC address is set via U-Boot, everything is fine. Except that I then need to generate both a specific BOOT.BIN (containing the U-Boot) and a DTS file for each board.

I think that there is an error in how the MAC address is passed from the DTS to the driver (xemacps). Does anyone of you have an idea how to fix that?

Best regards,

Pirmin

  • Sign in to reply
  • Cancel
Parents
  • zedhed
    0 zedhed over 10 years ago

    Hi Pirmin,

    Sorry for bringing up an old thread, but this one took me a while to find an answer for and I just happened to come back across this thread while looking for another one. I wanted to post this information for the rest of the community in case anyone stumbled across this thread again.

    In short, a modern U-Boot overwrites the local-mac-address = [00 0a 35 00 00 00]; property of your device tree after it gets loaded into memory. The value that it is overwritten with comes from the U-Boot ethaddr=00:0a:35:00:01:22 environment variable.

    This is also confirmed in this forum post here:

    http://forums.xilinx.com/t5/Embedded-Linux/Perm-changing-the-MAC-address/td-p/61463

    Now for the long version and how to prove that this happens:

    All of this can be observed if you boot a more recent OSL release like the 2014.4 found on this page:

    http://www.wiki.xilinx.com/Zynq+2014.4+Release

    Download the Xilinx 2014.4 Linux release and copy the zedboard files to an sd card, boot ZedBoard to U-Boot prompt, run the following command:

    zynq-uboot> printenv ethaddr ethaddr=00:0a:35:00:01:22 

    Take a peek inside of the devicetree.dts file, and see the following:

    local-mac-address = [00 0a 35 00 00 00]; 

    Boot ZedBoard all the way into Linux and then run ifconfig command:

    # ifconfig eth0
    
    …
    
    Hwaddr 00:0a:35:00:01:22
    
    …

    So this demonstrates, in this case, that U-Boot uses its own environment variable to override the devicetree setting.

    Now for the extra long version:

    You can prove that this happens by going into U-Boot source code and adding some additional print statements to see what is going on.

    To test this out, I made some additional prints to u-boot source code and rebuilt:

    In u-boot-xlnx/common/fdt_support.c: fdt_fixup_ethernet() added a few lines around here:

     

    // Debug stuff to demonstrate whether device tree is touched or not.
    
    printf("\n");
    
    printf("DEBUG: common/fdt_support.c:fdt_fixup_ethernet()\n");
    
    printf("DEBUG: Modifying the device tree that is loaded into memory\n");
    
    printf("\n");
    
    
    
    sprintf(mac, "eth%daddr", ++i);

     

    Fired this up on my ZedBoard and sure enough, here is what I see in the terminal:

     

    ## Flattened Device Tree blob at 02000000
    
       Booting using the fdt blob at 0x2000000
    
       Loading Kernel Image ... OK
    
       Loading Ramdisk to 1e793000, end 1ed23d29 ... OK
    
       Loading Device Tree to 1e78d000, end 1e7923de ... OK
    
    
    
    DEBUG: common/fdt_support.c:fdt_fixup_ethernet()
    
    DEBUG: Modifying the device tree that is loaded into memory
    
    DEBUG: About to fix up mac address in device tree node: /amba/ethernet@e000b000
    
    DEBUG: Device tree node modified to MAC address 00 0A 35 00 01 22
    
    
    Starting kernel ...

     

    Hopefully this clears up where the MAC address comes from.

    Regards,

    -Kevin

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Reply
  • zedhed
    0 zedhed over 10 years ago

    Hi Pirmin,

    Sorry for bringing up an old thread, but this one took me a while to find an answer for and I just happened to come back across this thread while looking for another one. I wanted to post this information for the rest of the community in case anyone stumbled across this thread again.

    In short, a modern U-Boot overwrites the local-mac-address = [00 0a 35 00 00 00]; property of your device tree after it gets loaded into memory. The value that it is overwritten with comes from the U-Boot ethaddr=00:0a:35:00:01:22 environment variable.

    This is also confirmed in this forum post here:

    http://forums.xilinx.com/t5/Embedded-Linux/Perm-changing-the-MAC-address/td-p/61463

    Now for the long version and how to prove that this happens:

    All of this can be observed if you boot a more recent OSL release like the 2014.4 found on this page:

    http://www.wiki.xilinx.com/Zynq+2014.4+Release

    Download the Xilinx 2014.4 Linux release and copy the zedboard files to an sd card, boot ZedBoard to U-Boot prompt, run the following command:

    zynq-uboot> printenv ethaddr ethaddr=00:0a:35:00:01:22 

    Take a peek inside of the devicetree.dts file, and see the following:

    local-mac-address = [00 0a 35 00 00 00]; 

    Boot ZedBoard all the way into Linux and then run ifconfig command:

    # ifconfig eth0
    
    …
    
    Hwaddr 00:0a:35:00:01:22
    
    …

    So this demonstrates, in this case, that U-Boot uses its own environment variable to override the devicetree setting.

    Now for the extra long version:

    You can prove that this happens by going into U-Boot source code and adding some additional print statements to see what is going on.

    To test this out, I made some additional prints to u-boot source code and rebuilt:

    In u-boot-xlnx/common/fdt_support.c: fdt_fixup_ethernet() added a few lines around here:

     

    // Debug stuff to demonstrate whether device tree is touched or not.
    
    printf("\n");
    
    printf("DEBUG: common/fdt_support.c:fdt_fixup_ethernet()\n");
    
    printf("DEBUG: Modifying the device tree that is loaded into memory\n");
    
    printf("\n");
    
    
    
    sprintf(mac, "eth%daddr", ++i);

     

    Fired this up on my ZedBoard and sure enough, here is what I see in the terminal:

     

    ## Flattened Device Tree blob at 02000000
    
       Booting using the fdt blob at 0x2000000
    
       Loading Kernel Image ... OK
    
       Loading Ramdisk to 1e793000, end 1ed23d29 ... OK
    
       Loading Device Tree to 1e78d000, end 1e7923de ... OK
    
    
    
    DEBUG: common/fdt_support.c:fdt_fixup_ethernet()
    
    DEBUG: Modifying the device tree that is loaded into memory
    
    DEBUG: About to fix up mac address in device tree node: /amba/ethernet@e000b000
    
    DEBUG: Device tree node modified to MAC address 00 0A 35 00 01 22
    
    
    Starting kernel ...

     

    Hopefully this clears up where the MAC address comes from.

    Regards,

    -Kevin

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Children
No Data
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube