U-boot problem

I have a u-boot problem booting OpenBSD from NVMe:

** Invalid partition 3 **
Couldn't find partition nvme 0:3
Can't set block device

I figured out:

StarFive # ls nvme 0:1
efi/
0 file(s), 1 dir(s)

Can boot directly from nvme like so:

load nvme 0:1 0x48000000 vendor/jh7110-starfive-visionfive-2-v1.3b.dtb
load nvme 0:1 0x44000000 efi/boot/bootriscv64.efi
bootefi 0x44000000 0x48000000

Why is it asking for nvme 0:3 ?

Needs a fix in

Or is it this issue?

How can I automate the manual steps (the 3 commands above) so I do not need to enter them each time but the boot happens “automatically”?

Many thanks.

1 Like

New version

U-Boot 2021.10 (Aug 31 2023 - 12:55:45 +0800), Build: jenkins-github_visionfive2-17

not really an improvement.

When I stop autoboot in the 2 seconds time frame and drop into uboot cmd line the nvme is not initialized any longer (which was the case before).

When I let go the autoboot I now get:

Hit any key to stop autoboot:  0 
Card did not respond to voltage select! : -110
Card did not respond to voltage select! : -110
starfive_pcie pcie@2B000000: Starfive PCIe bus probed.
PCI: Failed autoconfig bar 10
starfive_pcie pcie@2C000000: Starfive PCIe bus probed.
PCI: Failed autoconfig bar 10

Device 0: Vendor: 0x15b7 Rev: 234110WD Prod: 2239C6487212        
            Type: Hard Disk
            Capacity: 476940.0 MB = 465.7 GB (976773168 x 512)
... is now current device
Try booting from NVME0 ...
** Invalid partition 3 **
Couldn't find partition nvme 0:3
Can't set block device
## Warning: Input data exceeds 1048576 bytes - truncated
## Info: input data size = 1048578 = 0x100002
## Error: "boot2" not defined

Device 0: Vendor: 0x15b7 Rev: 234110WD Prod: 2239C6487212        
            Type: Hard Disk
            Capacity: 476940.0 MB = 465.7 GB (976773168 x 512)
... is now current device
Try booting from NVME0 ...
** Invalid partition 3 **
Couldn't find partition nvme 0:3
Can't set block device
## Warning: Input data exceeds 1048576 bytes - truncated
## Info: input data size = 1048578 = 0x100002
## Error: "boot2" not defined
Tring booting distro ...
Card did not respond to voltage select! : -110
Card did not respond to voltage select! : -110

Device 0: Vendor: 0x15b7 Rev: 234110WD Prod: 2239C6487212        
            Type: Hard Disk
            Capacity: 476940.0 MB = 465.7 GB (976773168 x 512)
... is now current device
Try booting from NVME0 ...
** Invalid partition 3 **
Couldn't find partition nvme 0:3
Can't set block device
## Warning: defaulting to text format
## Warning: Input data exceeds 1048576 bytes - truncated
## Info: input data size = 1048578 = 0x100002
** Invalid partition 3 **
Couldn't find partition nvme 0:3
Can't set block device
libfdt fdt_check_header(): FDT_ERR_BADMAGIC
** Invalid partition 3 **
Couldn't find partition nvme 0:3
libfdt fdt_check_header(): FDT_ERR_BADMAGIC
libfdt fdt_path_offset() returned FDT_ERR_NOTFOUND
libfdt fdt_path_offset() returned FDT_ERR_NOTFOUND
libfdt fdt_path_offset() returned FDT_ERR_NOTFOUND
libfdt fdt_path_offset() returned FDT_ERR_NOTFOUND
libfdt fdt_path_offset() returned FDT_ERR_NOTFOUND
libfdt fdt_path_offset() returned FDT_ERR_NOTFOUND
libfdt fdt_path_offset() returned FDT_ERR_NOTFOUND
fatwrite - write file into a dos filesystem

Usage:
fatwrite <interface> <dev[:part]> <addr> <filename> [<bytes> [<offset>]]
    - write file 'filename' from the address 'addr' in RAM
      to 'dev' on 'interface'
