From Fedora Project Wiki
m (Abologna moved page Architectures/RISC-V/VisionFive2 to Architectures/RISC-V/StarFive/VisionFive2: Organize boards by vendor)
(Simplified page by removing obsolete / duplicated information)
 
Line 1: Line 1:
This page provides instructions how to install Fedora 40 (or newer) on StarFive VisionFive 2 (JH7110) SBC. The instructions assume that main partitions will be on M.2 NVMe. microSD card is not required, but can be used to flash SPI-NOR firmware with a new U-Boot and OpenSBI.
This page explains how to get Fedora running on the StarFive VisionFive 2 board.


You can place the main partitions on microSD card instead of M.2 NVMe if you don't have one.
= Machine-specific instructions =


This guide assumes that your host system is running Fedora 40 (or newer).
For the most part you can just follow the [[Architectures/RISC-V/Installing|generic instructions]].


Default accounts:
== Requirements ==
* `root`:`linux`
* `riscv`:`fedora_rocks!` (groups: `wheel` and `mock`)


Web console (cockpit) should be available at 9090 port (exact link will be printed on the serial console and SSH login).
=== Firmware ===


`root` account will not work with SSH and web console. Use `riscv` account.
You need to replace the vendor firmware with the one built in Fedora. This version contains additional features and is based on a more recent U-Boot release.


You can find initial VisionFive 2 Fedora 40 disk images here:
Note that the firmware you will be installing can boot most modern UEFI-based distros (e.g. Ubuntu) just fine, but it cannot (at least out of the box) boot the vendor provided Debian-based image. It's always possible to revert back to the vendor firmware later if desired.
https://dl.fedoraproject.org/pub/alt/risc-v/disk_images/Fedora-40/VisionFive2/
 
Firmware builds can be obtained from:
 
* http://fedora.riscv.rocks/repos-dist/f41-staging/latest/riscv64/Packages/u/
 
As of this writing, the most recent firmware build is:
 
