Building u-boot from mainline repo

Noticed that the 2013.10 upstream u-boot release will contain support for the Visionfive 2. I’m trying the current RC2 build. This build fails at the very end. Cross-compiling on Debian bookworm. The error report is:

binman: Filename 'fw_dynamic.bin' not found in input path (.,.,./board/starfive/visionfive2,arch/riscv/dts) (cwd='/home/vf2build/u-boot')
make: *** [Makefile:1111: .binman_stamp] Error 1

This is odd: opensbi needs u-boot to build, and u-boot needs opensbi to build. Building opensbi with the partial u-boot build works, and then copying ‘fw_dynamic.bin’ to the u-boot root allows the u-boot build to complete without errors on second try.

Is this supposed to work like this?

Related to this: is the 2023.10 upstream u-boot build interchangeable with the u-boot build in v3.4.5 ?

All tips for correctly building upstream u-boot for VF2 are welcome.

1 Like

I can reply to my own question. Just tried RC3 which was released today. The error report now is more informative:

Image 'itb' is missing external blobs and is non-functional: opensbi

/binman/itb/fit/images/opensbi/opensbi (fw_dynamic.bin):
   See the documentation for your board. The OpenSBI git repo is at
   https://github.com/riscv/opensbi.git
   You may need to build fw_dynamic.bin first and re-build u-boot with
   OPENSBI=/path/to/fw_dynamic.bin

Some images are invalid
make: *** [Makefile:1115: .binman_stamp] Error 103

So, yes, it is supposed to work like this.

You need to clone&build opensbi to get that bin… It is needed to make system work correctly. Besides, currently there’s a bug need to fix through this patch series, please apply or boot would fail. Also you could check this series if you want to try to use usb/nvme in u-boot.

1 Like

Thank you!

I have placed my build notes & scripts up on gitlab: pnr / VF2_boot · GitLab

As the patch is accepted, probably by the time RC4 arrives the separate patch step in the script can be dropped.

1 Like

Already accepted now.

paul63,

Your build notes produce a fw_dynamic.bin but the starfive-dev Makefile works with fw_payload.bin. Did you run into any issues? Here is the difference:

OpenSBI provides several types of reference firmware, all platform-specific
– FW_PAYLOAD
• Firmware with the next booting stage as a payload
• Default firmware being used in Linux capable RISC-V hardware
– FW_JUMP
• Firmware with fixed jump address to the next booting stage
• Default method for QEMU
– FW_DYNAMIC
• Firmware with dynamic information on the next booting stage
• U-Boot SPL/Coreboot is using FW_DYNAMIC

ref: https://riscv.org/wp-content/uploads/2019/12/Summit_bootflow.pdf

So, I was messing about with this, given latest Ubuntu 24.10. I’ve been running from SDCard boot, wanted to try flashing SPI with mainline (from generic git, not vendor), and then boot using SPI, (0,0). Some notes on how I got it working…

compile opensbi and u-boot, needs some env.vars setting to cross compile

first clone
git@github.com:riscv-software-src/opensbi.git
git@github.com:u-boot/u-boot.git

Compiling from x86_64 (for both opensbi and u-boot). I’m using fedora rawhide (and fish shell, adjust for bash)
set -x PLATFORM generic
set -x CROSS_COMPILE riscv64-linux-gnu-
set -x ARCH riscv

from within opensbi folder
make -j9

from within u-boot folder

define your config for sbc
make starfive_visionfive2_defconfig

It pulls in output from the opensbi, you use an env.var to define where to find it
set -x OPENSBI …/opensbi/build/platform/generic/firmware/fw_dynamic.bin

make -j9

The 2 files you are after are u-boot-spl.bin.normal.out & u-boot.itb. need these on your visionfive2 sbc. For this I used python -m http.server, and then wget from sbc. But however…
cp u-boot.itb …/outputs/
cp spl/u-boot-spl.bin.normal.out …/outputs/

-rw-r–r-- 1 root root 140K Nov 6 22:12 u-boot-spl.bin.normal.out
-rw-r–r-- 1 root root 1001K Nov 6 22:12 u-boot.itb

after on the visionfive2

flashcp -v u-boot-spl.bin.normal.out /dev/mtd0
flashcp -v u-boot.itb /dev/mtd2

where the mtd partitions are…
cat /proc/mtd
dev: size erasesize name
mtd0: 000f0000 00001000 “spl”
mtd1: 00010000 00001000 “uboot-env”
mtd2: 00f00000 00001000 “uboot”

Hi,
I’ve been running Ubuntu 24.10 from NVME on my board and it works awesome and it has the newest kernel too.

RC

Yeah likewise, it seems they have close to stock u-boot and u-boot-spi on their sd images etc. I initially flashed my board with those, but then wanted to try going completely back to git. Very impressed with ubuntu 24.10 - going to try Fedora image that was talked about in a thread on the sdcard tonight.