How can I get a mac address from serial EEPROM on PetaLinux?
If a valid MAC address is stored in the EEPROM, this is used as default address if there is NO corresponding address setting in the u-boot environment.
If the corresponding environment (ethaddr) variable is set, this overrides the EEPROM address. This implies that:
The solution is comprised of two parts:
Part 1: Ensure that the u-boot environment variable 'ethaddr' is undefined.
Part 2: Write the MAC address into the EEPROM
Depending on the flow you are using, choose either of the following methods to ensure that the U-Boot environment variable 'ethaddr' is undefined:
a) If you are customizing the PetaLinux project:
Run the below command and then select the following:
---> Subsystem AUTO Hardware Settings --> Ethernet Settings --> Ethernet MAC address
Delete the default value, and keep this empty. Make sure to save the new config prior to exiting the GUI menu.
b) If using pre-built PetaLinux images:
Halt at U-Boot, and issue the following commands:
ZynqMP> setenv ethaddr
Use one of the two methods below to program the MAC address to EEPROM:
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 (rdf0382-zcu102-system-controller-es2-2017-2.zip) , saving the config.json, and relaunching the SCUI.
The modified file is attached to this Answer Record.
2) Writing EEPROM Using I2C Commands over U-Boot
Before writing, you need to know the address of the EEPROM.
Below are the files containing the MAC address information of the EEPROM defined in U-Boot for a ZCU102 board.
This information will be passed as arguments to the I2C commands for programming the MAC address into the EEPROM.
For 2018.x PetaLinux:
For 2019.1 PetaLinux:
Note: If using petalinux 2019.1, please refer to https://www.xilinx.com/support/answers/72401.html, for generating the correct device-tree entry for the eeprom node as shown above.
The following line defines the offset for writing the MAC address.
So the address of the EEPROM device is 0x54, and the MAC address is located at an offset of 0x20.
Use this information to update your desired MAC address to EEPROM with the following I2C commands:
After the reset command above, you should see U-Boot reading the MAC address from the EEPROM, and also the variable 'ethaddr' being updated with this address.
|Name||File Size||File Type|
|Boards & Kits||