# Tlv\_parser to set eeprom mac addr

**URL:** <https://community.solid-run.com/t/tlv-parser-to-set-eeprom-mac-addr/836>\
**Category:** NXP LX2160\
**Created:** [April 29, 2024, 10:40am UTC](https://community.solid-run.com/t/tlv-parser-to-set-eeprom-mac-addr/836 "2024-04-29T10:40:31Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![joema](https://avatars.discourse-cdn.com/v4/letter/j/a9adbd/32.png) [@joema](https://community.solid-run.com/u/joema)\
**Post date:** [April 29, 2024, 10:40am UTC](https://community.solid-run.com/t/tlv-parser-to-set-eeprom-mac-addr/836/1 "2024-04-29T10:40:31Z")

</div>

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:

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

```

this is where we take tlv\_parser from:

> **[GitHub - SolidRun/tlv\_parser](https://github.com/SolidRun/tlv_parser)**
>
> Contribute to SolidRun/tlv\_parser development by creating an account on GitHub.

---

<div class="post-metadata">

**Author:** ![jnettlet](https://dub1.discourse-cdn.com/flex005/user_avatar/community.solid-run.com/jnettlet/32/62_2.png) [@jnettlet](https://community.solid-run.com/u/jnettlet)\
**Post date:** [April 29, 2024, 11:50am UTC](https://community.solid-run.com/t/tlv-parser-to-set-eeprom-mac-addr/836/2 "2024-04-29T11:50:39Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![joema](https://avatars.discourse-cdn.com/v4/letter/j/a9adbd/32.png) [@joema](https://community.solid-run.com/u/joema)\
**Post date:** [April 30, 2024, 6:24am UTC](https://community.solid-run.com/t/tlv-parser-to-set-eeprom-mac-addr/836/3 "2024-04-30T06:24:27Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jnettlet](https://dub1.discourse-cdn.com/flex005/user_avatar/community.solid-run.com/jnettlet/32/62_2.png) [@jnettlet](https://community.solid-run.com/u/jnettlet)\
**Post date:** [April 30, 2024, 8:41am UTC](https://community.solid-run.com/t/tlv-parser-to-set-eeprom-mac-addr/836/4 "2024-04-30T08:41:24Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![joema](https://avatars.discourse-cdn.com/v4/letter/j/a9adbd/32.png) [@joema](https://community.solid-run.com/u/joema)\
**Post date:** [April 30, 2024, 8:49am UTC](https://community.solid-run.com/t/tlv-parser-to-set-eeprom-mac-addr/836/5 "2024-04-30T08:49:59Z")

</div>

any idea?

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

```

---

<div class="post-metadata">

**Author:** ![jnettlet](https://dub1.discourse-cdn.com/flex005/user_avatar/community.solid-run.com/jnettlet/32/62_2.png) [@jnettlet](https://community.solid-run.com/u/jnettlet)\
**Post date:** [April 30, 2024, 8:51am UTC](https://community.solid-run.com/t/tlv-parser-to-set-eeprom-mac-addr/836/6 "2024-04-30T08:51:52Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![joema](https://avatars.discourse-cdn.com/v4/letter/j/a9adbd/32.png) [@joema](https://community.solid-run.com/u/joema)\
**Post date:** [April 30, 2024, 9:22am UTC](https://community.solid-run.com/t/tlv-parser-to-set-eeprom-mac-addr/836/7 "2024-04-30T09:22:46Z")

</div>

```auto
# 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

```

---

<div class="post-metadata">

**Author:** ![joema](https://avatars.discourse-cdn.com/v4/letter/j/a9adbd/32.png) [@joema](https://community.solid-run.com/u/joema)\
**Post date:** [April 30, 2024, 9:24am UTC](https://community.solid-run.com/t/tlv-parser-to-set-eeprom-mac-addr/836/8 "2024-04-30T09:24:41Z")

</div>

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

```auto
# 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!

```

---

<div class="post-metadata">

**Author:** ![jnettlet](https://dub1.discourse-cdn.com/flex005/user_avatar/community.solid-run.com/jnettlet/32/62_2.png) [@jnettlet](https://community.solid-run.com/u/jnettlet)\
**Post date:** [April 30, 2024, 10:04am UTC](https://community.solid-run.com/t/tlv-parser-to-set-eeprom-mac-addr/836/9 "2024-04-30T10:04:35Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![joema](https://avatars.discourse-cdn.com/v4/letter/j/a9adbd/32.png) [@joema](https://community.solid-run.com/u/joema)\
**Post date:** [April 30, 2024, 12:17pm UTC](https://community.solid-run.com/t/tlv-parser-to-set-eeprom-mac-addr/836/10 "2024-04-30T12:17:53Z")

</div>

Thanks, got it to work:

```auto
# /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

---

<div class="post-metadata">

**Author:** ![jnettlet](https://dub1.discourse-cdn.com/flex005/user_avatar/community.solid-run.com/jnettlet/32/62_2.png) [@jnettlet](https://community.solid-run.com/u/jnettlet)\
**Post date:** [April 30, 2024, 12:48pm UTC](https://community.solid-run.com/t/tlv-parser-to-set-eeprom-mac-addr/836/11 "2024-04-30T12:48:03Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![joema](https://avatars.discourse-cdn.com/v4/letter/j/a9adbd/32.png) [@joema](https://community.solid-run.com/u/joema)\
**Post date:** [April 30, 2024, 12:48pm UTC](https://community.solid-run.com/t/tlv-parser-to-set-eeprom-mac-addr/836/12 "2024-04-30T12:48:52Z")

</div>

thanks 🙏

---

<div class="post-metadata">

**Author:** ![joema](https://avatars.discourse-cdn.com/v4/letter/j/a9adbd/32.png) [@joema](https://community.solid-run.com/u/joema)\
**Post date:** [May 4, 2024, 5:37pm UTC](https://community.solid-run.com/t/tlv-parser-to-set-eeprom-mac-addr/836/13 "2024-05-04T17:37:27Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![jnettlet](https://dub1.discourse-cdn.com/flex005/user_avatar/community.solid-run.com/jnettlet/32/62_2.png) [@jnettlet](https://community.solid-run.com/u/jnettlet)\
**Post date:** [May 5, 2024, 3:22pm UTC](https://community.solid-run.com/t/tlv-parser-to-set-eeprom-mac-addr/836/14 "2024-05-05T15:22:01Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![joema](https://avatars.discourse-cdn.com/v4/letter/j/a9adbd/32.png) [@joema](https://community.solid-run.com/u/joema)\
**Post date:** [May 5, 2024, 4:17pm UTC](https://community.solid-run.com/t/tlv-parser-to-set-eeprom-mac-addr/836/15 "2024-05-05T16:17:32Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jnettlet](https://dub1.discourse-cdn.com/flex005/user_avatar/community.solid-run.com/jnettlet/32/62_2.png) [@jnettlet](https://community.solid-run.com/u/jnettlet)\
**Post date:** [May 5, 2024, 5:46pm UTC](https://community.solid-run.com/t/tlv-parser-to-set-eeprom-mac-addr/836/16 "2024-05-05T17:46:33Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![joema](https://avatars.discourse-cdn.com/v4/letter/j/a9adbd/32.png) [@joema](https://community.solid-run.com/u/joema)\
**Post date:** [May 5, 2024, 6:51pm UTC](https://community.solid-run.com/t/tlv-parser-to-set-eeprom-mac-addr/836/17 "2024-05-05T18:51:33Z")

</div>

thanks!