* [http://fedora.riscv.rocks/repos-dist/f41-staging/latest/riscv64/Packages/u/uboot-images-riscv64-2024.10-1.0.riscv64.fc41.noarch.rpm <code>uboot-images-riscv64-2024.10-1.0.riscv64.fc41.noarch.rpm</code>]
 
The file you've just downloaded will be referred to as <code>UBOOT.rpm</code> below.
 
To extract the contents of the package, run:
 
<pre>
$ rpm2cpio UBOOT.rpm | cpio -id
</pre>
 
You can now update the board's SPI-NOR flash:
 
<pre>
$ sudo flashcp -v usr/share/uboot/starfive_visionfive2/spl/u-boot-spl.bin.normal.out /dev/mtd0
Erasing blocks: 3/3 (100%)
Writing data: 137k/137k (100%)
Verifying data: 137k/137k (100%)
 
$ sudo flashcp -v usr/share/uboot/starfive_visionfive2/u-boot.itb /dev/mtd2
Erasing blocks: 16/16 (100%)
Writing data: 989k/989k (100%)
Verifying data: 989k/989k (100%)
</pre>
 
One last step is necessary to complete the upgrade. Reset the machine, but interrupt the boot process before any entry is chosen to get access to the U-Boot prompt. If you're having trouble with this part, disconnecting all storage devices could help.
 
At the U-Boot prompt, type the following commands:
 
<pre>
StarFive # env default -f -a; env save
## Resetting to default environment
Saving Environment to SPIFlash... Erasing SPI flash...Writing to SPI flash...done
OK
</pre>
 
You've now completed the firmware update process and can proceed with installing Fedora.
 
This is the simplest way to update the firmware, which works if you already have Linux running. For an alternative method, see [[#Installing SPI-NOR firmware via UART boot mode|below]].
 
== Post-installation tasks ==
 
=== Access U-Boot environment from Linux ===
 
Add the following the the `/etc/fw_env.config` file:
 
<pre>
/dev/mtd1 0x0 0x10000
</pre>
 
You will now be able to use `fw_printenv` and `fw_setenv` to manipulate the U-Boot environment from within Linux.
 
== Additional information ==
 
=== Installing SPI-NOR firmware via UART boot mode ===


=Installing SPI-NOR firmware via UART boot mode=
This method allows to boot upstream U-Boot SPL (XMODEM) and U-Boot proper (YMODEM) using your serial console. This is especially helpful is SPI-NOR content is damaged and the board no longer boots. Once booted you can flash SPI-NOR with a new firmware images.
This method allows to boot upstream U-Boot SPL (XMODEM) and U-Boot proper (YMODEM) using your serial console. This is especially helpful is SPI-NOR content is damaged and the board no longer boots. Once booted you can flash SPI-NOR with a new firmware images.


SPI-NOR partitions:
SPI-NOR partitions:
<pre>
<pre>
# cat /proc/mtd
$ cat /proc/mtd
dev:    size  erasesize  name
dev:    size  erasesize  name
mtd0: 00080000 00010000 "spl"
mtd0: 00080000 00010000 "spl"
Line 27: Line 85:
mtd2: 00400000 00010000 "uboot"
mtd2: 00400000 00010000 "uboot"
mtd3: 00a00000 00010000 "reserved-data"
mtd3: 00a00000 00010000 "reserved-data"
</pre>
<pre>
[..]
partitions {
        compatible = "fixed-partitions";
        #address-cells = <1>;
        #size-cells = <1>;
        spl@0 {
                reg = <0x0 0x80000>;
        };
        uboot-env@f0000 {
                reg = <0xf0000 0x10000>;
        };
        uboot@100000 {
                reg = <0x100000 0x400000>;
        };
        reserved-data@600000 {
                reg = <0x600000 0xa00000>;
        };
};
[..]
</pre>
</pre>


Line 55: Line 90:


Connect UART-Serial to USB dongle to VF2 using GPIO headers (3V3):
Connect UART-Serial to USB dongle to VF2 using GPIO headers (3V3):
* PIN 6: GND
* PIN 6: GND
* PIN 8: UART-TX
* PIN 8: UART-TX
Line 62: Line 98:
https://doc-en.rvspace.org/VisionFive2/Quick_Start_Guide/VisionFive2_SDK_QSG/recovering_bootloader%20-%20vf2.html
https://doc-en.rvspace.org/VisionFive2/Quick_Start_Guide/VisionFive2_SDK_QSG/recovering_bootloader%20-%20vf2.html


Check `dmesg` or `usb-devices` output for a new device (could be written as "UART", "Serial", etc.).
Switch the board to UART boot mode:


Your USB serial port adapter will be `/dev/ttyUSB<NUMBER>` and `/dev/serial/by-id/<NAME>`. The latter name is generated base d on vendor, product name, serial code of your USB serial port adapter.
These devices are in `dialout` group. If you don't want to use `sudo` and your user to this group:
<pre>
usermod -aG dialout <USERNAME>
</pre>
We will use `minicom` for serial console. Let's launch it with `minicom -s` for setup:
<pre>
+-----[configuration]------+
| Filenames and paths      |
| File transfer protocols  |
| Serial port setup        |
| Modem and dialing        |
| Screen and keyboard      |
| Save setup as dfl        |
| Save setup as..          |
| Exit                    |
| Exit from Minicom        |
+--------------------------+
</pre>
Select `Serial port setup`. Press `A` and modify the path for your USB serial port adapter. Hit `ENTER` until you return to the original menu. Then choose `Exit` to start.
Switch the board to UART boot mode:
<pre>
<pre>
  1 (High)  0 (Low)                 
  1 (High)  0 (Low)                 
Line 103: Line 114:


Let's use microSD card with FAT or ext4 partition to store new firmware files:
Let's use microSD card with FAT or ext4 partition to store new firmware files:
* `u-boot-spl.bin.normal.out` (U-Boot SPL) '''[REQUIRED]'''
* `u-boot.itb` (U-Boot, OpenSBI, DTB) '''[REQUIRED]'''
* `uboot-env.bin` (default U-Boot environment in binary format) '''[OPTIONAL]'''


All required files can be found in `uboot-images-riscv64` (noarch) package. It's also installed in the disk image.
* `u-boot-spl.bin.normal.out` (U-Boot SPL)
* `u-boot.itb` (U-Boot, OpenSBI, DTB)
 
These are the files mentioned [[#Firmware|above]].


Remove M.2 NVMe if installed. We don't want to have bootable media in any form otherwise Linux will boot before you can get to U-Boot prompt.
Remove M.2 NVMe if installed. We don't want to have bootable media in any form otherwise Linux will boot before you can get to U-Boot prompt.
Line 114: Line 125:


You should see similar output:
You should see similar output:
<pre>
<pre>
(C)StarFive
(C)StarFive
CCCCCCCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCCCCCCC
</pre>
</pre>
It will constantly write `C`.
It will constantly write `C`.


Press `CTRL-A S`. You will see upload menu:
Press `CTRL-A S`. You will see upload menu:
<pre>
<pre>
+-[Upload]--+
+-[Upload]--+
Line 130: Line 144:
+-----------+
+-----------+
</pre>
</pre>
Select `xmodem`, then `[Goto]` button at the bottom. Enter directory were you have downloaded your U-Boot firmware files. Select `u-boot-spl.bin.normal.out` using `SPACE` and then active `[Okay]` button. It will start uploading the first binary:
 
Select `xmodem`, then `[Goto]` button at the bottom. Select `u-boot-spl.bin.normal.out` using `SPACE` and then press the `[Okay]` button. It will start uploading the first binary:
 
<pre>
<pre>
+----------------[xmodem upload - Press CTRL-C to quit]----------------+
+----------------[xmodem upload - Press CTRL-C to quit]----------------+
Line 142: Line 158:
+----------------------------------------------------------------------+
+----------------------------------------------------------------------+
</pre>
</pre>
Press any key once it's uploaded. Now you should see U-Boot SPL booted and `C` will continue to be printed out:
Press any key once it's uploaded. Now you should see U-Boot SPL booted and `C` will continue to be printed out:
<pre>
<pre>
U-Boot SPL 2024.10-rc2 (Aug 22 2024 - 00:00:00 +0000)
U-Boot SPL 2024.10 (Nov 07 2024 - 00:00:00 +0000)
DDR version: dc2e84f0.
DDR version: dc2e84f0.
Trying to boot from UART
Trying to boot from UART
CCCCCCCCC
CCCCCCCCC
</pre>
</pre>
Now press `CTRL-A S` and select `ymodem`. This time we want to send `u-boot.itb` file. This file is large and thus will take a bit longer to upload.
Now press `CTRL-A S` and select `ymodem`. This time we want to send `u-boot.itb` file. This file is large and thus will take a bit longer to upload.
<pre>
<pre>
+----------------[ymodem upload - Press CTRL-C to quit]----------------+
+----------------[ymodem upload - Press CTRL-C to quit]----------------+
Line 161: Line 181:
+----------------------------------------------------------------------+
+----------------------------------------------------------------------+
</pre>
</pre>
U-Boot will not find any bootable media and will drop you into the prompt.
U-Boot will not find any bootable media and will drop you into the prompt.
<pre>
<pre>
Loading Boot0000 'mmc 1' failed
Loading Boot0000 'mmc 1' failed
Line 169: Line 191:
StarFive #
StarFive #
</pre>
</pre>
Check the content of microSD card:
Check the content of microSD card:
<pre>
<pre>
StarFive # ls mmc 1:1
StarFive # ls mmc 1:1
Line 177: Line 201:
         1151019 u-boot.itb
         1151019 u-boot.itb
           146178 u-boot-spl.bin.normal.out
           146178 u-boot-spl.bin.normal.out
          65536 uboot-env.bin
</pre>
</pre>
Update U-Boot SPL and U-Boot data:
Update U-Boot SPL and U-Boot data:
<pre>
<pre>
sf probe
sf probe
Line 189: Line 214:
sf update ${loadaddr} 0x100000 ${ldsize}
sf update ${loadaddr} 0x100000 ${ldsize}
</pre>
</pre>
We booted using UART mode with the same files thus we can update default U-Boot environment too:
We booted using UART mode with the same files thus we can update default U-Boot environment too:
<pre>
<pre>
# env default -a -f; env save
# env default -a -f; env save
Line 196: Line 223:
OK
OK
</pre>
</pre>
Alternative would be to load `uboot-env.bin` from microSD card and write it out:
 
<pre>
Remove power cable and microSD card.
load mmc 1:1 ${loadaddr} uboot-env.bin
 
setenv ldsize ${filesize}
Switch back to SPI-NOR boot mode:
sf update ${loadaddr} 0xf0000 ${ldsize}
 
</pre>
Let's shutdown the system for now with `poweroff` command.
Remove power cable.
Remove the microSD card.
Switch to SPI-NOR boot mode:
<pre>
<pre>
  1 (High)  0 (Low)                 
  1 (High)  0 (Low)                 
Line 214: Line 236:
│      │ │XXXXXXX│ RGPIO_0: 1 (H)
│      │ │XXXXXXX│ RGPIO_0: 1 (H)
└───────┘ └───────┘               
└───────┘ └───────┘               
</pre>
=Prepare main system drive (M.2 NVMe or microSD) =
Download the latest Fedora 40 disk image. There are multiple way to write RAW disk image to a drive. One of them is using `dd` tool:
<pre>
sudo dd if=./Fedora.riscv64-Rawhide_server_20240826.n.0.raw of=/dev/<YOUR_DRIVE> bs=512K iflag=fullblock oflag=direct conv=fsync status=progress
</pre>
It's highly import to ensure that a proper `of=` device is used otherwise you could damage your host system and loose all the data.
You can also use GNOME Disks application. It has "Restore Disk Image.." once a drive is selected.
This image can be flashed to microSD or M.2 NVMe, and it will work the same way.
=Post Install=
At this stage you should be able to boot Fedora 40 with firmware on SPI-NOR flash and NVMe for the system partitions.
Our filesystem is not using a full drive capacity:
<pre>
[root@localhost ~]# btrfs filesystem usage -T /
Overall:
    Device size:                  3.53GiB
    Device allocated:              2.68GiB
    Device unallocated:          874.98MiB
    Device missing:                  0.00B
    Device slack:                  3.50KiB
    Used:                          1.67GiB
    Free (estimated):              1.49GiB      (min: 1.06GiB)
    Free (statfs, df):            1.49GiB
    Data ratio:                      1.00
    Metadata ratio:                  2.00
    Global reserve:                5.50MiB      (used: 0.00B)
    Multiple profiles:                  no
                  Data    Metadata  System
Id Path          single  DUP      DUP      Unallocated Total  Slack
-- -------------- ------- --------- -------- ----------- ------- -------
1 /dev/nvme0n1p3 2.16GiB 512.00MiB 16.00MiB  874.98MiB 3.53GiB 3.50KiB
-- -------------- ------- --------- -------- ----------- ------- -------
  Total          2.16GiB 256.00MiB  8.00MiB  874.98MiB 3.53GiB 3.50KiB
  Used          1.53GiB  73.53MiB 16.00KiB
</pre>
Expand it to full disk capacity:
<pre>
[root@localhost ~]# growpart /dev/nvme0n1 3
CHANGED: partition=3 start=3074048 old: size=7411679 end=10485726 new: size=1950451087 end=1953525134
[root@localhost ~]# btrfs filesystem resize max /
Resize device id 1 (/dev/nvme0n1p3) from 3.53GiB to max
[  554.546967] BTRFS info (device nvme0n1p3): resize device /dev/nvme0n1p3 (devid 1) from 3794776064 to 998630952960
[root@localhost ~]# btrfs filesystem usage -T /
Overall:
    Device size:                930.05GiB
    Device allocated:              2.68GiB
    Device unallocated:          927.37GiB
    Device missing:                  0.00B
    Device slack:                  3.50KiB
    Used:                          1.67GiB
    Free (estimated):            928.00GiB      (min: 464.32GiB)
    Free (statfs, df):          928.00GiB
    Data ratio:                      1.00
    Metadata ratio:                  2.00
    Global reserve:                5.50MiB      (used: 0.00B)
    Multiple profiles:                  no
                  Data    Metadata  System
Id Path          single  DUP      DUP      Unallocated Total    Slack
-- -------------- ------- --------- -------- ----------- --------- -------
1 /dev/nvme0n1p3 2.16GiB 512.00MiB 16.00MiB  927.37GiB 930.05GiB 3.50KiB
-- -------------- ------- --------- -------- ----------- --------- -------
  Total          2.16GiB 256.00MiB  8.00MiB  927.37GiB 930.05GiB 3.50KiB
  Used          1.53GiB  73.53MiB 16.00KiB
</pre>
Change default passwords for `root` and `riscv` users using `passwd` command.
You can access U-Boot default environment from Linux by creating a file `/etc/fw_env.config` with:
<pre>
/dev/mtd1 0x0 0x10000
</pre>
Command `fw_printenv` will print full environment, and `fw_setenv` will allow you to modify it without booting into U-Boot.
Change default hostname:
<pre>
hostnamectl set-hostname <HOSTNAME>
</pre>
Next time you want to update firmware you can do that from Linux user space. Check SPI-NOR partitioning:
<pre>
[root@fedora-riscv ~]# cat /proc/mtd
dev:    size  erasesize  name
mtd0: 00080000 00010000 "spl"
mtd1: 00010000 00010000 "uboot-env"
mtd2: 00400000 00010000 "uboot"
mtd3: 00a00000 00010000 "reserved-data"
</pre>
Use `flashcp` command:
<pre>
flashcp -v u-boot-spl.bin.normal.out /dev/mtd0
flashcp -v u-boot.itb /dev/mtd2
</pre>
Boot into U-Boot, load default environment and write it out to SPI-NOR flash.
You can find firmware files on your disk image:
<pre>
# rpm -ql uboot-images-riscv64
[..]
/usr/share/uboot/starfive_visionfive2
[..]
/usr/share/uboot/starfive_visionfive2/spl/u-boot-spl.bin.normal.out
[..]
/usr/share/uboot/starfive_visionfive2/u-boot.itb
</pre>
Remember to reboot and get into U-Boot prompt to load new default environment and write it out to SPI-NOR flash.
=Configurating for highest performance=
By default CPU scaling governor is `schedutil` which close to highest performance while scaling frequency. To achieve the best performance from JH7110 boards you might want to switch to `performace` governor.
Get information about the current default kernel:
<pre>
# grubby --info=DEFAULT
index=0
kernel="/boot/vmlinuz-6.10.6-200.1.riscv64.fc40.riscv64"
args="ro rootflags=subvol=root earlycon rootflags=subvol=root cpufreq.default_governor=performance"
root="UUID=9bde1c01-47d0-43bb-bcdd-4aa90ffec397"
initrd="/boot/initramfs-6.10.6-200.1.riscv64.fc40.riscv64.img"
title="Fedora Linux (6.10.6-200.1.riscv64.fc40.riscv64) 40 (Server Edition)"
id="e97ec9d687994be78cf0a91cc5e7633e-6.10.6-200.1.riscv64.fc40.riscv64"
</pre>
Modify the current default kernel to user `performance` governor:
<pre>
grubby --update-kernel=DEFAULT --args="cpufreq.default_governor=performance"
</pre>
To modify the current default kernel and future kernels too to use `performance` governor:
<pre>
grubby --update-kernel=ALL --args="cpufreq.default_governor=performance"
</pre>
Reboot the system.
You can get more information from running system:
<pre>
# cpupower  frequency-info
analyzing CPU 1:
  driver: cpufreq-dt
  CPUs which run at the same hardware frequency: 0 1 2 3
  CPUs which need to have their frequency coordinated by software: 0 1 2 3
  maximum transition latency:  Cannot determine or is not supported.
  hardware limits: 375 MHz - 1.50 GHz
  available frequency steps:  375 MHz, 500 MHz, 750 MHz, 1.50 GHz
  available cpufreq governors: conservative ondemand userspace powersave performance schedutil
  current policy: frequency should be within 375 MHz and 1.50 GHz.
                  The governor "performance" may decide which speed to use
                  within this range.
  current CPU frequency: 1.50 GHz (asserted by call to hardware)
# cpupower  frequency-info -s
analyzing CPU 3:
375000:0, 500000:0, 750000:0, 1500000:268990  (1)
</pre>
=How to generate U-Boot default environment=
U-Boot package in Fedora does not incl. default environment (text or binary) for the boards. If you want to generate on your own you will need to rebuild `uboot-tools` SRPM locally. Once you have done that. Follow these instructions:
<pre>
cd /home/riscv/rpmbuild/BUILD/u-boot-2024.10-rc3
make u-boot-initial-env starfive_visionfive2_defconfig O=builds/starfive_visionfive2
cd builds/starfive_visionfive2
# You can check actual content
vi u-boot-initial-env
mkenvimage -s $(grep CONFIG_ENV_SIZE .config | sed 's/^CONFIG_ENV_SIZE=//') -o uboot-env.bin u-boot-initial-env
# You can check the binary
hexdump -C uboot-env.bin | less
</pre>
Another alternative would be to directly call `get_default_envs.sh` script:
<pre>
cd /home/riscv/rpmbuild/BUILD/u-boot-2024.10-rc3
./scripts/get_default_envs.sh builds/starfive_visionfive2/  > uboot-env.txt
./builds/tools/mkenvimage -s $(grep CONFIG_ENV_SIZE builds/starfive_visionfive2/.config | sed 's/^CONFIG_ENV_SIZE=//') -o uboot-env.bin uboot-env.txt
</pre>
</pre>

Latest revision as of 19:21, 31 January 2025

This page explains how to get Fedora running on the StarFive VisionFive 2 board.

Machine-specific instructions

For the most part you can just follow the generic instructions.

Requirements

Firmware

You need to replace the vendor firmware with the one built in Fedora. This version contains additional features and is based on a more recent U-Boot release.

Note that the firmware you will be installing can boot most modern UEFI-based distros (e.g. Ubuntu) just fine, but it cannot (at least out of the box) boot the vendor provided Debian-based image. It's always possible to revert back to the vendor firmware later if desired.

Firmware builds can be obtained from:

As of this writing, the most recent firmware build is:

The file you've just downloaded will be referred to as UBOOT.rpm below.

To extract the contents of the package, run:

$ rpm2cpio UBOOT.rpm | cpio -id

You can now update the board's SPI-NOR flash:

$ sudo flashcp -v usr/share/uboot/starfive_visionfive2/spl/u-boot-spl.bin.normal.out /dev/mtd0
Erasing blocks: 3/3 (100%)
Writing data: 137k/137k (100%)
Verifying data: 137k/137k (100%)

$ sudo flashcp -v usr/share/uboot/starfive_visionfive2/u-boot.itb /dev/mtd2
Erasing blocks: 16/16 (100%)
Writing data: 989k/989k (100%)
Verifying data: 989k/989k (100%)

One last step is necessary to complete the upgrade. Reset the machine, but interrupt the boot process before any entry is chosen to get access to the U-Boot prompt. If you're having trouble with this part, disconnecting all storage devices could help.

At the U-Boot prompt, type the following commands:

StarFive # env default -f -a; env save
## Resetting to default environment
Saving Environment to SPIFlash... Erasing SPI flash...Writing to SPI flash...done
OK

You've now completed the firmware update process and can proceed with installing Fedora.

This is the simplest way to update the firmware, which works if you already have Linux running. For an alternative method, see below.

Post-installation tasks

Access U-Boot environment from Linux

Add the following the the /etc/fw_env.config file:

/dev/mtd1 0x0 0x10000

You will now be able to use fw_printenv and fw_setenv to manipulate the U-Boot environment from within Linux.

Additional information

Installing SPI-NOR firmware via UART boot mode

This method allows to boot upstream U-Boot SPL (XMODEM) and U-Boot proper (YMODEM) using your serial console. This is especially helpful is SPI-NOR content is damaged and the board no longer boots. Once booted you can flash SPI-NOR with a new firmware images.

SPI-NOR partitions:

$ cat /proc/mtd
dev:    size   erasesize  name
mtd0: 00080000 00010000 "spl"
mtd1: 00010000 00010000 "uboot-env"
mtd2: 00400000 00010000 "uboot"
mtd3: 00a00000 00010000 "reserved-data"

Make sure your board is powered down.

Connect UART-Serial to USB dongle to VF2 using GPIO headers (3V3):

  • PIN 6: GND
  • PIN 8: UART-TX
  • PIN 10: UART-RX

More details here: https://doc-en.rvspace.org/VisionFive2/Quick_Start_Guide/VisionFive2_SDK_QSG/recovering_bootloader%20-%20vf2.html

Switch the board to UART boot mode:

 1 (High)  0 (Low)                
┌───────┐ ┌───────┐               
│XXXXXXX│ │       │ RGPIO_1: 1 (H)
└───────┘ └───────┘               
┌───────┐ ┌───────┐               
│XXXXXXX│ │       │ RGPIO_0: 1 (H)
└───────┘ └───────┘               

More details here: https://doc-en.rvspace.org/VisionFive2/Boot_UG/VisionFive2_SDK_QSG/boot_mode_settings.html?hl=uart

Let's use microSD card with FAT or ext4 partition to store new firmware files:

  • u-boot-spl.bin.normal.out (U-Boot SPL)
  • u-boot.itb (U-Boot, OpenSBI, DTB)

These are the files mentioned above.

Remove M.2 NVMe if installed. We don't want to have bootable media in any form otherwise Linux will boot before you can get to U-Boot prompt.

Insert the card to the board, and power it on.

You should see similar output:

(C)StarFive
CCCCCCCCCCCCCCCCCCCCC

It will constantly write C.

Press CTRL-A S. You will see upload menu:

+-[Upload]--+
| zmodem    |
| ymodem    |
| xmodem    |
| kermit    |
| ascii     |
+-----------+

Select xmodem, then [Goto] button at the bottom. Select u-boot-spl.bin.normal.out using SPACE and then press the [Okay] button. It will start uploading the first binary:

+----------------[xmodem upload - Press CTRL-C to quit]----------------+
|Sending u-boot-spl.bin.normal.out, 1142 blocks: Give your local XMODEM|
| receive command now.                                                 |
|Xmodem sectors/kbytes sent: 414/51k                                   |
|                                                                      |
|                                                                      |
|                                                                      |
|                                                                      |
+----------------------------------------------------------------------+

Press any key once it's uploaded. Now you should see U-Boot SPL booted and C will continue to be printed out:

U-Boot SPL 2024.10 (Nov 07 2024 - 00:00:00 +0000)
DDR version: dc2e84f0.
Trying to boot from UART
CCCCCCCCC

Now press CTRL-A S and select ymodem. This time we want to send u-boot.itb file. This file is large and thus will take a bit longer to upload.

+----------------[ymodem upload - Press CTRL-C to quit]----------------+
|Sending: u-boot.itb                                                   |
|Bytes Sent:1151104   BPS:8710                                         |
|Sending:                                                              |
|Ymodem sectors/kbytes sent:   0/ 0k                                   |
|Transfer complete                                                     |
|                                                                      |
| READY: press any key to continue...                                  |
+----------------------------------------------------------------------+

U-Boot will not find any bootable media and will drop you into the prompt.

Loading Boot0000 'mmc 1' failed
Loading from BootNext failed, falling back to BootOrder
Loading Boot0000 'mmc 1' failed
EFI boot manager: Cannot load any image
StarFive #

Check the content of microSD card:

StarFive # ls mmc 1:1
<DIR>       4096 .
<DIR>       4096 ..
<DIR>      16384 lost+found
         1151019 u-boot.itb
          146178 u-boot-spl.bin.normal.out

Update U-Boot SPL and U-Boot data:

sf probe
load mmc 1:1 ${loadaddr} u-boot-spl.bin.normal.out
setenv ldsize ${filesize}
sf update ${loadaddr} 0x0 ${ldsize}
load mmc 1:1 ${loadaddr} u-boot.itb
setenv ldsize ${filesize}
sf update ${loadaddr} 0x100000 ${ldsize}

We booted using UART mode with the same files thus we can update default U-Boot environment too:

# env default -a -f; env save
## Resetting to default environment
Saving Environment to SPIFlash... Erasing SPI flash...Writing to SPI flash...done
OK

Remove power cable and microSD card.

Switch back to SPI-NOR boot mode:

 1 (High)  0 (Low)                
┌───────┐ ┌───────┐               
│       │ │XXXXXXX│ RGPIO_1: 1 (H)
└───────┘ └───────┘               
┌───────┐ ┌───────┐               
│       │ │XXXXXXX│ RGPIO_0: 1 (H)
└───────┘ └───────┘