The Pi4 has 512Kb of EEPROM which hold the bootloader.

Does anyone know if it is possible to write to spi memory to be used in programs in the user space without corrupting the bootloader?

Is there any small space available?


  • I wonder what's the intended use case. Assuming you can use half of it, 256K is a microscopic amount compared to any modern SD card. Oct 3, 2019 at 15:41

1 Answer 1


Yes the EEPROM can be written to. You can install the rpi-eeprom package and check the rpi-eeprom-update script to see how it is done. Apparently, you'll have to get the EEPROM image file from /lib/firmware/raspberrypi/bootloader/critical/, add whatever data you wanted, and then write it to the EEPROM using rpi-eeprom-update or flashrom command.

Writing procedure is detailed in applyUpdate function of rpi-eeprom-update. Here's a shortened version:

eeprom_image="$1" # must be configured with rpi-eeprom-config

[ "$(id -u)" = "0" ] || die "* Must be run as root - try 'sudo rpi-eeprom-update'"

# Bootloader EEPROM chip-select is muxed with audio pin so disable audio
# LDO first to avoid sending noise to analog audio.
/opt/vc/bin/vcmailbox 0x00030056 4 4 0 > /dev/null || true
dtparam audio=off

# Switch the SPI pins to boot EEPROM
dtoverlay spi-gpio40-45
modprobe spidev
modprobe spi-bcm2835

flashrom -p "linux_spi:dev=/dev/spidev0.0,spispeed=16000" -w "${eeprom_image}" || die "flashrom EEPROM update failed"

dtparam -R spi-gpio40-45
dtparam audio=on
/opt/vc/bin/vcmailbox 0x00030056 4 4 1 > /dev/null || true

At the time of writing, about 60% of space at the end of the bootloader image is filled with 0xFF bytes, which is a strong hint that they are unused. I'd say that the last 256KB of the bootloader image should be safe to write to. This can obviously change as new versions are released, especially once the network boot and USB boot will be implemented.

See this Raspberry Pi documentation page for more details.

If you brick the bootloader, a recovery image is available on the download page.

  • Is the bootloader ever updated? If so, this might eventually brick the Pi by going over the maximum amount of supported writes. EEPROM doesn't last forever. Of-course, this takes a while, but if somebody would continually write values to it...
    – Mast
    Oct 2, 2019 at 19:54
  • But what size is available to use without damaging the bootloader? I'm looking for some information that indicates a range of addresses available for write. Available without corrupting the bootloader. Oct 3, 2019 at 12:05
  • 1
    @Mast EEPROM chips are much more robust than consumer-grade flash, 100'000 write cycles is typical. That's one update per day for 273 years. I wouldn't worry about it. Oct 3, 2019 at 15:34
  • @AlfredoPonsMenargues In current bootloader images, the last half seems empty. I'd try writing there for a start. Oct 3, 2019 at 15:37
  • 1
    No problem, was only a question to understand things :)
    – Ingo
    Oct 4, 2019 at 12:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.