EEPROM
EEPROM stands for Electrically Erasable Programmable Read-Only Memory. It is a non-volatile memory that can be programmed and erased electrically, and can be used to store configuration data or other general-purpose data.
The phyCORE-AM64x development kit has two EEPROMs with an I2C interface:
A 32 kbit (4 kB) EEPROM on the SOM. It holds PHYTEC’s hardware identification data, which the bootloader reads at boot. See SOM EEPROM (Limited Access).
A 2 kbit (256 byte) EEPROM on the carrier board, which this guide uses for the read and write example. See Carrier Board EEPROM.
To learn more information about the phyCORE-AM64x EEPROM system memory, please see section 6.1.2 in the Hardware Manual.
Location |
Reference |
I2C Bus |
Address |
|---|---|---|---|
SOM |
U7 |
i2c0 |
0x50 |
Carrier Board |
U61 |
i2c1 |
0x51 |
Carrier Board EEPROM
EEPROM Initialization
First ensure that the EEPROM is initialized correctly by checking the boot log.
sh-phyboard-electra-am64xx-2:~# dmesg | grep -i "eeprom" [ 6.049192] at24 0-0050: 4096 byte 24c32 EEPROM, writable, 32 bytes/write [ 6.090717] at24 1-0051: 256 byte 24c02 EEPROM, writable, 16 bytes/write
Writing to the EEPROM
Clear out the entirety of the EEPROM by writing zeros to it.
sh-phyboard-electra-am64xx-2:~# dd if=/dev/zero of=/sys/bus/i2c/devices/1-0051/eeprom bs=256 count=1 1+0 records in 1+0 records out 256 bytes copied, 0.0780454 s, 3.3 kB/s
Now generate a 2kbit file with random data. This will serve as the test file:
sh-phyboard-electra-am64xx-2:~# dd if=/dev/urandom of=/tmp/test.img bs=256 count=1 1+0 records in 1+0 records out 256 bytes copied, 0.000466573 s, 549 kB/s
Write the test file to the EEPROM
sh-phyboard-electra-am64xx-2:~# dd if=/tmp/test.img of=/sys/bus/i2c/devices/1-0051/eeprom bs=256 count=1 0+1 records in 0+1 records out 256 bytes copied, 0.0875027 s, 2.9 kB/s
Reading from EEPROM
Read the contents of the EEPROM and store it to a file.
sh-phyboard-electra-am64xx-2:~# dd if=/sys/bus/i2c/devices/1-0051/eeprom of=/tmp/test_read.img bs=256 count=1 1+0 records in 1+0 records out 256 bytes copied, 0.0136441 s, 18.8 kB/s
Make sure the output file was not corrupted during the transfer using md5sum.
sh-phyboard-electra-am64xx-2:~# md5sum /tmp/test.img /tmp/test_read.img 192e08b78bc0100bcff74d324d1ccbde /tmp/test.img 192e08b78bc0100bcff74d324d1ccbde /tmp/test_read.img
SOM EEPROM (Limited Access)
PHYTEC Board Support Packages (BSPs) are equipped with extended functionality in the bootloader that allows it to read the System on Module (SOM) EEPROM. This enables the software to adjust based on the SOM configuration, allowing a single software image to work across multiple hardware configurations.
While modifying the SOM EEPROM content is not recommended, it is possible to disable this feature if needed. However, disabling it may require additional effort to support various SOM options.
You can access the SOM EEPROM content using the EEPROM Flashtool. Below is an overview of how to read the content and add new information. For further details, please refer to the official GitHub page.
Read the Content
To read the full content of the SOM EEPROM, use the pre-installed phytec_eeprom_flashtool. This tool will display all the relevant information stored in the SOM.
sh-phyboard-electra-am64xx-2:~# phytec_eeprom_flashtool read -som PCM-072
MAC Address
By default, the phyCORE-AM64x does not have pre-programmed MAC addresses and instead generates random MAC addresses at boot time. You can write specific MAC addresses into the SOM EEPROM using the EEPROM Flashtool, which will be read during the boot process.
Example command to set a MAC address 00:91:da:dc:1f:c5 for Ethernet interface 0:
sh-phyboard-electra-am64xx-2:~# phytec_eeprom_flashtool add-mac -som PCM-072 0 00:91:da:dc:1f:c5
Key Values
The SOM EEPROM can also store key-value pairs in ASCII format. These pairs will be read by the bootloader and stored in the environment, where they can be used either in the bootloader or accessed in Linux via the fw_printenv tool.
Example command to set the value CAFE1234 for the key SERIAL.
sh-phyboard-electra-am64xx-2:~# phytec_eeprom_flashtool add-key-value -som PCM-072 SERIAL CAFE1234