U-boot upstream

Has anyone here yet been adventurous enough to try running the U-boot upstream?


I can report limited success. Below the current patch process for anyone interested.


I translated the material on the VF2 board itself, using Debian unstable.

Get the u-boot patches

Click the two patches mentioned in U-boot upstream
There, on the right upper hand side, click series to download the patch.

Clone u-boot and compile u-boot

# git clone git://git.denx.de/u-boot.git
# cd u-boot
# git checkout master -b patched
# git apply ../Basic-StarFive-JH7110-RISC-V-SoC-support.patch

i.e. the patches apply cleanly on the master branch.

The version 3 of the first patch series contains board specific information in
u-boot/doc/board/starfive/visionfive2.rst, which are to follow then.

Unfortunately, the second patch v1, which contains PCIe support, has been broken by v3 of the first one. I could apply them earlier, and was at least able to list a nvme directory from u-boot. So it is almost there.

Results so far

The build and installation process works well, but booting hangs after spl stage, here:

U-Boot SPL 2023.04-rc3-00083-gf31df8ec44 (Mar 08 2023 - 07:46:22 +0100)
DDR version: dc2e84f0.
Trying to boot from MMC2

Other have reported success in reproducing a successful run, so it might be a local issue.


I tested it and it worked fine, I can confirm that PCIe support v1 is broken with the v3 patches, and I did not test older patches.
I flashed and booted it from SPI not MMC though.


I tried SPI, too, but with the same hang. Board instructions shows it has been tested on MMC. Hmm, funny. Since we both followed the same instruction, there must be a minimal deviation. @ROSsi15, did you cross compile? Have you been using the upstream OpenSBI? Have you installed u-boot.itb?

I’m interested in this; especially the SPL. I want to update the device tree OpenSBI sees to enable the perf counter, a prerequisite for perf to work. As best I can tell, U-boot’s SPL embeds this and provides it to OpenSBI, so … I need to rebuild that. (of course I don’t think 5.15 will have the necessary changes, but baby steps)

Think so too. u-boot/scripts/Makefile.spl regulates this starting at line 598. Since a uboot-spl-dtb.bin is produced, uboot-spl.bin has to be identical to that, and it is.

Yes I have been using upstream opensbi, I cross compiled everything on an x86_64 machine using arch Linux riscv64-linux-gnu- toolchain, and flashed u-boot-spl.bin.normal.out and u-boot.itb

1 Like

Did you get the exact same hang with SPL and U-Boot flashed to SPI and with the boot selector in flash mode?
Did you set the correct environment variables when compiling u-boot and opensbi (for example FW_TEXT_START=0x40000000 in opensbi)?

1 Like

I also noticed that either Ethernet interfaces were not recognized in uboot upstream, I didn’t check the patches, so i don’t know if it’s a bug or if they are not supported yet.

U-Boot SPL 2023.04-rc3-00083-gf31df8ec44 (Mar 10 2023 - 20:30:08 +0100)
DDR version: dc2e84f0.
Trying to boot from SPI

Absolutely. I find it hard to believe, that cross compilation will resolve it, but i’ll try it … Hmm, it is both the Debian tool chain, perhaps the different tool chain matters …

There is a new version of the patches (v4):
and also patches to support ethernet:


Thank you @ROSsi15, for pointing out the new patches. I gave them a shot and can report that they patch and compile cleanly on the master branch.

The PCIe patch and the Ethernet patch apply alternatively in the moment.

I tried a cross-compilation on Debian unstable amd64 and could basically boot into u-boot.
Hmm, i used the the gcc-riscv64-linux-gnu package for cross-compilation.

( I got the same hang as above compiling it on the board itself using Debian unstable. This is very unfortunate, since the system is currently not fully self-hoisting. )

It should be a matter of a proper configuration only, to boot via SPI,NVMe, now.

Does this mean, @ROSsi15, that you could successfully start Linux?

