Categories
Tech

Bootstrapping NetBSD on Star64

Some time ago (about 2 years?) I bought a Star64 with the vague plan of experimenting with RISC-V. Due to factors at the time, it sat on my shelf untouched.

I recently found the time to actually do something with it, and discovered the usual lack of written documentation on how to get a functional system going, and the Linux environments seem to be in various weird states.

I also have been on a bit of a systems history binge, including poking at 4.3BSD and MVS3.8 and remembered that there was always the option of running NetBSD on the Star64, and according to the website, it should be a supported target…

Well, it is, but getting it going involves a bit of faith and hitting up mailing lists archives, so I’ve decided to throw down a quick summary of what I’ve found.

Just a note: This uses the NetBSD 11.0 artefacts. If you try to build your own from source, you’ll need to adjust your process appropriately.

Updating the Firmware

First, you need to blast on the latest firmware which you can find on GitHub. The Star64 can use the VisionFive V2’s OpenSBI and uBoot verbatim. I ended up using the tftp method for overwriting the copies in SPI flash and that got me past the first hurdle.

Fetching the root image

Next, you need to grab the riscv64.img.gz file from a NetBSD mirror. (which you’ll find inside of the NetBSD-11.0/riscv-riscv64/binary/gzimg/ subtree). This you can decompress and image onto your target storage device (eMMC and SD both work).

Don’t worry about it not filling the target disk – when NetBSD boots this image the first time, it’ll automatically expand itself to fill the disk.

Setting up u-boot

This is the bit that was barely documented and I had to go hunting to find.

Whilst the NetBSD environment does use EFI to boot, it’s not at all automagical – you need to configure uboot to load the dtb and efi stage1 loader.

Power up the Star64 and interrupt the boot process so you get a boot prompt.

Next, you need to set the bootcmd environment variable to automatically load the dtb and stage1:

setenv bootcmd "load mmc 0:1 ${fdt_addr_r} dtb/starfive/jh7110-pine64-star64.dtb; load mmc 0:1 ${kernel_addr_r} efi/boot/bootriscv64.efi; bootefi ${kernel_addr_r} ${fdt_addr_r}"

If you’re using an SD card, rather than an eMMC, you need to change the two load commands to reference mmc 1:1 instead.

(If you’re using another RISCV board that uses the same boot method, you can change the dtb to load also).

Finally, save the change to SPI flash

saveenv

From here, you should be able to power cycle the star64 and it will try to autoboot NetBSD.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.