Retrieving file: /extlinux/extlinux.conf
** Invalid partition 3 **
Couldn't find partition nvme 0:3
Can't set block device
Error reading config file

Device 0: Vendor: 0x15b7 Rev: 234110WD Prod: 2239C6487212        
            Type: Hard Disk
            Capacity: 476940.0 MB = 465.7 GB (976773168 x 512)
... is now current device
Try booting from NVME0 ...
** Invalid partition 3 **
Couldn't find partition nvme 0:3
Can't set block device
## Warning: defaulting to text format
## Warning: Input data exceeds 1048576 bytes - truncated
## Info: input data size = 1048578 = 0x100002
** Invalid partition 3 **
Couldn't find partition nvme 0:3
Can't set block device
libfdt fdt_check_header(): FDT_ERR_BADMAGIC
** Invalid partition 3 **
Couldn't find partition nvme 0:3
libfdt fdt_check_header(): FDT_ERR_BADMAGIC
libfdt fdt_path_offset() returned FDT_ERR_NOTFOUND
libfdt fdt_path_offset() returned FDT_ERR_NOTFOUND
libfdt fdt_path_offset() returned FDT_ERR_NOTFOUND
libfdt fdt_path_offset() returned FDT_ERR_NOTFOUND
libfdt fdt_path_offset() returned FDT_ERR_NOTFOUND
libfdt fdt_path_offset() returned FDT_ERR_NOTFOUND
libfdt fdt_path_offset() returned FDT_ERR_NOTFOUND
fatwrite - write file into a dos filesystem

Usage:
fatwrite <interface> <dev[:part]> <addr> <filename> [<bytes> [<offset>]]
    - write file 'filename' from the address 'addr' in RAM
      to 'dev' on 'interface'
Retrieving file: /extlinux/extlinux.conf
** Invalid partition 3 **
Couldn't find partition nvme 0:3
Can't set block device
Error reading config file

I do not like it is so linux centric. It puts others like BSDs, Haiku,…at a disadvantage :-1:

Oh and there is other folks reporting basically similar problems:

For Haiku I use this U-Boot commands to enable permanent EFI NVMe boot.

env default -a -f
setenv boot_targets "mmc0 nvme0 dhcp"
setenv bootcmd_nvme0 "devnum=0; run nvme_boot"
saveenv
2 Likes

Thank you. I tried it:

StarFive # env default -a -f                                                    
## Resetting to default environment                                             
StarFive # setenv boot_targets "mmc0 nvme0 dhcp"                                
StarFive # setenv bootcmd_nvme0 "devnum=0; run nvme_boot"                       
StarFive # saveenv                                                              
Saving Environment to SPIFlash... Erasing SPI flash...Writing to SPI flash...doe
OK

It still looks at 0:3. Do you know how I can set it to 0:1 ?

You need to reboot (reset) after entering commands.

Yes, I did :slight_smile: But still…

