.. include:: ../substitutions.rst EEPROM ====== EEPROM stands for Electrically Erasable Programmable Read-Only Memory. It is a non-volatile memory that can be programmed and erased electrically. The |product| SOM provides a 4kB (32kbit) EEPROM on WKUP_I2C0 (/dev/i2c-\ |intf-eeprom0-i2c-bus|) at address 0x\ |intf-eeprom0-i2c-addr|, which is reserved for PHYTEC SOM information. The SoM EEPROM can be used to store configuration data or other general-purpose data. This guide will show you how to access the 2kbit user EEPROM featured on the |product| development kit carrier board. .. note:: The |product| development kit provides access to three EEPROMs, 1x 32kbit EEPROM on the SOM and 2x 2kbit EEPROMs on the carrier board. .. list-table:: EEPROM :header-rows: 1 * - Location - Designator - I2C Bus - Address * - SOM (PHYTEC) - |eeprom0-ref| - i2c-\ |intf-eeprom0-i2c-bus| - 0x\ |intf-eeprom0-i2c-addr| * - Carrier Board (Factory) - |eeprom1-ref| - i2c-\ |intf-eeprom1-i2c-bus| - 0x\ |intf-eeprom1-i2c-addr| * - Carrier Board (User) - |eeprom2-ref| - i2c-\ |intf-eeprom2-i2c-bus| - 0x\ |intf-eeprom2-i2c-addr| Carrier Board User EEPROM ------------------------- The examples below use the user EEPROM (|eeprom2-ref|) at address 0x\ |intf-eeprom2-i2c-addr|. EEPROM Initialization ~~~~~~~~~~~~~~~~~~~~~ * First ensure that the EEPROMs are initialized correctly by checking the boot log. .. code-block:: console :substitutions: |target-prompt| dmesg | grep -i "eeprom" [ 6.049192] at24 |intf-eeprom0-i2c-bus|-00|intf-eeprom0-i2c-addr|: |intf-eeprom0-stats| [ 6.090717] at24 |intf-eeprom1-i2c-bus|-00|intf-eeprom1-i2c-addr|: |intf-eeprom1-stats| [ 6.090717] at24 |intf-eeprom2-i2c-bus|-00|intf-eeprom2-i2c-addr|: |intf-eeprom2-stats| Writing to the EEPROM ~~~~~~~~~~~~~~~~~~~~~ * Clear out the entirety of the EEPROM by writing zeros to it. .. code-block:: console :substitutions: |target-prompt| dd if=/dev/zero of=/sys/bus/i2c/devices/|intf-eeprom2-i2c-bus|-00|intf-eeprom2-i2c-addr|/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: .. code-block:: console :substitutions: |target-prompt| 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 .. code-block:: console :substitutions: |target-prompt| dd if=/tmp/test.img of=/sys/bus/i2c/devices/|intf-eeprom2-i2c-bus|-00|intf-eeprom2-i2c-addr|/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. .. code-block:: console :substitutions: |target-prompt| dd if=/sys/bus/i2c/devices/|intf-eeprom2-i2c-bus|-00|intf-eeprom2-i2c-addr|/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. .. code-block:: console :substitutions: |target-prompt| md5sum /tmp/test.img /tmp/test_read.img 192e08b78bc0100bcff74d324d1ccbde /tmp/test.img 192e08b78bc0100bcff74d324d1ccbde /tmp/test_read.img PHYTEC SOM EEPROM (Limited Access) ---------------------------------- PHYTEC Board Support Packages (BSPs) are equipped with extended functionality in the bootloader that allows it to read the PHYTEC reserved 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 PHYTEC 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. .. note:: The SOM EEPROM is write-protected by default. To write to it (for example, to add a MAC address or key-value pair), close jumper J10 on the |product-cb|. You can access the PHYTEC 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. .. code-block:: console :substitutions: |target-prompt| phytec_eeprom_flashtool read -som |default-som-product-number| .. _eeprom_set_mac: MAC Address ~~~~~~~~~~~ By default, the |product| does not have pre-programmed MAC addresses and instead generates random MAC addresses at boot time. You can write specific MAC addresses into the PHYTEC 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: .. code-block:: console :substitutions: |target-prompt| phytec_eeprom_flashtool add-mac -som |default-som-product-number| 0 00:91:da:dc:1f:c5 Key Values ~~~~~~~~~~ The PHYTEC 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`. .. code-block:: console :substitutions: |target-prompt| phytec_eeprom_flashtool add-key-value -som |default-som-product-number| SERIAL CAFE1234