We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

AR# 53476

Setting per-board ethernet MAC addresses


I am manufacturing a device that runs PetaLinux, and I need to each one to have a different network MAC address. How can I change the MAC address per-board without building a different PetaLinux image for each board?        


Problem Description:

By default, the Ethernet MAC address for both u-boot and the kernel are set during compilation, based on the "Ethernet MAC address" option in the "System Settings" configuration menu.

When preparing devices for manufacturing, it is not practical to create a new PetaLinux system image for each board, to provide a unique MAC address.

This article describes a manufacturing-friendly procedure the allows easy customization of the board MAC address.


The system MAC address is used in both u-boot and the kernel.

In case of u-boot, it uses the environment variable "ethaddr" as the MAC address.

In case of the Linux kernel, it gets the MAC address from the device tree (DTB/DTS file).

To update the MAC address on a per-board basis, we need to update both the "ethaddr" u-boot variable and the MAC address in the device tree.

This is achieved by creating a new flash memory partition to hold the per-board DTB, which will override the default DTB built into the PetaLinux system image


This solution is for PetaLinux SDK version 1.3 and later. 

The following procedure is used to set a per-board Ethernet address. 

It is intended that this procedure would be integrated with a manufacturing process, which might involve a bar-code scanner or similar to automatically inject the sequence of commands to the u-boot console, including the unique MAC address.


1. Create a flash partition "dtb" to contain the DTB file with the minimum partition size as 16KByte (0x4000) with menuconfig. 

Be sure to observe any flash device rules about minimum sector size.

Also enable the 'Boot image with DTB partition' option.

    $ petalinux-config-app
      "System Settings" --->
          |- [*] Boot image with the DTB partition
          |-"Flash Partition Table" --->
             (dtb) name
             (0x4000) size

2. Rebuild PetaLinux:

    $ cd ${PETALINUX}/software/petalinux-dist
    $ make clean
    $ make

The resulting u-boot (u-boot-s.bin) and kernel (image.ub) images will be programmed into the flash memory of all boards to be manufactured.

The following steps will then be performed per-board:


3. After programing the board with the FPGA bitstream, download the latest built u-boot image:

    $ petalinux-jtag-boot -u

Alternatively, boot the board directly into u-boot via fs-boot.


4. When u-boot starts, download the DTB file to the DTB flash partition:

    u-boot> run update_dtb

This command will download the DTB file to the DTB flash partition. 

Ensure that the serverip variable is correctly set.


5. update the u-boot MAC address:

    u-boot> set ethaddr AA BB CC DD EE FF


6. Save the u-boot environment variables to save the u-boot MAC address:

    u-boot> saveenv


7. Load the DTB file from the DTB flash partition to the memory:

    u-boot> run get_dtb


8. Set the MAC address in DTB:

    u-boot> fdt set <PATH TO local-mac-address PROPERTY OF THE ETHERNET CORE> local-mac-address "[AA BB CC DD EE FF]"

Example 1, change the MAC address of Ethernet lite:

   u-boot> fdt set /plb@0/ethernet@81000000 local-mac-address "[AA BB CC DD EE FF]"

Example 2, change the MAC address of ll_temac:

   u-boot> fdt set /plb@0/xps-ll-temac@82780000/ethernet@82780000 local-mac-address "[AA BB CC DD EE FF]" 

You can use the u-boot command 'fdt print' to display the device tree, and find the DTB path to the ethernet device.

9. Copy the changed DTB file back to flash:

    u-boot> run install_dtb


10. Update the kernel image in flash (if necessary):

    u-boot> run update_kernel


11. Update the u-boot image in Flash (if necessary):

    u-boot-> run update_uboot

The next time you reboot the board, it will boot the kernel with the updated DTB from the flash from u-boot.

AR# 53476
Date Created 12/12/2012
Last Updated 06/10/2015
Status Active
Type General Article
  • Zynq-7000
  • SoC
  • FPGA Device Families
  • EDK
  • Microblaze
  • Processing System 7