Re: FreeBSD on Star64 from Pine64

From: Milan Obuch <freebsd-riscv_at_dino.sk>
Date: Thu, 29 May 2025 06:16:19 UTC
On Wed, 28 May 2025 14:47:08 -0300
Mitchell Horne <mhorne@freebsd.org> wrote:

> Please try updating your firmware (u-boot), as Rich suggested. This
> hardware should be supported by the version we ship in ports:
> sysutils/u-boot-starfive-visionfive2.

OK, I had this port already built, so no problem to try it...

> This flavour of u-boot contains logic to select the appropriate DTB
> for your hardware; you should not need to change or load anything
> manually.

Almost, see below.

> After this I expect that booting FreeBSD should succeed, but I do not
> have this Star64 hardware to confirm first-hand.

It took me couple of hours to get everything in line, so I am going to
write what needs to be done in order to get somehow meaningfull result.

First, my attempts before was based on boot from SPI flash, where old
U-Boot is residing. This was enough for some Linux based distribution
to boot. At the same time, I did not want to overwrite it, so I still
have something working, just in case.

Switch to boot from SD card is relatively easy, change boot mode switch
selection from 00 to 01, provided you have properly prepared SD card.
For this you actually can't use directly snapshot prepared by FreeBSD
project, it is probably tailored for HiFive boards.

When you examine its content, you see following:

# gpart show -r md0
=>      40  12582832  md0  GPT  (6.0G)
        40      4056       - free -  (2.0M)
      4096      4096    1  5b193300-fc78-40cd-8002-e86c45580b47  (2.0M)
      8192      8192    2  2e54b353-1271-4842-806f-e436d6af6985  (4.0M)
     16384    110592    3  c12a7328-f81f-11d2-ba4b-00a0c93ec93b  (54M)
    126976  12455808    4  516e7cb6-6ecf-11d6-8ff8-00022d09712b  (5.9G)
  12582784        88       - free -  (44K)

Read https://docs.u-boot.org/en/latest/board/starfive/pine64_star64.html
and README from sysutils/u-boot-starfive-visionfive2 port, you see
UUIDs are not correct for StarFive board, they should be

# gpart show -r da0
=>      40  30719920  da0  GPT  (15G)
        40      4056       - free -  (2.0M)
      4096      4096    1  2e54b353-1271-4842-806f-e436d6af6985  (2.0M)
      8192      8192    2  bc13c2ff-59e6-4262-a352-b275fd6f7172  (4.0M)
     16384    131072    3  c12a7328-f81f-11d2-ba4b-00a0c93ec93b  (64M)
    147456  30572504    4  516e7cb6-6ecf-11d6-8ff8-00022d09712b  (15G)

(I have slightly bigger EFI partition and use all available space for
root filesystem, that's minor detail). It was necessary to build the
card anew (I tried first delete just partitions 1 and 2, but that
failed, probably some card failure) so the boot from SD card is doing
what's expected.

Long story short, the result is

mountroot: waiting for device /dev/ufs/rootfs...
regulator: shutting down unused regulators
Mounting from ufs:/dev/ufs/rootfs failed with error 19.

Loader variables:
  vfs.root.mountfrom=ufs:/dev/ufs/rootfs
  vfs.root.mountfrom.options=rw

Manual root filesystem specification:
  <fstype>:<device> [options]
      Mount <device> using filesystem <fstype>
      and with the specified (optional) option list.

    eg. ufs:/dev/da0s1a
        zfs:zroot/ROOT/default
        cd9660:/dev/cd0 ro
          (which is equivalent to: mount -t cd9660 -o ro /dev/cd0 /)

  ?               List valid disk boot devices
  .               Yield 1 second (for background tasks)
  <empty line>    Abort manual input

mountroot> ?

List of GEOM managed disk devices:
  

mountroot> 

Which means I need to investigate a bit more to find what the problem
is with SD card (something in DTB, 'no bus speed provided'). See
attached boot log. This looks promising - somehow tuning DTB should
yield correct result, I hope.

Regards,
Milan