Tlv_parser to set eeprom mac addr

hi,
can we use the tlv_parser tool to set the eeprom mac address fields instead of doing this in u-boot?

in u-boot we are doing something like:
tlv_eeprom set 0x24 FA:00:E7:00:FF:F8
tlv_eeprom set 0x2a 0x0A
tlv_eeprom write

but tlv_parser expects different params:

# tlv_parser 
Usage:
tlv_parser -b <I2C bus number> -a <EEPROM address>

this is where we take tlv_parser from:

tlv_parser is only written to read from the eeprom in Linux userspace. Onie does have a tlv parser, but I have not tested it on the lx2160a.

Thanks. Any idea how to read the eeprom? what do I provide as i2c bus num?

It is device 0x57 on i2c bus 0. You can find the information from our schematics, or the device-tree.

1 Like

any idea?

# ./tlv_parser -b 0 -a 0x57                                                                                                                                                                                          
ioctl error while reading data from I2C bus - No such device or address
Can't read EEPROM..

Could be permissions, are you running it as root. It is possible your i2c bus is enumerated differently. You can use the i2cdump utility to check the devices on each bus.

# i2cdump 0 0x57 b
Error: Could not set address to 0x57: Device or resource busy

# i2cdetect -y 0
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:                         -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- UU -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- UU -- -- -- -- -- -- -- 
50: UU -- -- UU -- -- -- UU -- -- -- -- UU -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- UU                         

# i2cget -y 0 0x57 0x1
Error: Could not set address to 0x57: Device or resource busy

I do find 0x57 on bus 2 but tlv_parser doesn’t seem to like it either:

# i2cdetect -y 2
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:                         -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- UU -- -- 54 55 56 57 -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --                         

# ./tlv_parser -b 2 -a 0x57
Invalid TLV header read from EEPROM!

This is the correct eeprom, but the tlv_parser code can not read it because the eeprom kernel driver has control over the device. You can disable the device in the device-tree and then access it from this utility, otherwise you would need to modify the tool to read the eeprom contents directly from the sysfs eeprom device and then parse it.

1 Like

Thanks, got it to work:

# /root/tlv_parser -b 3 -a 0x57
EEPROM Contents:
        Product Name: LX2160A_CEX7
        ...

I’m thinking to expand tlv_parser with code for writing the EEPROM, too, so I can change the mac address from user space (for production line). do you think there’s any reason why this would not work?

thanks

Should work fine. As long as the TLV is written in the correct format with the proper CRC entry it does not matter where the device is programmed.

thanks :pray:

to update the Mac address, it seems it would be most simple just to rewrite the EEPROM with only 3 fields: mac address base, size, and the CRC.

but it seems SolidRun is putting some extra fields into the EEPROM, and we wonder how important/required/used are they?

fields like product name, vendor name, country, serial number (i wonder what serial number is that? SolidRun’s SOM serial number? is this meaningful or just arbitrary?), platform name, vendor extension…

Can we just remove them?

Or should we keep them around?

Thanks!

It is your hardware you can do with it what you want. On other platforms we do use them, but currently on the LX2160a only the MAC address and number fields are used.

any chance you can share details regarding the serial number field? is it meaningful? is this allocated per SOM by SolidRun or something? thanks

The serial number matches the same serial number that is stickered on the part, either SOM/COM or carrier.

thanks!