...
Table of Contents
...
Anchor | ||||
---|---|---|---|---|
|
This script writes TLV (TagType-Length-Value) structured data into an I2C EEPROM. It supports a variety of system-specific keys that define metadata for the device.
...
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.
...
Anchor | ||||
---|---|---|---|---|
|
Code Block |
---|
python3 TLV_write.py <i2c_bus> <eeprom_address> [--yes] <key> <value> <key> <value> ... |
Arguments
Argument | Description |
---|---|
i2c_bus | The I2C bus number. |
eeprom_address | The EEPROM address (hex or decimal). |
--yes (optional) | Automatically confirms the operation (skips user confirmation). |
<key> <value> | One or more key-value pairs to write to EEPROM. |
Example Usage
Code Block |
---|
python3 TLV_write.py 2 0x50 TLV_CODE_SYS_NAME "MySystem" TLV_CODE_SYS_VERSION "1.0" |
Panel | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
as you can see this usage write that the System name is “MySystem“ , the i2c_bus is 2 and eeprom_address is 0X50. |
Info | ||||||
---|---|---|---|---|---|---|
Finding the I2C Bus NumberTo determine the correct I2C bus number, run the following command:
If no EEPROM device is found, repeat the command with different bus numbers (e.g., 2, 3, 4, etc.) until you detect an address 0x50 or 0x56. Once found, use the corresponding bus number in the script. Example:
If the output shows:
Then bus 2 and address 0x50 should be used in the script. |
Arguments
Argument | Description |
---|---|
i2c_bus | The I2C bus number. |
eeprom_address | The EEPROM address (hex or decimal). |
--yes (optional) | Automatically confirms the operation (skips user confirmation). |
<key> <value> | One or more key-value pairs to write to EEPROM. |
Example Usage
Code Block |
---|
python3 TLV_write.py 2 0x50 TLV_CODE_SYS_NAME "MySystem" TLV_CODE_SYS_VERSION "1.0" |
This writes:
System Name: "MySystem"
System Version: "1.0" to EEPROM at I2C bus 2, address 0x50.
...
Anchor | ||||
---|---|---|---|---|
|
Each TLV Key has a Hex Code, Max Length, and belongs to a DMIDecode Type.
System Information (SMBUS Type 1)
TLV KeyHex Code | Max Length (bytes) | |
TLV_CODE_FAMILY0x20 | 20 | |
TLV_CODE_MANUF_DATE | 0x23 | 10 |
TLV_CODE_PLATFORM_NAME | 0x24 | 20 |
TLV_CODE_MANUF_NAME0x25 | 20 | |
TLV_CODE_VENDOR_NAME0x27 | 20 | |
TLV_CODE_SYS_NAME0x30 | 20 | |
TLV_CODE_SYS_SKU0x31 | 20 | |
TLV_CODE_SYS_SERIAL_NUMBER | 0x32 | 24 |
TLV_CODE_SYS_VERSION | 0x33 | 5 |
NIO Information (
...
SMBUS Type: 2)
TLV KeyHex Code | Max Length (bytes) | |
TLV_CODE_NIO_NAME0x40 | 20 | |
TLV_CODE_NIO_SERIAL_NUMBER0x41 | 24 | |
TLV_CODE_NIO_VERSION | 0x42 | 5 |
Chassis Information (
...
SMBUS Type: 3)
TLV Key | Hex Code | Max Length (bytes) |
TLV_CODE_CHS_SERIAL_NUMBER0x50 | 24 | |
TLV_CODE_CHS_VERSION0x51 | 5 |
TLV_CODE_CONFIG_CODE
...
:
This entry will only be displayed in BIOS main menu.
Main → Detailed Configuration Information → Configuration String
...
Anchor | ||||
---|---|---|---|---|
|
If invalid input is provided, the script will:
Print an error message.
Exit without modifying EEPROM contents.
...
Possible Errors
Error Message | Cause |
| Provided TLV key is not in the supported list. |
| Input exceeds the maximum allowed length. |
| Incorrect MAC format. |
| I2C communication issue during EEPROM write. |
| Data is too large for EEPROM storage. |
...
Anchor | ||||
---|---|---|---|---|
|
This script requires:
Python 3
smbus
(I2C communication)struct
andbinascii
(binary manipulation)
...