StarFive # printenv
baudrate=115200
boot_a_script=load ${devtype} ${devnum}:${distro_bootpart} ${scriptaddr} ${prefix}${script}; source ${scriptaddr}
boot_devs=mmc nvme
boot_efi_binary=load ${devtype} ${devnum}:${distro_bootpart} ${kernel_addr_r} efi/boot/bootriscv64.efi; if fdt addr ${fdt_addr_r}; then bootefi ${kernel_addr_r} ${fdt_addr_r};else bootefi ${kernel_addr_r} ${fdtcontroladdr};fi
boot_efi_bootmgr=if fdt addr ${fdt_addr_r}; then bootefi bootmgr ${fdt_addr_r};else bootefi bootmgr;fi
boot_extlinux=sysboot ${devtype} ${devnum}:${distro_bootpart} any ${scriptaddr} ${prefix}${boot_syslinux_conf}
boot_net_usb_start=usb start
boot_pci_enum=pci enum
boot_prefixes=/ /boot/
boot_script_dhcp=boot.scr.uimg
boot_scripts=boot.scr.uimg boot.scr
boot_syslinux_conf=extlinux/extlinux.conf
boot_targets=mmc0 nvme0 dhcp
bootargs=console=tty1 console=ttyS0,115200  debug rootwait  earlycon=sbi
bootcmd=run sdk_boot_env; run distro_boot_env
bootcmd_dhcp=devtype=dhcp; run boot_net_usb_start; run boot_pci_enum; if dhcp ${scriptaddr} ${boot_script_dhcp}; then source ${scriptaddr}; fi;setenv efi_fdtfile ${fdtfile}; setenv efi_old_vci ${bootp_vci};setenv efi_old_arch ${bootp_arch};setenv bootp_;
bootcmd_distro=run load_distro_uenv; run fdt_loaddtb; run fdt_sizecheck; run set_fdt_distro; sysboot ${bootdev} ${devnum}:${bootpart} fat ${scriptaddr} /${boot_syslinux_conf}; 
bootcmd_mmc0=devnum=0; run mmc_boot
bootcmd_nvme0=devnum=0; run nvme_boot
bootdelay=2
bootdev=nvme
bootdir=/boot
bootenv=uEnv.txt
bootenv_mmc=setenv bootdev mmc;if test ${bootmode} = flash; then for mmc_devnum in ${mmc_devnum_l}; do setenv devnum ${mmc_devnum}; run mmc_test_and_boot;done;fi; if test ${bootmode} = sd; then setenv devnum ${sd_devnum};run mmc_test_and_boot;fi; if tes 
bootenv_nvme=if test ${bootmode} = flash; then for nvme_devnum in ${nvme_devnum_l}; do setenv devnum ${nvme_devnum};if pci enum; then nvme scan; fi; if nvme dev ${devnum}; then echo Try booting from NVME${devnum} ...; setenv bootdev nvme;setenv sdev_blk 
bootenv_sdk=vf2_uEnv.txt
bootfile=/extlinux/extlinux.conf
bootmode=flash
bootpart=3
chip_vision=A
chipa_gmac_set=fdt set /soc/ethernet@16030000/ethernet-phy@0 tx_inverted_10 <0x0>;fdt set /soc/ethernet@16030000/ethernet-phy@0 tx_inverted_100 <0x0>;fdt set /soc/ethernet@16030000/ethernet-phy@0 tx_inverted_1000 <0x0>;fdt set /soc/ethernet@16030000/eth 
chipa_set=if test ${chip_vision} = A; then run chipa_gmac_set;fi; 
chipa_set_linux=fdt addr ${fdt_addr_r};run visionfive2_mem_set;run chipa_set;
chipa_set_uboot=fdt addr ${uboot_fdt_addr};run chipa_set;
cma_1g=b000000
cma_2g=20000000
cma_4g=40000000
cma_8g=60000000
cma_ddr1g_set=fdt set ${cma_node} size <0x0 0x${cma_1g}>;fdt set ${cma_node} alloc-ranges <0x0 0x${cma_start} 0x0 0x${cma_1g}>;
cma_ddr2g_set=fdt set ${cma_node} size <0x0 0x${cma_2g}>;fdt set ${cma_node} alloc-ranges <0x0 0x${cma_start} 0x0 0x${cma_2g}>;
cma_ddr4g_set=fdt set ${cma_node} size <0x0 0x${cma_4g}>;fdt set ${cma_node} alloc-ranges <0x0 0x${cma_start} 0x0 0x${cma_4g}>;
cma_ddr8g_set=fdt set ${cma_node} size <0x0 0x${cma_8g}>;fdt set ${cma_node} alloc-ranges <0x0 0x${cma_start} 0x0 0x${cma_8g}>;
cma_node=/reserved-memory/linux,cma
cma_resize=if test ${memory_size} -eq 40000000; then run cma_ddr1g_set;elif test ${memory_size} -eq 80000000; then run cma_ddr2g_set;elif test ${memory_size} -eq 100000000; then run cma_ddr4g_set;elif test ${memory_size} -ge 200000000; then run cma_ddr8 
cma_start=70000000
cpu_max_vol=1040000
cpu_speed_1250_set=fdt rm /opp-table-0/opp-375000000;fdt rm /opp-table-0/opp-500000000;fdt rm /opp-table-0/opp-750000000;fdt rm /opp-table-0/opp-1500000000;
cpu_speed_1500_set=fdt rm /opp-table-0/opp-312500000;fdt rm /opp-table-0/opp-417000000;fdt rm /opp-table-0/opp-625000000;fdt rm /opp-table-0/opp-1250000000;
cpu_vol_1020_set=fdt set /opp-table-0/opp-1500000000 opp-microvolt <1020000>;
cpu_vol_1040_set=fdt set /opp-table-0/opp-1500000000 opp-microvolt <1040000>;
cpu_vol_1060_set=fdt set /opp-table-0/opp-1500000000 opp-microvolt <1060000>;
cpu_vol_set=if test ${cpu_max_vol} = 1000000; then run cpu_speed_1250_set; else run cpu_speed_1500_set; if test ${cpu_max_vol} = 1060000; then run cpu_vol_1060_set; elif test ${cpu_max_vol} = 1020000; then run cpu_vol_1020_set; else run cpu_vol_1040_set 
devnum=0
distro_boot_env=echo Tring booting distro ...;for bootdev_s in ${boot_devs}; do run distro_bootenv_${bootdev_s}; done; 
distro_bootcmd=setenv nvme_need_init; for target in ${boot_targets}; do run bootcmd_${target}; done
distro_bootenv_mmc=setenv bootdev mmc;if test ${bootmode} = flash; then for mmc_devnum in ${mmc_devnum_l}; do setenv devnum ${mmc_devnum}; run distro_mmc_test_and_boot;done;fi; if test ${bootmode} = sd; then setenv devnum ${sd_devnum};run distro_mmc_tes 
distro_bootenv_nvme=if test ${bootmode} = flash; then for nvme_devnum in ${nvme_devnum_l}; do setenv devnum ${nvme_devnum};if pci enum; then nvme scan; fi; if nvme dev ${devnum}; then echo Try booting from NVME${devnum} ...; setenv bootdev nvme;run boot 
distro_mmc_test_and_boot=if mmc dev ${devnum}; then echo Try booting from MMC${devnum} ...; run bootcmd_distro;fi;
efi_dtb_prefixes=/ /dtb/ /dtb/current/
emmc_devnum=0
eth0addr=6c:cf:39:00:1c:29
eth1addr=6c:cf:39:00:1c:2a
ethaddr=6c:cf:39:00:1c:29
fdt_addr_r=0x46000000
fdt_high=0xffffffffffffffff
fdt_loaddtb=fatload ${bootdev} ${devnum}:${bootpart} ${fdt_addr_r} /dtbs/${fdtfile}; fdt addr ${fdt_addr_r}; 
fdt_sizecheck=fatsize ${bootdev} ${devnum}:${bootpart} /dtbs/${fdtfile}; 
fdtaddr=f7fad910
fdtcontroladdr=f7fad910
fdtfile=starfive/jh7110-visionfive-v2.dtb
fdtoverlay_addr_r=0x4f000000
initrd_high=0xffffffffffffffff
ipaddr=192.168.120.230
kernel_addr_r=0x40200000
kernel_comp_addr_r=0x5a000000
kernel_comp_size=0x4000000
load_distro_uenv=fatload ${bootdev} ${devnum}:${bootpart} ${loadaddr} /${bootenv}; env import ${loadaddr} ${filesize}; 
load_efi_dtb=load ${devtype} ${devnum}:${distro_bootpart} ${fdt_addr_r} ${prefix}${efi_fdtfile}
load_sdk_uenv=fatload ${bootdev} ${devnum}:${bootpart} ${loadaddr} ${bootenv_sdk};env import -t ${loadaddr} ${filesize}; 
loadaddr=0x60000000
memory_addr=40000000
memory_size=200000000
mmc_boot=if mmc dev ${devnum}; then devtype=mmc; run scan_dev_for_boot_part; fi
mmc_devnum_l=1 0
mmc_test_and_boot=if mmc dev ${devnum}; then echo Try booting from MMC${devnum} ...; setenv sdev_blk mmcblk${devnum}p${rootpart};run load_sdk_uenv; run boot2;fi;
netmask=255.255.255.0
nvme_boot=run boot_pci_enum; run nvme_init; if nvme dev ${devnum}; then devtype=nvme; run scan_dev_for_boot_part; fi
nvme_devnum_l=0 0
nvme_init=if ${nvme_need_init}; then setenv nvme_need_init false; nvme scan; fi
partitions=name=loader1,start=17K,size=1M,type=${type_guid_gpt_loader1};name=loader2,size=4MB,type=${type_guid_gpt_loader2};name=system,size=-,bootable,type=${type_guid_gpt_system};
preboot=run chipa_set_uboot;
pxefile_addr_r=0x45900000
ramdisk_addr_r=0x46100000
rootpart=4
scan_dev_for_boot=echo Scanning ${devtype} ${devnum}:${distro_bootpart}...; for prefix in ${boot_prefixes}; do run scan_dev_for_extlinux; run scan_dev_for_scripts; done;run scan_dev_for_efi;
scan_dev_for_boot_part=part list ${devtype} ${devnum} -bootable devplist; env exists devplist || setenv devplist 1; for distro_bootpart in ${devplist}; do if fstype ${devtype} ${devnum}:${distro_bootpart} bootfstype; then run scan_dev_for_boot; fi; donet
scan_dev_for_efi=setenv efi_fdtfile ${fdtfile}; for prefix in ${efi_dtb_prefixes}; do if test -e ${devtype} ${devnum}:${distro_bootpart} ${prefix}${efi_fdtfile}; then run load_efi_dtb; fi;done;run boot_efi_bootmgr;if test -e ${devtype} ${devnum}:${distre
scan_dev_for_extlinux=if test -e ${devtype} ${devnum}:${distro_bootpart} ${prefix}${boot_syslinux_conf}; then echo Found ${prefix}${boot_syslinux_conf}; run boot_extlinux; echo SCRIPT FAILED: continuing...; fi
scan_dev_for_scripts=for script in ${boot_scripts}; do if test -e ${devtype} ${devnum}:${distro_bootpart} ${prefix}${script}; then echo Found U-Boot script ${prefix}${script}; run boot_a_script; echo SCRIPT FAILED: continuing...; fi; done
scan_sf_for_scripts=${devtype} read ${scriptaddr} ${script_offset_f} ${script_size_f}; source ${scriptaddr}; echo SCRIPT FAILED: continuing...
script_offset_f=0x1fff000
script_size_f=0x1000
scriptaddr=0x43900000
sd_devnum=1
sdev_blk=nvme0n1p4
sdk_boot_env=for bootdev_s in ${boot_devs}; do run bootenv_${bootdev_s}; done;
serial#=VF7110A1-2250-D008E000-00001109
set_fdt_distro=run chipa_set_linux; run cpu_vol_set;fatwrite ${bootdev} ${devnum}:${bootpart} ${fdt_addr_r} /dtbs/${fdtfile} ${filesize}; 
sf_boot=if sf probe ${busnum}; then devtype=sf; run scan_sf_for_scripts; fi
type_guid_gpt_loader1=5B193300-FC78-40CD-8002-E86C45580B47
type_guid_gpt_loader2=2E54B353-1271-4842-806F-E436D6AF6985
type_guid_gpt_system=0FC63DAF-8483-4772-8E79-3D69D8477DE4
uboot_fdt_addr=0xf7fad910
usb_boot=usb start; if usb dev ${devnum}; then devtype=usb; run scan_dev_for_boot_part; fi
ver=U-Boot 2021.10 (Aug 31 2023 - 12:55:45 +0800)
visionfive2_mem_set=fdt memory ${memory_addr} ${memory_size};run cma_resize; 

Environment size: 10234/65532 bytes

Maybe setenv bootcmd_nvme0 "devnum=0; bootpart=1; run nvme_boot" will help?

Seems to get calculated somewhere still.
Tried your parameter and distro_bootpart=1 , too.

Have a working version now (but quite “hardcoded”):

> env default -a -f
> setenv distro_boot_env "echo Booting OpenBSD from NVME; load nvme 0:1 0x48000000 vendor/jh7110-starfive-visionfive-2-v1.2a.dtb;load nvme 0:1 0x44000000 efi/boot/bootriscv64.efi;bootefi 0x44000000 0x48000000;"
> saveenv
> reset

Thanks for your advice that helped me to make it work for me.

1 Like

Btw you can try upstream uboot now. It supports PCIE and USB and GMAC on VF2 now.

3 Likes

Ok, thanks! Can I build it natively on VF2 ?

Think I need to follow https://u-boot.readthedocs.io/en/latest/board/starfive/visionfive2.html to do that, including Open Sbi.

But instructions talk about Riscv Toolchain and cross compile. Is that really needed ?

1 Like

Yes, that doc works. But the QSPI flash download method is quite weird… You could just use flashcp for this.
Cross compile is used when you are not compiling that on board. (compile on x86/arm64 or sth.)
Pcie wouldn’t enable on boot on default config, but still supported. Check this series: [v1,0/2] Enable PCIE and USB by default on Visionfive 2 - Patchwork

1 Like

Okay. Think it showed cpl of errors with make of opensbi. Do I need the riscv toolchain when compiling on VF2 or for cross compile only. Otherwise will need to grab it somewhere, too or compile it, too…

That toolchain is just gcc stuff, maybe more is needed, just check the compile log output and search.

Cool. Thanks :pray:

Hm, stuck here…

cc: error: invalid arch name 'rv64imafdc_zicsr_zifencei', unsupported standard user-level extension 'zicsr'

Found https://lore.kernel.org/lkml/75037eb4-7be4-4182-a377-18343491c7da@spud/T/, but don’t know how to apply it.

vf2# cc --version  
OpenBSD clang version 13.0.0
Target: riscv64-unknown-openbsd7.3
Thread model: posix
InstalledDir: /usr/bin

vf2# gas --version
GNU assembler (GNU Binutils) 2.41
Copyright (C) 2023 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or later.
This program has absolutely no warranty.
This assembler was configured for a target of `riscv64-unknown-openbsd7.3'.

vf2# gmake PLATFORM=generic FW_TEXT_START=0x40000000 FW_OPTIONS=0 TOOLCHAIN_NEEDS_EXPLICIT_ZICSR_ZIFENCEI=1 

 CC-DEP    platform/generic/starfive/jh7110.dep
cc: error: invalid arch name 'rv64imafdc_zicsr_zifencei', unsupported standard user-level extension 'zicsr'
 CC-DEP    platform/generic/sifive/fu540.dep
cc: error: invalid arch name 'rv64imafdc_zicsr_zifencei', unsupported standard user-level extension 'zicsr'

vf2# grep -R zicsr .                                                                                        
./Makefile:CC_SUPPORT_ZICSR_ZIFENCEI := $(shell $(CC) $(CLANG_TARGET) $(RELAX_FLAG) -nostdlib -march=rv$(OPENSBI_CC_XLEN)imafd_zicsr_zifencei -x c /dev/null -o /dev/null 2>&1 | grep "zicsr\|zifencei" > /dev/null && echo n || echo y)
./Makefile:      PLATFORM_RISCV_ISA = rv$(PLATFORM_RISCV_XLEN)imafdc_zicsr_zifencei
vf2# pkg_info kconfig  
Information for inst:kconfig-5.108.0

Any suggestion? Thanks.

1 Like

You are running on openbsd+clang? Sorry, I never used this​:pensive: I’m using Ubuntu20.04+x86 for compiling.

1 Like

Yes. Think I need clang 17 rc1+ , but not available yet.

Well, think FreeBSD has a port of latest llvm available, so will try to fall back on that machine and do a cross compile…