Flash ROMs with a Raspberry Pi

So when I wired things up, I connected pin 2 of the Pomona clip to GPIO pin 17, but in other guides, they use GPIO pin 1 for 3.3V. I list both because pin 17 worked for me (and I imagine any 3.3V power source might work), but in case you want an alternative pin, there it is.

Build Flashrom

There are two main ways to build flashrom. If you intend to build and flash a Libreboot image from source, you can use the version of flashrom that comes with the Libreboot source. You also can just build flashrom directly from its git repository. Either way, you first will need to pull down all the build dependencies:

$ sudo apt-get install build-essential pciutils
 ↪usbutils libpci-dev libusb-dev libftdi1
 ↪libftdi-dev zlib1g-dev subversion

If you want to build flashrom directly from its source, do this:

$ svn co svn://flashrom.org/flashrom/trunk flashrom
$ cd flashrom
$ make

Otherwise, if you want to build from the flashrom source included with Libreboot, do this:

$ git clone http://libreboot.org/libreboot.git
$ cd libreboot
$ ./download flashrom
$ ./build module flashrom

In either circumstance, at the end of the process, you should have a flashrom binary compiled for the Raspberry Pi ready to use.

Enable SPI

The next step is to load two SPI modules so you can use the GPIO pins to flash. In my case, the Raspbian image I used did not default to enabling that device at boot, so I had to edit /boot/config.txt as root and make sure that the file contained dtparam=spi=on and then reboot.

Once I rebooted, I then could load the two spi modules:

$ sudo modprobe spi_bcm2708
$ sudo modprobe spidev

Now that the modules loaded successfully, I was ready to power down the Raspberry Pi and wire everything up.


Kyle Rankin is Chief Security Officer at Purism, a company focused on computers that respect your privacy, security, and freedom. He is the author of many books including Linux Hardening in Hostile Networks, DevOps Troubleshooting and The Official Ubuntu