Configuring EEPROM
The device integrates an EEPROM with 4KB of storage capacity, allowing users to write and save small amounts of critical data. The following describes the specific operations for writing and reading data.
Preparation:
The device has started up normally.
Steps:
- Open a terminal and execute the following command to create a
.txtfile with a custom name.
nano edatec_hat.txt
edatec_hatindicates the custom file name.
- Add the following content to be written to the EEPROM in the
edatec_hat.txtfile (this is just an example; users can add content as needed).
cat > myhat.txt << 'EOF'
product_uuid 00000000-0000-0000-0000-000000000000
product_id 0x0001
product_ver 0x0001
vendor "My Company"
product "My HAT"
current_supply 0
dt_blob "my-overlay"
EOF
TIP
The content written to the EEPROM has format restrictions. For detailed specifications, please refer to the EEPROM Configuration File Description.
Press
Ctrl+Oto save the file, then pressEnter, and finally pressCtrl+Xto exit the file editing mode.Execute the following command to convert the created
.txtfile into a.eepfile recognizable by the EEPROM.
eepmake edatec_hat.txt edatec_hat.eep
- Execute the following command to write
edatec_hat.eepto the EEPROM.
sudo eepflash.sh -w -f=edatec_hat.eep -t=24c32 -d=1 -a=57
-w: Indicates write mode;-f=edatec_hat.eep: Indicates the file to be written;-t=24c32: Indicates the EEPROM chip model is AT24C32;-d=1: Indicates the I2C bus number;-a=57: Indicates the I2C device address.
- Execute the following command to read data from the EEPROM and save it as a binary file named
readback.bin.
sudo eepflash.sh -r -f readback.bin -t=24c32 -d=1 -a=57
-r: Indicates read mode;-t=24c32: Indicates the EEPROM chip model is AT24C32;-d=1: Indicates the I2C bus number;-a=57: Indicates the I2C device address.
- Execute the following command to parse the read
readback.binbinary file.
hexdump -C readback.bin | head -20
20: Indicates displaying 20 lines of information.
TIP
The EEPROM has a limited number of read/write cycles. Please avoid frequent operations to prevent affecting its service life.
