Writing prebuilt disk image to uSD card

Hello everyone,

I am experimenting with HiFive Unmatched RevB computer.
I did not have any problems booting from uSD card delivered together with HiFive Unmatched RevB computer.

However, I do not understand if there are any missing points in the way I am writing disk images from uSD cards.
Same problems happen when I use release candidate 2024.07.00 and when I build images for HiFive Unmatched RevB from the freedom-u-sdk myself.

I am using this command for writing to my uSD card:

sudo xzcat ./demo-coreip-cli-unmatched.rootfs.wic.xz | sudo dd of=/dev/sda bs=512K iflag=fullblock oflag=direct conv=fsync status=progress

U-Boot does not understand command sysboot and after that it does not find EFI system partition. After that it scans USB for storage devices and looks for storage devices over Ethernet, but I guess I do not have to include it in my post.

Do you know is it some problem with U-Boot or the way I am preparing my uSD card?
I would like to use images from freedom-u-sdk, and not from some other projects.
Thank you!

I would try some older versions of freedom-u-sdk that have earlier versions of u-boot.

u-boot 2024.01

u-boot 2023.10

Thank you @drmpeg
At least Release Version 2024.03.00 works fine.

The problem with ‘sysboot’ not being recognised as valid command is still present in the
most recent build (2024.10.00).

I tracked this down. This commit breaks u-boot for Unmatched.

Almost all of the environment variables are lost. Having the kernel and OS on NVME no longer works. EXT_LINUX no longer works. Only booting EFI from SD card works.

Hi @Rijad12 ,

I can bringup the demo-coreip-cli-unmatched.rootfs.wic.xz of release 2024.10.00 and 2024.07.00.
Could you provide your u-boot config and u-boot env? The u-boot config will be removed after compiled. To preserve the u-boot config file, please add the following lines in {FUSDK dir}/meta-sifive/recipes-bsp/u-boot/u-boot-sifive_2024.10.bb and rebuild the image again.

do_rm_work() {
}

The config file will be placed in {FUSDK dir}/build/tmp/work/unmatched-freedomusdk-linux/u-boot-sifive/2024.10/build/.config, and the u-boot env file is located at {FUSDK dir}/build/tmp/deploy/images/unmatched/u-boot-sifive-initial-env-unmatched.

Hello @yong-xuan,

I have made that change in recipe of u-boot, but I still can not boot after rebuilding tag 2024.10.0
I needed older version of freedom-u-sdk anyway because of some other Yocto layers.
That is why I was not too interested in this issue.

I do not have {FUSDK dir}/build/tmp/work/unmatched-freedomusdk-linux/u-boot-sifive/2024.10/build/.config, but I do have generated_defconfig in {FUSDK dir}/build/tmp/work/unmatched-freedomusdk-linux/u-boot-sifive/2024.10/build

I am uploading generated_defconfig and u-boot-sifive-initial-env-unmatched, in case you want to compare them.

u-boot-sifive-initial-env-unmatched:

arch=riscv
baudrate=115200
board=unmatched
board_name=unmatched
bootcmd=bootflow scan
bootdelay=2
cpu=fu740
fdt_addr_r=0x8c000000
fdtfile=“sifive/hifive-unmatched-a00.dtb”
kernel_addr_r=0x80200000
kernel_comp_addr_r=0x88000000
kernel_comp_size=0x4000000
loadaddr=0x80200000
mtdids=
mtdparts=
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=setenv fdt_addr ${fdtcontroladdr};fdt addr ${fdtcontroladdr};
pxefile_addr_r=0x8c200000
ramdisk_addr_r=0x8c300000
scriptaddr=0x8c100000
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
usb_ignorelist=
vendor=sifive

generated_defconfig:

Hi @Rijad12 ,

Thanks for your information! Your image uses the default config and environment variables of unmatched board.
After commit 44a792c, the unmatched board switched to use standard boot to bringup Linux. I have no idea why your image didn’t use the command provided by standard boot but tried to use the sysboot command. Could you try the prebuilt demo-coreip-cli-unmatched.rootfs.wic.xz of 2024.10.00?

Hi @yong-xuan,

Thank you very much.

Prebuilt demo-coreip-cli-unmatched.rootfs.wic.xz from version 2024.10.00 does not boot on my HiFive Unmatched Board.

I made some experiment: I combined U-Boot 2023.01 (seems to be enough old version) with Freedom-U-SDK directly from master branch
(which at the moment still has tag 2024.12 without additional Git commits).
I made some changes quick-and-dirty, but I still have to see how much sense do these changes have.

I cloned freedom-u-sdk from master branch.
In file freedom-u-sdk/conf/distro/freedom-u-sdk.conf I commented out all PREFERRED_PROVIDER_* lines where u-boot-sifive is mentioned.

In meta-sifive layer, I deleted u-boot folder, used u-boot folder from tag 2023.04 of meta-sifive having u-boot_2023.01.bbappend in it.
After that, I did not use any of patches mentioned in meta-sifive/recipes-bsp/u-boot/u-boot_2023.01.bbappend (whether it being good or not).
In file meta-sifive/conf/machine/unmatched.conf, I replaced occurrences of “u-boot-sifive” with “u-boot”.
In file meta-sifive/scripts/kas/include/meta-sifive-common.yml, I replaced refspec of openembedded-core with refspec of 2023.04 (which is Git commit c57d1a561db563ed2f521bbac5fc12d4ac8e11a7)

In layer openembedded-core, I replaced existing recipes-bsp/u-boot with recipes-bsp/u-boot having u-boot_2023.01.bb (which is also from Git commit c57d1a561db563ed2f521bbac5fc12d4ac8e11a7)
In layer openembedded-core, I also replaced existing recipes-devtools/swig having version 4.3.0, with recipes-devtools/swig having version 4.1.1.

With these changes, my HiFive Unmatched Board boots just five, with new Linux kernel and old U-Boot.

Hi @Rijad12 ,

Sorry for the late reply. I can reproduce this issue now.
The sysboot command is a boot command stored in an environment variable. U-Boot first attempts to load the saved environment variables from persistent memory. If that fails, it switches to the default environment variables embedded in the image.
In the unmatched board defconfig, the default saved path for environment variables is in SPI flash, which differs from the SD card. As a result, writing the image to the SD card does not erase the saved environment variables.
The commit changes the boot command from sysboot to bootcmd, so the latest image no longer recognizes the sysboot command in the old saved environment variables.

To update the latest environment variables in SPI flash, follow these steps:

  1. Stop autoboot and enter the command-line interface.
  2. Run env default -a to reset all U-Boot environment variables in memory to their latest values.
  3. Run env save to store the updated values in persistent memory.
  4. Run bootflow scan to continue booting into Linux.