
On 11/23/22 04:14, Sean Anderson wrote:
On 11/22/22 20:23, David Antliff wrote:
Hi,
I'm looking to extract the board's MAC address from serial I2C EEPROM at boot time, so I'm trying to work out how I can tell if U-Boot is actually able to communicate with this EEPROM, outside of manual i2c commands.
I have set CONFIG_ZYNQ_MAC_IN_EEPROM and CONFIG_ZYNQ_MAC_IN_EEPROM however I'm not completely sure that this is working with UltraScale+ Zynq MPSoC boards - I'm using a ZCU208. There's no log message on the U-Boot console to say that there was an attempt to read the MAC address, and with ethaddr unset, this variable is set by U-Boot to the value taken from the device tree rather than EEPROM:
That was the old way how to this was achieve and based on DTS in the mainline it is not used on any existing board because none defined xlnx,eeprom property.
I just sent the patch to remove also Kconfig entries which we forget to clean up.
But the way how it is working now is that eeprom is referenced by nvmem alias. You can find conversion here 531abcb71e60 ("xilinx: Convert xlnx,eeprom property to nvmem alias")
Then you have nvmem link to eeprom which can be used.
In board_init() you can see calling xilinx_read_eeprom() which reads this link.
This structure was added for FRU format decoding also with supporting legacy format used on zcu1xx boards.
IIRC zcu208 is not using legacy format used on zcu1xx boards xilinx_read_eeprom_legacy() and there is one more legacy format which is not currently supported by this code. But it shouldn't be that complicated to add support for it because it is pretty much just different layout.
That's why I am suggesting you to create that nvmem0 link and take a look at that format to support.
Then mac address is saved to environment variables and used by ethernet driver.
ethernet@ff0e0000 { ... local-mac-address = [00 0a 35 00 22 01]; ...
I would expect it to be 00 0a 35 07 60 1c based on the contents of the EEPROM.
I would like to understand how to debug this. I read that the command "eeprom" has been deprecated for some time (I don't have it enabled), with some I2C serial EEPROM devices now supported by the "Driver Model" - aka DM.
Thus I did find:
dm uclass
... uclass 39: i2c_eeprom 0 eeprom@54 @ 7dd21420 ...
And I'm able to communicate with the device via commands like:
ZynqMP> i2c md 54 0.2 40 200000 0000: 5a 43 55 32 30 38 ff ff ff ff ff ff ff ff ff ff ZCU208.......... 0010: ff 41 30 32 38 33 32 32 30 34 31 34 33 33 32 38 .A02832204143328 0020: 31 2e 33 00 0a 35 07 60 1c 00 0a 35 07 60 1d 00 1.3..5.`...5.`.. 0030: 0a 35 07 60 1e 00 0a 35 07 60 1f 41 08 ff ff ff .5.`...5.`.A....
The MAC address is 6 bytes starting at offset 0x23 (00 0a 35 07 60 1c).
My question is - is the 'i2c' command now the accepted and best way to interact with an I2C EEPROM? Or is there another command I can enable (other than "eeprom") that will provide a generic interface for accessing EEPROMs and prove that U-Boot can "see" this device?
I don't think such an API exists.
The EEPROM device in question is an M24128.
CONFIG_SYS_I2C_EEPROM_ADDR=0x54 CONFIG_SYS_I2C_EEPROM_BUS=6 CONFIG_SYS_EEPROM_SIZE=16384 CONFIG_SYS_I2C_EEPROM_ADDR_LEN=2 CONFIG_ZYNQ_GEM_I2C_MAC_OFFSET=0x23 CONFIG_ZYNQ_MAC_IN_EEPROM=y
U-Boot 2021.01 (Xilinx fork: git://github.com/Xilinx/u-boot-xlnx.git)
P.S. if this is better directed to Xilinx or the Xilinx community then I'm happy to do that, but in case it's a more generic U-Boot issue I thought it best to ask here first. Please don't flame me for using Xilinx, I'm trying to do my best with what I'm given.
-- David.
This doesn't directly address your question, but have you tried using nvmem-cells?
You enable CONFIG_NVMEM and CONFIG_I2C_EEPROM, and modify your device tree like
i2c { eeprom@54 { #address-cells = <1>; #size-cells = <1>; compatible = "atmel,24c08"; reg = <0x54>;
mac_address: mac-address@23 { reg = <0x23 6>; }; }; };
ethernet { nvmem-cells = <&mac_address>; nvmem-cell-names = "mac-address"; };
You'll need 2022.07 for this I think. This is the same method which Linux uses. I added this specificly to be able to load MAC addresses from EEPROMs without needing to hard code stuff into Kconfig.
This looks good and I see Sean wired it in the U-Boot already. It should work fine with all Xilinx formats but on boards just for MAC address. (FRU format is also designed in a way that the same boards have MAC address at the same location). The code I described above is also checking in FRU format that checksums are correct and also reading more information from it for other use cases.
Thanks, Michal