While the system here loads the kernel, running it soon fails by first being unable to initialize the other CPUs and apparently to setup the L2CACHE rightly. The log follows. Can anyone interpret the issue, perhaps, or has seen this in another context?

The kernel is read from NVMe, and it runs well through the regular startup.

StarFive :: bootflow scan
** Booting bootflow 'nvme#0.blk#1.bootdev.part_2' with distro
3:      nvmep1-dirty
Retrieving file: /vmlinuz-5.15.0-dirty
Retrieving file: /initrd.img-5.15.0-dirty
append: root=/dev/nvme0n1p3 rw console=tty0 console=ttyS0,115200 earlycon rootwait stmmaceth=chain_mode:1 selinux=0
Retrieving file: /boot/dtbs/starfive/jh7110-starfive-visionfive-2-v1.3b.dtb
## Flattened Device Tree blob at ff73dbb0
   Booting using the fdt blob at 0xff73dbb0
Working FDT set to ff73dbb0
   Loading Ramdisk to fe250000, end fe728ff7 ... OK
   Loading Device Tree to 00000000fe244000, end 00000000fe24f22f ... OK
Working FDT set to fe244000

Starting kernel ...

[    0.000000] Linux version 5.15.0-dirty (root@starfive) (gcc (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40) #1 SMP Fri Feb 10 13:56:33 UTC 2023
[    0.000000] OF: fdt: Ignoring memory range 0x40000000 - 0x40200000
[    0.000000] Machine model: StarFive VisionFive 2 v1.3B
[    0.000000] earlycon: uart0 at MMIO32 0x0000000010000000 (options '115200n8')
[    0.000000] printk: bootconsole [uart0] enabled
[    0.000000] efi: UEFI not found.
[    0.000000] cma: Reserved 16 MiB at 0x00000000bf000000
[    0.000000] Zone ranges:
[    0.000000]   DMA32    [mem 0x0000000040200000-0x00000000ffffffff]
[    0.000000]   Normal   [mem 0x0000000100000000-0x000000023fffffff]
[    0.000000] Movable zone start for each node
[    0.000000] Early memory node ranges
[    0.000000]   node   0: [mem 0x0000000040200000-0x000000023fffffff]
[    0.000000] Initmem setup node 0 [mem 0x0000000040200000-0x000000023fffffff]
[    0.000000] SBI specification v1.0 detected
[    0.000000] SBI implementation ID=0x1 Version=0x10002
[    0.000000] SBI TIME extension detected
[    0.000000] SBI IPI extension detected
[    0.000000] SBI RFENCE extension detected
[    0.000000] SBI v0.2 HSM extension detected
[    0.000000] riscv: base ISA extensions acim
[    0.000000] riscv: ELF capabilities acim
[    0.000000] percpu: Embedded 18 pages/cpu s33896 r8192 d31640 u73728
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 2067975
[    0.000000] Kernel command line: root=/dev/nvme0n1p3 rw console=tty0 console=ttyS0,115200 earlycon rootwait stmmaceth=chain_mode:1 selinux=0
[    0.000000] Unknown command line parameters: stmmaceth=chain_mode:1 selinux=0
[    0.000000] Dentry cache hash table entries: 1048576 (order: 11, 8388608 bytes, linear)
[    0.000000] Inode-cache hash table entries: 524288 (order: 10, 4194304 bytes, linear)
[    0.000000] mem auto-init: stack:all(zero), heap alloc:off, heap free:off
[    0.000000] software IO TLB: mapped [mem 0x00000000fa244000-0x00000000fe244000] (64MB)
[    0.000000] Memory: 8132464K/8386560K available (10168K kernel code, 4992K rwdata, 4096K rodata, 2197K init, 403K bss, 237712K reserved, 16384K cma-reserved)
[    0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=5, Nodes=1
[    0.000000] rcu: Hierarchical RCU implementation.
[    0.000000] rcu:     RCU restricting CPUs from NR_CPUS=8 to nr_cpu_ids=5.
[    0.000000] rcu:     RCU debug extended QS entry/exit.
[    0.000000]  Tracing variant of Tasks RCU enabled.
[    0.000000] rcu: RCU calculated value of scheduler-enlistment delay is 10 jiffies.
[    0.000000] rcu: Adjusting geometry for rcu_fanout_leaf=16, nr_cpu_ids=5
[    0.000000] NR_IRQS: 64, nr_irqs: 64, preallocated irqs: 0
[    0.000000] riscv-intc: 64 local interrupts mapped
[    0.000000] plic: interrupt-controller@c000000: mapped 136 interrupts with 4 handlers for 9 contexts.
[    0.000000] random: get_random_bytes called from start_kernel+0x4cc/0x6e6 with crng_init=0
[    0.000000] riscv_timer_init_dt: Registering clocksource cpuid [0] hartid [2]
[    0.000000] clocksource: riscv_clocksource: mask: 0xffffffffffffffff max_cycles: 0x1d854df40, max_idle_ns: 881590404240 ns
[    0.000002] sched_clock: 64 bits at 4MHz, resolution 250ns, wraps every 2199023255500ns
[    0.009265] Console: colour dummy device 80x25
[    0.016176] printk: console [tty0] enabled
[    0.020851] Calibrating delay loop (skipped), value calculated using timer frequency.. 8.00 BogoMIPS (lpj=40000)
[    0.032175] pid_max: default: 32768 minimum: 301
[    0.037900] Mount-cache hash table entries: 16384 (order: 5, 131072 bytes, linear)
[    0.046648] Mountpoint-cache hash table entries: 16384 (order: 5, 131072 bytes, linear)
[    0.058716] ASID allocator disabled
[    0.062809] rcu: Hierarchical SRCU implementation.
[    0.068533] EFI services will not be available.
[    0.074485] smp: Bringing up secondary CPUs ...
sbi_trap_error: hart0: trap handler failed (error -2)
sbi_trap_error: hart0: mcause=0x0000000000000005 mtval=0x0000000040041068
sbi_trap_error: hart0: mepc=0x0000000040005376 mstatus=0x0000000200001800
sbi_trap_error: hart0: ra=0x000000004000aba8 sp=0x0000000040040ee0
sbi_trap_error: hart0: gp=0x0000000000000000 tp=0x0000000040041000
sbi_trap_error: hart0: s0=0x0000000040040ef0 s1=0x0000000040041000
sbi_trap_error: hart0: a0=0x0000000040041068 a1=0x0000000000000002
sbi_trap_error: hart0: a2=0x0000000000000000 a3=0x0000000000000019
sbi_trap_error: hart0: a4=0x0000000000000001 a5=0x0000000040041068
sbi_trap_error: hart0: a6=0x00000000400410b8 a7=0x0000000000000004
sbi_trap_error: hart0: s2=0x0000000040041068 s3=0x0000000000000000
sbi_trap_error: hart0: s4=0x0000000000000000 s5=0x0000000040022020
sbi_trap_error: hart0: s6=0x0000000000000000 s7=0xfffffffffffffffe
sbi_trap_error: hart0: s8=0x0000000000002000 s9=0x000000004002eab8
sbi_trap_error: hart0: s10=0x0000000000000000 s11=0x0000000000000000
sbi_trap_error: hart0: t0=0x0000000000000022 t1=0x0000000000000000
sbi_trap_error: hart0: t2=0x0000000000000000 t3=0x0000000000002000
sbi_trap_error: hart0: t4=0x0000000000000000 t5=0x0000000000000000
sbi_trap_error: hart0: t6=0x0000000000000000
[    1.140395] CPU1: failed to come online
[    1.148238] smp: Brought up 1 node, 4 CPUs
[    1.156883] devtmpfs: initialized
[    1.169346] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
[    1.180322] futex hash table entries: 2048 (order: 5, 131072 bytes, linear)
[    1.189283] pinctrl core: initialized pinctrl subsystem
[    1.196714] NET: Registered PF_NETLINK/PF_ROUTE protocol family
[    1.204438] cpuidle: using governor menu
[    1.243960] HugeTLB registered 1.00 GiB page size, pre-allocated 0 pages
[    1.251454] HugeTLB registered 2.00 MiB page size, pre-allocated 0 pages
[    1.265799] vgaarb: loaded
[    1.269303] SCSI subsystem initialized
[    1.274195] usbcore: registered new interface driver usbfs
[    1.280363] usbcore: registered new interface driver hub
[    1.286525] usbcore: registered new device driver usb
[    1.292496] mc: Linux media interface: v0.10
[    1.297306] videodev: Linux video capture interface: v2.00
[    1.303802] Advanced Linux Sound Architecture Driver Initialized.
[    1.311395] Bluetooth: Core ver 2.22
[    1.315414] NET: Registered PF_BLUETOOTH protocol family
[    1.321326] Bluetooth: HCI device and connection manager initialized
[    1.328383] Bluetooth: HCI socket layer initialized
[    1.333821] Bluetooth: L2CAP socket layer initialized
[    1.339444] Bluetooth: SCO socket layer initialized
[    1.345621] clocksource: Switched to clocksource riscv_clocksource
[    1.367421] NET: Registered PF_INET protocol family
[    1.374966] IP idents hash table entries: 131072 (order: 8, 1048576 bytes, linear)
[    1.398679] tcp_listen_portaddr_hash hash table entries: 4096 (order: 5, 163840 bytes, linear)
[    1.408831] TCP established hash table entries: 65536 (order: 7, 524288 bytes, linear)
[    1.419587] TCP bind hash table entries: 65536 (order: 9, 2097152 bytes, linear)
[    1.433436] TCP: Hash tables configured (established 65536 bind 65536)
[    1.441332] UDP hash table entries: 4096 (order: 6, 393216 bytes, linear)
[    1.450218] UDP-Lite hash table entries: 4096 (order: 6, 393216 bytes, linear)
[    1.459795] NET: Registered PF_UNIX/PF_LOCAL protocol family
[    1.467344] RPC: Registered named UNIX socket transport module.
[    1.473927] RPC: Registered udp transport module.
[    1.479190] RPC: Registered tcp transport module.
[    1.484405] RPC: Registered tcp NFSv4.1 backchannel transport module.
[    1.493093] PCI: CLS 0 bytes, default 64
[    1.499518] Initialise system trusted keyrings
[    1.504842] Unpacking initramfs...
[    1.508808] workingset: timestamp_bits=62 max_order=21 bucket_order=0
[    1.529039] NFS: Registering the id_resolver key type
[    1.534712] Key type id_resolver registered
[    1.539445] Key type id_legacy registered
[    1.544101] nfs4filelayout_init: NFSv4 File Layout Driver Registering...
[    1.551606] nfs4flexfilelayout_init: NFSv4 Flexfile Layout Driver Registering...
[    1.559968] ntfs: driver 2.1.32 [Flags: R/W].
[    1.565360] jffs2: version 2.2. (NAND) © 2001-2006 Red Hat, Inc.
[    1.573267] fuse: init (API version 7.34)
[    1.653551] NET: Registered PF_ALG protocol family
[    1.659017] Key type asymmetric registered
[    1.663585] Asymmetric key parser 'x509' registered
[    1.669255] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 249)
[    1.677517] io scheduler mq-deadline registered
[    1.682563] io scheduler kyber registered
[    1.800260] Serial: 8250/16550 driver, 6 ports, IRQ sharing disabled
[    1.811362] @@#########################@@
[    1.826172] L2CACHE: base addr invalid, skipping flush
[    1.831919] L2CACHE: base addr invalid, skipping flush
[    1.837679] L2CACHE: base addr invalid, skipping flush
[    1.843409] L2CACHE: base addr invalid, skipping flush