This document exists as a guide for reading from or writing to an SPI flash chip with the BeagleBone Black, using the flashrom software. A BeagleBone Black, rev. C was used when creating this guide, but earlier revisions may also work.
NOTE: Use of BeagleBone black is for example purposes only, don’t buy it unless you want it specifically. There are many ARM Single Board Computers (SBC) that are capable of in system programming (external flashing) and they perform similarly terrible at that task. Common use of devicetrees on those devices allows for configuring them in similar way, but not identical, so a bit of own research is required. Lastly SBC is an example of self-contained device that is capable of flashing, but it’s possible to use smaller device like stm32 bluepill with another computer to achieve similar result.
Note: This guide was written for Debian Stretch 9.5, which is the latest operating system for the BeagleBone Black as of June 2019. It is possible that these instructions may be outdated if newer operating systems versions have been released since then.
There was no justification for a further section for the Teensy. Simply refer to this page on flashrom.org for information about how to set it up, and correlate that with the pins on the SPI flash chip as per other guides in the libreboot documentation for each board. At the time of writing, the teensy is tested for flashing on the ThinkPad X200, but it should work for other targets. here is a photo of the setup for the teensy: http://h5ai.swiftgeek.net/IMG_20160601_120855.jpg
Onto the Beaglebone black…
Shopping list (pictures of this hardware is shown later):
A Flashrom-compatible external SPI programmer: BeagleBone Black, sometimes referred to as ‘BBB’, (rev. C) is highly recommended. You can buy one from Adafruit (USA), ElectroKit (Sweden) or any of the distributors listed on BeagleBoard’s website (look below ‘Purchase’). We recommend this product because we know that it works well for our purposes and doesn’t require any non-free software.
FTDI TTL cable or debug board: used for accessing the serial console on the BBB. This page contains a list. OPTIONAL-–only needed for serial console on the BBB, if not using SSH via ethernet cable.
ATX PSU pinouts can be read on this Wikipedia page.
You can use pin 1 or 2 (orange wire) on a 20-pin or 24-pin ATX PSU for 3.3V, and any of the ground/earth sources (black cables) for ground. Short PS_ON# / Power on (green wire; pin 16 on 24-pin ATX PSU, or pin 14 on a 20-pin ATX PSU) to a ground (black; there is one right next to it) using a wire/paperclip/jumper, then power on the PSU by grounding PS_ON# (this is also how an ATX motherboard turns on a PSU).
DO NOT use pin 4, 6, do NOT use pin 19 or 20 (on a 20-pin ATX PSU), and DO NOT use pin 21, 22 or 23 (on a 24-pin ATX PSU). Those wires (the red ones) are 5V, and they WILL kill your flash chip. NEVER supply more than 3.3V to your flash chip (that is, if it’s a 3.3V flash chip; 5V and 1.8V SPI flash chips do exist, but they are rare. Always check what voltage your chip takes. Most of them take 3.3V).
You only need one 3.3V supply and one ground for the flash chip, after grounding PS_ON#.
The male end of a 0.1" or 2.54mm header cable is not thick enough to remain permanently connected to the ATX PSU on its own. When connecting header cables to the connector on the ATX PSU, use a female end attached to a thicker piece of wire (you could use a paper clip), or wedge the male end of the jumper cable into the sides of the hole in the connector, instead of going through the centre.
Here is an example set up:
Follow the Getting Started instructions to install the latest version of Debian onto the BBB. It is recommended to download the eMMC IoT Flasher edition, which will write its image to the on-board eMMC.
The operating system on the BBB can be accessed over SSH, with username ‘debian’ and password ‘temppwd’. Follow the instructions on the Getting Started page for complete details.
You will also be using the OS on your BBB for programming an SPI flash chip.
You can also use a serial FTDI debug board with GNU Screen, to access the serial console. # screen /dev/ttyUSB0 115200
Here are some example photos:
You can also connect the USB cable from the BBB to another computer and a new network interface will appear, with its own IP address. This is directly accessible from SSH, or screen:
# screen /dev/ttyACM0 115200
You can also access the uboot console, using the serial method instead of SSH.
Log in to the BBB using either SSH or a serial console as described in #bbb_access.
Note: The following commands are run as root. To run them from a normal user account, add yourself to the
gpio group to configure the pins and the
spi group to access spidev.
Run the following commands to enable spidev:
# config-pin P9.17 spi_cs # config-pin P9.18 spi # config-pin P9.21 spi # config-pin P9.22 spi_sclk
Verify that the spidev devices now exist:
# ls /dev/spidev*
/dev/spidev1.0 /dev/spidev1.1 /dev/spidev2.0 /dev/spidev2.1
Now the BBB is ready to be used for flashing. The following systemd service file can optionally be enabled to make this persistent across reboots.
[Unit] Description=Enable SPI function on pins [Service] Type=oneshot ExecStart=config-pin P9.17 spi_cs ExecStart=config-pin P9.18 spi ExecStart=config-pin P9.21 spi ExecStart=config-pin P9.22 spi_sclk RemainAfterExit=yes [Install] WantedBy=multi-user.target
Get flashrom from the libreboot_util release archive, or build it from libreboot_src/git if you need to. An ARM binary (statically compiled) for flashrom exists in libreboot_util releases. Put the flashrom binary on your BBB.
You may also need ich9gen, if you will be flashing an ICH9-M laptop (such as the X200). Get it from libreboot_util, or build it from libreboot_src, and put the ARM binary for it on your BBB.
Finally, get the ROM image that you would like to flash and put that on your BBB.
Now test flashrom:
# ./flashrom -p linux_spi:dev=/dev/spidev1.0,spispeed=512
Calibrating delay loop... OK. No EEPROM/flash device found. Note: flashrom can never write if the flash chip isn't found automatically.
This means that it’s working (the clip isn’t connected to any flash chip, so the error is fine).
Use this image for reference when connecting the pomona to the BBB: http://beagleboard.org/Support/bone101#headers (D0 = MISO or connects to MISO).
The following shows how to connect clip to the BBB (on the P9 header), for SOIC-16 (clip: Pomona 5252):
NC - - 21 1 - - 17 NC - - NC NC - - NC NC - - NC NC - - NC 18 - - 3.3V (PSU) 22 - - NC - this is pin 1 on the flash chip This is how you will connect. Numbers refer to pin numbers on the BBB, on the plugs near the DC jack. You may also need to connect pins 1 and 9 (tie to 3.3V supply). These are HOLD# and WP#. On some systems they are held high, if the flash chip is attached to the board. If you're flashing a chip that isn't connected to a board, you'll almost certainly have to connect them. SOIC16 pinout (more info available online, or in the datasheet for your flash chip): HOLD 1-16 SCK VDD 2-15 MOSI N/C 3-14 N/C N/C 4-13 N/C N/C 5-12 N/C N/C 6-11 N/C SS 7-10 GND MISO 8-9 WP
The following shows how to connect clip to the BBB (on the P9 header), for SOIC-8 (clip: Pomona 5250):
18 - - 1 22 - - NC NC - - 21 3.3V (PSU) - - 17 - this is pin 1 on the flash chip This is how you will connect. Numbers refer to pin numbers on the BBB, on the plugs near the DC jack. You may also need to connect pins 3 and 7 (tie to 3.3V supply). These are HOLD# and WP#. On some systems they are held high, if the flash chip is attached to the board. If you're flashing a chip that isn't connected to a board, you'll almost certainly have to connect them. SOIC8 pinout (more info available online, or in the datasheet for your flash chip): SS 1-8 VDD MISO 2-7 HOLD WP 3-6 SCK GND 4-5 MOSI
NC = no connection
DO NOT connect 3.3V (PSU) yet. ONLY connect this once the pomona is connected to the flash chip.
You also need to connect the BLACK wire (ground/earth) from the 3.3V PSU to pin 2 on the BBB (P9 header). It is safe to install this now (that is, before you connect the pomona to the flash chip); in fact, you should.
if you need to extend the 3.3v psu leads, just use the same colour M-F leads, but keep all other leads short and equal length (30cm or less). Keep in mind that length isn’t inversely proportional to signal quality, so trying out different lengths will yield different results. Same goes for spispeed.
You should now have something that looks like this:
Copyright © 2014, 2015 Leah Rowe email@example.com
Copyright © 2015 Patrick “P. J.” McDermott firstname.lastname@example.org
Copyright © 2015 Albin Söderqvist
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License Version 1.3 or any later version published by the Free Software Foundation with no Invariant Sections, no Front Cover Texts, and no Back Cover Texts. A copy of this license is found in ../fdl-1.3.html
Edit this page – License – Template – Authors – Conduct Guidelines – Governance – Peers Community