2023-07-10 15:43:08 +00:00
---
title: Generic SPI Flashing Guide
x-toc-enable: true
...
2024-01-27 22:35:38 +00:00
NOTE: Canoeboot standardises on [flashprog ](https://flashprog.org/wiki/Flashprog )
now, as of 3 May 2024, which is a fork of flashrom.
There are a plethora of single board computers with which you can flash canoeboot to a SOIC chip.
2023-07-10 15:43:08 +00:00
Some users might be daunted by the price of a raspberry pi.
This guide is intended to help users looking to use a programmer which is not listed in the [main guide. ](spi.md )
As an example, this guide will use the [libre computer 'le potato.' ](https://libre.computer/products/aml-s905x-cc/ )
2023-10-26 00:10:41 +00:00
You should note however, that this guide is intended to demonstrate how to set up any SBC with SPI programming capabilities for flashing Canoeboot.
2023-07-10 15:43:08 +00:00
If you are wondering about which SBC to buy, keep these things in mind:
+ The board *must* support SPI (look at the specs/pinout to find out if it does)
+ It is easier to use a board that supports raspbian/raspberry pi OS
+ Boards often require their own kernel patches which rarely get upstreamed
All of this means that you should try to find a board that is *known* to support SPI on an OS for which there are available images.
It is *not* enough to know that the board itself supports SPI.
Selecting an Operating System
=============================
In theory, any linux based operating system will do.
In practice, many distros are highly limited when it comes to single-board-computers.
SBCs often require specialized kernel patches which are rarely upstreamed.
Additionally, armhf boards (like the le potato) are not supported in most modern distros.
In light of the above facts, it is a good general rule to use a distro aimed at supporting SBCs.
[Armbian ](https://www.armbian.com/ ) is one such distro you might use.
Note that not all armbian images support SPI.
If your SBC supports [Raspbian ](https://www.raspberrypi.com/software/ ) then using it will make your work much easier.
As a bonus, you may refer to the [main guide ](spi.md ) if the SBC you have supports raspbian, should you get confused with this guide.
Connecting to your Programmer
=============================
Many SBC operating systems enable ssh by default.
If the OS you chose does not enable ssh on first boot, try checking the distro documentation and looking for terms such as 'headless install.'
You will need the IP address of your programmer to continue.
Connecting via ethernet is generally easier than doing so with WiFi.
Check your distro's docs if you wish to connect with WiFi only.
To determine the IP address of your programmer, log in to your AP/Router web interface.
If you're not sure the IP address of your AP, it is likely `192.168.1.1.`
2024-05-10 03:37:48 +00:00
You can determine the correct IP address with `ip r` on a GNU+Linux system.
2023-07-10 15:43:08 +00:00
You should see your programmer somewhere on the homepage, depending on your router firmware.
This author recommends using [https://openwrt.org/ ](https://openwrt.org/ ) for your router firmware.
SSH to your programmer using the default credentials as specified in your distro's docs.
The IP address is the one determined in the earlier step.
For example:
`ssh root@192.168.0.167`
Finding GPIO Pins
=================
If you have determined that a board supports SPI then the only step left is to
determine the correct location of the SPI pins.
The board will have the pinout in its documentation.
The Le potato board has the same pinout as the raspberry pi so you can refer to the [main SPIC documentation. ](spi.md#gpio-pins-on-raspberry-pi-rpi-40-pin )
If your board is not raspberry pi compatible, refer to the [wiring table. ](spi.html#soic8dip8wson8-wiring-diagram )
Match each of the categories in the 'signal' column with those in the 'pin' column.
Using this method, you can theoretically use any single board computer with SPI support.
Enabling SPI
============
The modules needed and methods to enable SPI vary based on the SBC you choose.
You should always make sure there is a well documented method for enabling SPI on your SBC before purchasing.
In the case of the *le potato,* SPI is enabled by activating the correct overlays as such (raspbian):
```
sudo ldto enable spicc spicc-spidev
sudo ldto merge spicc spicc-spidev
```
2024-01-27 22:35:38 +00:00
Using Flashprog
2023-07-10 15:43:08 +00:00
==============
extreme cleanup / grandiose gesture
make canoeboot a truly GNU FSDG compliant coreboot distro,
by removing all overly positive reference to Libreboot;
what remains is technical in nature, so as to provide
historical context since Canoeboot is a fork of Libreboot.
I've stated before that I wish to take a more neutral tone
toward the FSF, in contrast to the *coldboot war* of 2023
when GNU Boot started.
Canoeboot was heavily linking to Libreboot, even going so far
as to call itself "inferior" and tell the reader to use
Libreboot.
From now on, Canoeboot will be maintained as though I actually
believed in FSF propoganda. I don't, but its users do. Treat
them with respect. My reason for providing Canoeboot is
precisely that I wish for such people to have a high quality
coreboot distro, much unlike the inferior *GNU Boot* project;
inferior because to this day, it's still based on very old
Libreboot, with not much changed (of any real substance)
relative to the Libreboot 20220710 release on which it forked.
In general, I've also found a lot of stragglers from when
Canoeboot started, where paragraphs referred to Libreboot that
should have actually referred to Canoeboot, or paragraphs
with Libreboot-specific information that does not make sense
in the Canoeboot project e.g. references to vendor scripts.
The resulting canoeboot.org will now look no different to any
typical reader than a typical FSF-aligned project.
There is a next stage to this, which will become apparent to
everyone if I have my way.
Signed-off-by: Leah Rowe <info@minifree.org>
2024-05-10 02:12:44 +00:00
Some GNU+Linux distros will provide flashprog in their default repositories.
2023-07-10 15:43:08 +00:00
```
sudo apt update
2024-01-27 22:35:38 +00:00
sudo apt install flashprog
2023-07-10 15:43:08 +00:00
```
Reading/writing from SPI works respectively as such:
```
2024-01-27 22:35:38 +00:00
sudo ./flashprog -p linux_spi:dev=/dev/spidev0.0,spispeed=32768 -r /path/to/read.bin
sudo ./flashprog -p linux_spi:dev=/dev/spidev0.0,spispeed=32768 -w /path/to/canoeboot.rom
2023-07-10 15:43:08 +00:00
```
Note that `spispeed` varies based on the board in question.
A standard lower limit is *512.*
For example, to read on a board with a lower SPI speed, you may try:
2024-01-27 22:35:38 +00:00
sudo ./flashprog -p linux_spi:dev=/dev/spidev0.0,spispeed=512 -r /path/to/read.bin