Booting from Flash

I think it can be done, at least with Ubuntu 22.04. First, download the latest u-boot .deb file.

http://launchpadlibrarian.net/593560393/u-boot-sifive_2022.01+dfsg-2ubuntu2_riscv64.deb

Then extract the .deb with dpkg-deb.

dpkg-deb -x u-boot-sifive_2022.01+dfsg-2ubuntu2_riscv64.deb /tmp

The files will be in /tmp/usr/lib/u-boot/sifive_unmatched/

Load the MTD block driver.

sudo modprobe mtdblock

And then write the flash.

sudo sgdisk -g --clear -a 1 \
  --new=1:40:2087         --change-name=1:spl --typecode=1:5B193300-FC78-40CD-8002-E86C45580B47 \
  --new=2:2088:10279      --change-name=2:uboot  --typecode=2:2E54B353-1271-4842-806F-E436D6AF6985 \
  --new=3:10280:10535	  --change-name=3:env   --typecode=3:0FC63DAF-8483-4772-8E79-3D69D8477DE4 \
  /dev/mtdblock0

sudo partprobe

sudo dd if=u-boot-spl.bin of=/dev/mtdblock0 bs=4096 seek=5 conv=sync
sudo dd if=u-boot.itb  of=/dev/mtdblock0 bs=4096 seek=261 conv=sync

Flip the boot DIP switches to 6 and reboot.

1 Like