Configuring the Sff_eeprom Script
Overview
The sff_eeprom script is used to read data from or write data to Electrically Erasable Programmable Read-Only Memory (EEPROM) via the sysfs interface. EEPROM is a type of non-volatile memory that is embedded into an optical module. You can modify the optical module by using the sff_eeprom script.
The sysfs interface is a virtual file system provided by the Linux kernel. You can manage the kernel information (such as EEPROM) through the corresponding files located at /sys/class/swmon/ports/portX. X indicates the port number.
Configuration Notes and Constraints
When you use the script, pay attention to the following considerations:
This function is currently supported only on the switch platforms: Trident4-X9, Tomahawk4, and Tomahawk5.
You need to run the script with root privileges. After entering the Linux Shell mode, type the sudo su command to switch to the root user, or directly add sudo before the commands of sff_eeprom read and sff_eeprom write.
Only the following pages support read and write operations: 0x00, 0x01, 0x02, 0x03, 0x10, and 0x11.
The 0x00 page is divided into two sections: Lower Page 00h and Upper Page 00h. To read data from or write data to EEPROM in Lower Page 00h, set the offset ranges from 0 to 127. To read data from or write data to EEPROM in Upper Page 00h, set the offset to a value ranging from 128 to 255.
To read or write data in page 0x01, 0x02, 0x03, 0x10, and 0x11, set the offset to a value ranging from 128 to 255.
If the embedded EEPROM does not support the paging function, data can be read from or written to only the page 0x00.
Common errors and solutions are shown below:
Error | Solution |
Error: Please input value of page in 0xXX hexadecimal format! | Ensure that the page is entered in hexadecimal. |
Error: Invalid value for length or offset. | Ensure that the offset is greater than or equal to 0, the length is greater than 0, and the sum of the offset and length is less than or equal to 256. |
Error: This feature is temporarily not supported by current platform! | Ensure that the platform of the switch running the script is Trident4-X9, Tomahawk 4, or Tomahawk 5. |
Error: There is no module plugged in port <port_number>. | Ensure that the optical module is inserted. |
Error: Incorrect number of arguments provided! | Ensure that the command is formatted correctly. |
Error: Fail to set parameters for reading eeprom! | Pull the optical module out and reinsert it. |
Error: Fail to read <length> bytes at address <offset> in page <page>! | Ensure that the page and offset you entered are correct. |
Error: Mismatch between data number (<data_count>) and length(<length>) | Ensure that data is separated by commas (,) and the number of the data is the same as the length that you specified. |
Error: data to write should be between 0x00 0xXX hexadecimal format! | Ensure that the data to write is in hexadecimal.
|
Error: data to write should be between 0x00 and 0xff! | Ensure that the data to write is between 0x00 and 0xFF. |
Error: Fail to set <value> to offset <offset>! | Pull the optical module out and reinsert it. |
Error: Permission denied. | Ensure that you run this script with root privileges. |
Error: Command not found. | Run the chomd +x sff_eeprom command to grant the executable permission to the script. |
Reading or Writing the Sff_eeprom Script
To read or write the sff_eeprom script, take the following steps:
Step 1 Enter the Linux shell mode from the operation mode.
start shell sh
Step 2 Read the sff_eeprom script.
sff_eeprom read <port_number> <page> <offset> <length>
Step 3 Write the sff_eeprom script.
sff_eeprom write <port_number> <page> <offset> <length> <data>
Configuration Examples
Disable channel C2 on the module.
admin@PICOS> start shell sh
admin@PICOS:~$ sudo su
root@PICOS:/home/admin# sff_eeprom write 1 0x10 130 1 0x02
Write value to reg is done!
Please use "sff_eeprom read 1 0x10 130 1" to verify! |
Read 1 byte of data from the port 1 EEPROM, starting from the offset address 130 in page 0x10.
admin@PICOS> start shell sh
admin@PICOS:~$ sudo sff_eeprom read 1 0x10 130 1
0x02 |