User:RemDogKap/SandBox/Update XSPI Flash SPL and U-Boot
Please help to review and edit this page or section. Information are subject to change.
The Star64 ships with an integrated 128 megabit (16 megabyte) xSPI NOR flash. Loaded on this flash from the factory is firmware called U-Boot and SPL but an old version designed for the StarFive VisionFive 2 SBC which may have incompatibilities with the Star64. The firmware on this flash is known as Das U-Boot, commonly just U-Boot which is an open-source primary boot loader. It performs similar functions to the BIOS on x86 platforms. The SPL or Secondary Program Loader is the software that loads U-Boot, which in turn loads the Linux kernel.
There are two main ways to update the xSPI flash. The first uses the flashcp
command which requires the Star64 to first boot into an OS. This method may not work on older versions of [firmware, os, something else????]. The other method requires only the ability to load U-Boot and uses TFTP and the U-Boot tftpboot
command.
Prerequisites
Required:
- Star64 SBC
- Computer running Linux, MacOS, or Windows
Possibly required:
- Ability to communicate over TTL (transistor to transistor logic) UART
- Ability to network the Star64 to a computer over ethernet
flashcp
First, connect to your Star64 over UART or with a mouse, keyboard, and monitor.
Next, install the mtd-utils
package onto the Star64 if not already installed. This package is a set of tools that allow access to raw flash storage devices such as the xSPI flash. Also install wget
if not already installed. These instructions assume that you are using the deb
package manager.
$ sudo apt update && sudo apt install mtb-utils wget
Next, using wget
download the .bin.normal.out
SPL file and the .img
U-Boot image onto the.
$ wget https://pine64.my-ho.st:8443/[fishwaldo SPL file goes here] $ wget https://pine64.my-ho.st:8443/[fishwaldo U-Boot image goes here]
Next, print out the list of MTD (Memory Technology Device) raw flash devices using cat
.
$ cat /proc/mtd
The output should look something like this:
dev: size erasesize name mtd0: 00020000 00001000 "spl" mtd1: 00300000 00001000 "uboot" mtd2: 00100000 00001000 "data"
Finally, write the .bin.normal.out
SPL file and the .img
U-Boot image. to the respective partitions using flashcp
, a command which writes to raw flash devices with more protections than dd
.
$ flashcp -v [fishwaldo spl file name here].bin.normal.out /dev/${SPL Partition} $ flashcp -v [fishwaldo uboot img file name here].img /dev/${U-Boot Partition}
Where ${SPL Partition}
is the partition name found under the "dev" column for the row "spl" from the cat printout, in this case mtd0
and ${U-Boot Partition}
is the partition name found under the "dev" column for the row "uboot" in the cat printout, in this case mtd1
At this point your xSPI flash has been rewritten and only a system restart is needed for the changes to take effect.
tftpboot
The tftpboot
method uses a TFTP (Trivial File Transfer Protocol, a protocol which allows for basic file transfer functionality without authentication) server to transfer the SPL file and U-Boot image from a host computer to the Star64 running U-Boot and using the tftpboot
command and then written to flash using the sf
command which is a U-Boot command used to access SPI flash.
Linux
First, on your computer (not the Star64) install a TFTP server and wget
if you do not already have it.
$ sudo apt update && sudo apt install tftpd-hpa wget
Next, check that the TFPT server is running using systemctl
.
$ sudo systemctl status tftpd-hpa
This should output somethng like
● tftpd-hpa.service - LSB: HPA's tftp server Loaded: loaded (/etc/init.d/tftpd-hpa; generated) Active: active (running) since Sat 2023-06-10 20:51:28 CDT; 17min ago Docs: man:systemd-sysv-generator(8) Process: 1016 ExecStart=/etc/init.d/tftpd-hpa start (code=exited, status=0/SUCCESS) Tasks: 1 (limit: 2306) Memory: 588.0K CPU: 23ms CGroup: /system.slice/tftpd-hpa.service └─1023 /usr/sbin/in.tftpd --listen --user tftp --address :69 --secure /srv/tftp Jun 10 20:51:28 debian-bookworm systemd[1]: Starting tftpd-hpa.service - LSB: HPA's tftp server... Jun 10 20:51:28 debian-bookworm tftpd-hpa[1016]: Starting HPA's tftpd: in.tftpd. Jun 10 20:51:28 debian-bookworm systemd[1]: Started tftpd-hpa.service - LSB: HPA's tftp server.
If the service is not running, try
$ sudo systemctl start tftpd-hpa
and check the status again. If it is still not running please join the #star64 channel in the Pine64 IRC, Discord, or Matrix.
Next, edit the configuration file for tftpd-hpa
.
$ sudo nano /etc/default/tftpd-hpa
by default it should look like:
# /etc/default/tftpd-hpa TFTP_USERNAME="tftp" TFTP_DIRECTORY="/srv/tftp" TFTP_ADDRESS=":69" TFTP_OPTIONS="--secure"
Change TFTP_DIRECTORY="/srv/tftp"
to TFTP_DIRECTORY="/home/user/tftp_share"
. The final file should look like:
TFTP_USERNAME="tftp" TFTP_DIRECTORY="/home/user/tftp_share" TFTP_ADDRESS=":69" TFTP_OPTIONS="--secure"
After that, save and close the file then restart the TFTP server.
$ sudo systemctl restart tftpd-hpa
Next in your home directory (/home/user
) create a folder called tftp_share
$ mkdir /home/user/tftp_share
In this folder, download the .bin.normal.out
SPL file and the .img
U-Boot image using wget
.
$ cd /home/user/tftp_share $ wget https://pine64.my-ho.st:8443/[fishwaldo SPL file goes here] $ wget https://pine64.my-ho.st:8443/[fishwaldo U-Boot image goes here]