TLV Writer Documentation
Table of Contents
where to get
Overview
This script writes TLV (Type-Length-Value) structured data into an I2C EEPROM. It supports a variety of system-specific keys that define metadata for the device.
The script:
Builds TLV-formatted payloads.
Writes the data into an EEPROM via I2C.
Supports custom-defined keys.
Calculates and appends a CRC checksum to ensure data integrity.
Dependencies
To ensure all required dependencies are installed, run:
this will:
Install Python 3 if it is not already installed.
Install smbus for I2C communication.
Usage
Arguments
Argument
Description
i2c_bus
The I2C bus number.
eeprom_address
The EEPROM address (hex or decimal).
--yes -y --force
Automatically confirms the operation (skips user confirmation).
-b
Writes the TLV data to a binary file (/tmp/eeprom_tlv.bin) without writing to the EEPROM. You can later write it manually using dd.
One or more key-value pairs to write to EEPROM.
Example Usage
For example if we want the following data to appear in DMI:
We want to run the following command (Note that bus 3 address 0X50 is used in this example):
Bus 2 or 5 usually has the memory SPD on addresses 0x50 & 0x51, do not write to them!
Supported TLV Keys
Each TLV Key has a Hex Code, Max Length, and belongs to a DMIDecode Type.
System Information (SMBIOS Type 1)
TLV Key
Max Length (bytes)
BIOS path
TLV_CODE_FAMILY
20
-
TLV_CODE_MANUF_DATE
10
-
TLV_CODE_PLATFORM_NAME
20
-
TLV_CODE_MANUF_NAME
20
-
TLV_CODE_VENDOR_NAME
20
-
TLV_CODE_SYS_NAME
20
Main → Detailed Configuration Information → Model
TLV_CODE_SYS_SKU
20
Main screen
TLV_CODE_SYS_SERIAL_NUMBER
24
Main screen
TLV_CODE_SYS_VERSION
5
-
NIO Information (SMBIOS Type 2)
TLV Key
Max Length (bytes)
TLV_CODE_NIO_NAME
20
TLV_CODE_NIO_SERIAL_NUMBER
24
TLV_CODE_NIO_VERSION
5
Chassis Information (SMBIOS Type 3)
TLV Key
Max Length (bytes)
TLV_CODE_CHS_SERIAL_NUMBER
24
TLV_CODE_CHS_VERSION
5
TLV Key
Max Length (bytes)
BIOS path
TLV_CODE_CONFIG_CODE
200
Main → Detailed Configuration Information → Configuration String
Error Handling
If invalid input is provided, the script will:
Print an error message.
Exit without modifying EEPROM contents.
Possible Errors
Error Message
Cause
Error: Unknown key
Provided TLV key is not in the supported list.
Error: Value for key 'X' is too long
Input exceeds the maximum allowed length.
Error: MAC address must have 6 parts
Incorrect MAC format.
Error: I2C write error
I2C communication issue during EEPROM write.
Error: Total TLV data length exceeds EEPROM capacity
Data is too large for EEPROM storage.
Last updated