Backup the Original EEPROM Contents
Before attempting the other steps outlined in this article it is highly recommended to back up the contents of your EEPROM as it contains machine specific information used during boot. Use the following command to create a back up:
dd if=/sys/bus/i2c/devices/0-0050/eeprom of=/tmp/eeprom_backup bs=4096 count=1
Verify the EEPROM is detected
Use the following command to print the name of the EEPROM. The expected result is 24c32 which corresponds to the device driver name in Linux.
Write to the EEPROM
Create data that you want to store on the EEPROM. In this example a hello.img file was created with the text "Hello World".
echo "Hello World" > hello.img
Write the file (hello.img) to the EEPROM
dd if=hello.img of=/sys/class/i2c-dev/i2c-0/device/0-0050/eeprom bs=1 count=4096
Read from the EEPROM
Dump the contents of the entire 4kB EEPROM.
dd if=/sys/class/i2c-dev/i2c-0/device/0-0050/eeprom bs=1 count=4096 | hexdump -C
If hello.img was written to the EEPROM in the previous step you should see the following output:
00000000 48 65 6c 6c 6f 5f 57 72 6f 6c 64 0a 68 00 00 34 |Hello World.h..4| 00000010 31 33 30 30 31 31 31 49 41 32 00 00 00 00 00 32 |1300111IA2.....2| 00000020 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................| * 00001000 4096+0 records in 4096+0 records out
Erase the EEPROM
Write all zeros to the entire density of the EEPROM to erase the contents.
dd if=/dev/zero of=/sys/bus/i2c/devices/0-0050/eeprom bs=4096 count=1
Restore the Original EEPROM Contents
Once evalution of the EEPROM is complete, it is recommended to restore the original contents of the EEPROM as it contains machine specific information used during boot.
dd if=/tmp/eeprom_backup of=/sys/bus/i2c/devices/0-0050/eeprom bs=4096 count=1
Lose the Original Contents Of the EEPROM?
If something went wrong and the EEPROM is empty, we got you covered. Head over to this How-To Guide: Using the PHYTEC EEPROM Flashtool