Close

Setting up Hat EEPROM

A project log for Raspberry Pi Zero Breakout

A break out board for the Raspberry Pi Zero for use with 5v signalling, and featuring a full size USB-A socket

david-brownDavid Brown 07/21/2016 at 15:533 Comments

This process is taken from Howto: Raspi HAT EEPROM and device-tree but corrected for a couple of syntax errors (using Raspbian).

As a preliminary step, you need to activate videocore I2C. This is done by adding a line at the beginning of your /boot/config.txt file

sudo nano /boot/config.txt
then add
dtparam=i2c_vc=on

reboot

First of all, you need to get EEPROM utils (to make EEPROM content and flash it) and device-tree compiler (dtc).

git clone https://github.com/raspberrypi/hats.git
sudo apt-get install device-tree-compiler
You'll have now installed dtc compiler and have a hat directory. Go inside, and open eepromutils directory and compile the eepmake file.

cd Downloads/hat/eepromutils
sudo make

Then modify eeprom_settings.txt to create your own version of HAT board. You don't have to modify the UUID, as it will be auto-generated.

sudo nano eeprom_settings.txt

Then, you can create an eep file, based on you eeprom_settings.txt file. Basically, an eep file is a binary version of this file, which is ready to flash on EEPROM.

sudo ./eepmake eeprom_settings.txt myhat.eep

You have now a working HAT file!

You can now write it on EEPROM. If you have followed the design guide, you have a 24c32 memory (4k). But your myhat.eep file is smaller. As you don't know the state of your EEPROM, you may have conflict, as your myhat.eep could be misread. To avoid that, we shall start by cleaning the EEPROM.

Use this dd command to generate a 4k file, padded with zero (an excellent choice, zeros are my favorites!). If you have another EEPROM size, just change count value according to your real EEPROM size.

sudo dd if=/dev/zero ibs=1k count=4 of=blank.eep

To be sure, you can review this binary, using hexdump :

hexdump blank.eep

Next, you can now upload it to your EEPROM :

sudo ./eepflash.sh -w -f=blank.eep -t=24c32

Answer yes and wait. The write protect is disabled by the small ground trace and once programmed can be cut and the write protect soldered closed.

To verify if everything went well, you can use this command to check EEPROM content. Caution: it will only work after you use the eepflash command, which does some modprobes.

sudo hexdump /sys/class/i2c-adapter/i2c-0/0-0050/eeprom

If everything is okay, you'll only see zeros.

Then, you can upload your own myhat.eep.

sudo ./eepflash.sh -w -f=myhat.eep -t=24c32

And again, verify it after uploading :

sudo hexdump /sys/class/i2c-adapter/i2c-0/0-0050/eeprom

If the contents match, you can reboot your Raspberry Pi.

To check if your HAT is recognised, just go to /proc/device-tree/. If you see a hat directory, you are a winner:)

cd /proc/device-tree/hat/
more vendor
more product


Discussions

wilsonny371 wrote 11/13/2018 at 19:17 point

Nice one!

  Are you sure? yes | no

Joan wrote 08/25/2016 at 02:38 point

Hi, interesting!, as i can do to check data EEPROM at the start of the Raspberry, call a script from the etc/rc.local ?. Thanks

  Are you sure? yes | no

David Brown wrote 08/25/2016 at 13:03 point

The Raspberry pi will automatically read the content of the EEPROM on startup and set the pin assignments as directed. I would advise looking up the official implementation on; https://github.com/raspberrypi/hats and also the guide linked above.

  Are you sure? yes | no