AR# 70176

Zynq UltraScale+ MPSoC: How to get MAC address from EEPROM on ZCU102 Borad using PetaLinux?


How can I get a mac address from serial EEPROM on PetaLinux?


Run the below command and then select the following:

$ petalinux-config

---> Subsystem AUTO Hardware Settings --> Ethernet Settings --> Ethernet MAC address

Set the MAC address of the primary Ethernet.

Note: If the MAC address is programmed into EEPROM, keep this empty.

Use one of the two methods below to program the MAC address to EEPROM:


1) ZCU102_SCUI

In previous versions of the SCUI (earlier than 2016.4), it was possible to set the MAC Address in the SCUI GUI.

However, from the 2017.1 release on, that option no longer exists, and you can only get the MAC Address from the board.

However, you can manually take it back by adding the following section to config.json ( , saving the config.json, and relaunching the SCUI.

      "name": "Set MAC Address",
      "command": "<setmux:1:74:01><writeeeprom:1:54:20:<3>><setmux:1:74:00>",
      "UI": {
          "spacer": 20,
          "label": "Input the board MAC address with no colons (only hex characters):",
          "spacer": 20,
          "input": "^([0-9a-fA-F]{12})$"

The modified file is attached to this Answer Record.

2) Writing EEPROM Using I2C Commands over U-Boot


In U-Boot the Ethernet MAC address is configured as an environment variable. 

The MAC address environment variable can be changed from the U-Boot console and then saved into the bootenv Flash partition using the saveenv command.

ZynqMP> setenv ethaddr AA:BB:CC:DD:EE:FF
ZynqMP> saveenv

However this method only saves the MAC address to QSPI flash partition, not EEPROM.

As a result, you will need to Write EEPROM Using I2C Commands.

Before writing, you need to know the address of EEPROM. 

Below is the mac address information of EEPROM defined in u-boot for a ZCU102 board.

#define CONFIG_ZYNQ_EEPROM_BUS        5

Use this information to update the MAC address to EEPROM with the i2c command:

ZynqMP> i2c 
i2c - I2C sub-system

i2c bus [muxtype:muxaddr:muxchannel] - show I2C bus info
crc32 chip address[.0, .1, .2] count - compute CRC32 checksum
i2c dev [dev] - show or set current I2C bus
i2c loop chip address[.0, .1, .2] [# of objects] - looping read of device
i2c md chip address[.0, .1, .2] [# of objects] - read from I2C device
i2c mm chip address[.0, .1, .2] - write to I2C device (auto-incrementing)
i2c mw chip address[.0, .1, .2] value [count] - write to I2C device (fill)
i2c nm chip address[.0, .1, .2] - write to I2C device (constant address)
i2c probe [address] - test for and show device(s) on the I2C bus
i2c read chip address[.0, .1, .2] length memaddress - read to memory
i2c write memaddress chip address[.0, .1, .2] length [-s] - write memory
          to I2C; the -s option selects bulk write in a single transaction
i2c reset - re-init the I2C Controller
i2c speed [speed] - show or set I2C bus speed

ZynqMP> mm.b 0
00000000: 00 ? 12
00000001: 00 ? 34
00000002: 00 ? 56
00000003: 00 ? 78
00000004: 00 ? 9a
00000005: 00 ? bc
00000006: 00 ? q
ZynqMP> i2c dev
Current bus is 5
ZynqMP> i2c write 0 54 20 6
ZynqMP> i2c md 54 20
0020: 12 34 56 78 9a bc 

Then reboot the u-boot. 

In the boot log, you can confirm that the EEPROM is updated:

Address in SROM is         12:34:56:78:9a:bc


Associated Attachments

Name File Size File Type 4 KB ZIP
AR# 70176
Date 07/26/2018
Status Active
Type General Article
Boards & Kits