Booting FreeBSD 13-RELEASE on AmigaOne X5000 (Cyrus P5020)

From: widelec-bb <widelecbb_at_protonmail.com>
Date: Thu, 07 Apr 2022 18:29:39 UTC
Hello.

I'm trying to boot FreeBSD 13-RELEASE on AmigaOne x5000. I can load ubldr
from u-boot, but I can't get it to load the kernel. How can I do that?

This is the boot sequence I have (from u-boot console):

X5000> run bootfreebsd
reading ubldr
315292 bytes read in 238 ms (1.3 MiB/s)
reading bsd_cyrus_p5020.dtb
65536 bytes read in 254 ms (252 KiB/s)
## Starting application at 0x00010160 ...
Consoles: U-Boot console
Compatible U-Boot API signature found @0x7fe2efd8

FreeBSD/powerpc64 U-Boot loader, Revision 1.1

Number of U-Boot devices: 4
U-Boot env: loaderdev not set, will probe all devices.
Found U-Boot device: disk
  Probing all <unknown> devices...
  Checking unit=0 slice=<auto> partition=<auto>...
  Checking unit=1 slice=<auto> partition=<auto>...
  Checking unit=2 slice=<auto> partition=<auto>... good.
Booting from disk2s4a:
/
can't load 'kernel'

Type '?' for a list of commands, 'help' for more detailed help.

The bootfreebsd variable is defined as shown at
https://wiki.freebsd.org/powerpc/UBoot-Install that is:
fatload sata 1:1 $loadaddr ubldr;
fatload sata 1:1 $fdtaddr bsd_cyrus_p5020.dtb;
fdt addr $fdtaddr;
fdt boardsetup;
bootelf $loadaddr;

The addr variables are defined as:
loadaddr=1000000
fdtaddr=c00000

File bsd_cyrus_p5020.dtb is downloaded from
https://people.freebsd.org/~jhibbits/cyrus_p5020.dtb

ubdlr lsdev:
loader> lsdev
disk devices:
        disk0 (MMC)
        disk1 (SATA)
        disk1p1: EFI
        disk1p2: APFS
        disk2 (SATA)
        disk2s1: DOS/Windows
        disk2s2: Linux
        disk2s3: Linux
        disk2s4: FreeBSD
        disk2s4a: FreeBSD UFS
        disk2s4b: FreeBSD swap
net devices:
        net0:

FreeBSD partitions have been created under VM (VirtualBox/amd64) using
gpart, following EXAMPLES/MBR section from manual.
Output of "gpart show" on VM:
=>        63  4000797296  da0  MBR  (1.9T)
          63        1985       - free -  (993K)
        2048     4194304    1  fat32  (2.0G)
     4196352   104857600    2  linux-data  (50G)
   109053952  1074120704    3  linux-data  (512G)
  1183174656   268435456    4  freebsd  (128G)
  1451610112  2549187247       - free -  (1.2T)

=>        0  268435456  da0s4  BSD  (128G)
          0  104857600      1  freebsd-ufs  (50G)
  104857600   33554432      2  freebsd-swap  (16G)
  138412032  130023424         - free -  (62G)

It is "da0" because disk was connected via sata->usb adapter.
On disk (da0s4a) I extracted kernel.txz and base.txz downloaded from
https://download.freebsd.org/releases/powerpc/powerpc64/13.0-RELEASE/

I'm probably missing some simple, but required step, so any help will be
appreciated.

I think those are not relevant, but I tried also:
1. switching disk to become only disk in system and primary device (the
   first partition become sata 0:1 in uboot)
2. writing installation ISO to the usb stick
3. building system from sources and extracting generated kernel.txz
   and base.txz
4. writing installation ISO generated during build from source to USB stick
5. creating FreeBSD partitions on USB stick and extracting kernel.txz
   and base.txz on it (to exclude interference of the Linux partitions
   present on sata disk)
6. moving /boot/kernel/kernel to the root directory (partition da0s4a using
   names from "gpart show" output shown above)

In all those cases I end up with same error in ubldr (can't load 'kernel')
with FreeBSD partition properly discovered, variables loaderdev and currdev
in ubldr were assigned to correct device name.

When building system from sources I used following commands:
make -s -j3 buildworld buildkernel TARGET_ARCH=powerpc64 KERNCONF=QORIQ64
make -C release cdrom ARCH=powerpc
The second one have "ARCH" variable set which is not shown on wiki,
but seems to be required to run correctly.

- widelec-BB