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
  • paulclaessen
    0 paulclaessen over 10 years ago

    Okay, I figured out how to give a Zed board that is running Linaro Ubuntu a unique MAC address.

    As mentioned in a previous post above, the way one would expect this to work is by setting the ethaddr environment variable in uBoot. (This actually works for Petalinux).
    The problem I had when I did that, was that Linux wouldn't create my eth0 interface.
    What I just found out was that it actually DID create an eth4 interface. Of course I didn't have an interface file for it, so it wasn't usable. But after I used ipconfig to give it the right info (IP address, gateway, etc), it worked just fine.

    So then I started to wonder where this eth4 came from.
    Turns out it is created by the udev system.
    By looking at the rules file that creates the interfaces ( /etc/udev/rules.d/70-persistent-net.rules) I noticed that it tries to create, indeed, 5 interfaces, one for each MAC address I ever tried in all my testing. So, had I changed the ethaddr Uboot variable yet again, it would have added a sixth (eth5) interface for it (which would never be configured right, since I did't expect an eth5).
    As it turns out this rules file /etc/udev/rules.d/70-persistent-net.rules is itself created dynamically at boot time by a udev script called /lib/udev/write_net_rules.
    THAT is the file that keeps adding interfaces to the rules file if it gets a MAC address passed that it hasn't used before.
    One way of fixing this it to alter that script to not add new interfaces, but a much simpler solution is to simply delete the rules file!

    So here is the entire procedure:

    1. Boot into Linux
    2. Run:
       rm /etc/udev/rules.d/70-persistent-net.rules
       sync
       boot
    3. Stop uBoot from booting, so you get into the uBoot command line (if you accidently boot into Linux again, remove the rules file again!)
    4. Run:
       setenv ethaddr xx:xx:xx:xx:xx:xx
       saveenv
       reset   (NOT 'boot'!)
    5. Let it boot into Linux .. now you have an eth0 with the new MAC address

    Hope this is helpful to someone .. (the critical step is to remove the rules file! You only have to do all this once for each board/device)


    ~ Paul

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

    'ipconfig'  = 'ifconfig'

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

    'ipconfig'  = 'ifconfig'

    • 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