What is the SPI flash
The SPI flash is a small memory chip soldered in a few of the PINE64 devices. This is a flash storage chip with a size between 16 and 128 Megabytes usually and is intended to store a bootloader that can start an operating system from the SD or eMMC storage.
The main upside of this over storing the bootloader (usually u-boot) on the start of the SD or eMMC is that the SPI bootloader can be relied on to be Just Working™ since it's written once and is not accidentally overwritten again.
Why is it needed
For development, and even end-users it's pretty common to wipe entire disks and flash a new operating system to the device, the fact that this is possible is one of the reasons why the PINE64 devices are so great.
For the PinePhone (original edition) the built-in boot order of the Allwinner A64 SoC just happened to be SD first, then eMMC. This made testing a distribution or recovering an installation very easy since having a functional operating system with bootloader on the SD card will take priority when booting. This made the PinePhone basically unbrickable.
The PinePhone Pro and the other Rockchip rk3399 based devices like the Pinebook Pro have a different boot order in hardware. The eMMC is tried first and then the SD card is tried. This isn't a huge problem until the installation on the eMMC storage is broken. Usually the u-boot identifier survives on the start of the disk but parts of the operating system or rest of the bootloader might be broken. In this case hardware will see the u-boot signature on the eMMC and start it and never try the SD card. This makes the SD card for recovery impossible.
Another upside for an SPI flash chip with the bootloader is that not every single distribution needs to maintain the full boot firmware stack for all the devices. At this moment most distributions are shipping their own build of u-boot for every PINE64 device and those are all slightly different. Some might be patched to have different boot orders, some might be patched to have the display working to have proper multiboot support. This work could be de-duplicated and one known good working fully featured u-boot could be deployed to the SPI flash and give some consistency to end-users.
Where is the SPI used already
Some PINE64 devices have the SPI flash chip present already and some batches have just a footprint on the PCB with the part populated. This is a list of projects using the SPI chip already on these devices.
- Tow-Boot is a distribution of u-boot that tries to provide a consistent boot interface for ARM devices. This is also a great option to be the "standard" u-boot flashed to the SPI of new devices. This has support at the moment for the Pinebook Pro and the A64 SBC.
- postmarketOS supports writing the postmarketOS u-boot build to the SPI flash of the Pinebook Pro to have a sane booting environment. This is a build that is tuned to be generic and not postmarketOS branded. This also adjusts the boot order to SD then eMMC instead of the default rk3399 boot order.
- For Fedora it's needed to flash an u-boot to the SPI to make it work nicely on the Pinebook Pro.
- For the Rockpro64 there's ayufan u-boot that has made booting the rockpro64 nice for years now and has been a nice way to get a bootloader running on this SBC that can start more or less generic distributions.