User:RemDogKap/SandBox/Update XSPI Flash SPL and U-Boot

From PINE64
< User:RemDogKap‎ | SandBox
Revision as of 05:21, 10 June 2023 by RemDogKap (talk | contribs) (minor grammar updates, started on updating Star64 firmware using tftpboot on Linux.)
Jump to navigation Jump to search
This page or section is under construction

Please help to review and edit this page or section. Information are subject to change.

Warning: Attempting these instructions may permanently brick (make nonfunctional) your device. Do not attempt unless you know what you are doing.
Warning: These instructions have not been tested or verified. Use at your own risk.

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 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.

$ 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, install a TFTP server.

$ sudo apt update && sudo apt install tftpd-hpa

Next, check that the TFPT server is running using systemctl.

$ sudo systemctl status tftpd-hpa

This should output somethng like

to be filled 
in later

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.


Windows