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:

  1. Open a terminal and execute the following command to create a .txt file with a custom name.
nano edatec_hat.txt
  • edatec_hat indicates the custom file name.
  1. Add the following content to be written to the EEPROM in the edatec_hat.txt file (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.

  1. Press Ctrl+O to save the file, then press Enter, and finally press Ctrl+X to exit the file editing mode.

  2. Execute the following command to convert the created .txt file into a .eep file recognizable by the EEPROM.

eepmake edatec_hat.txt edatec_hat.eep
  1. Execute the following command to write edatec_hat.eep to 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.
  1. 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.
  1. Execute the following command to parse the read readback.bin binary 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.