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

From: widelec-bb <widelecbb_at_protonmail.com>
Date: Sat, 09 Apr 2022 12:03:32 UTC
> > You will need to compile the kernel and userland.
> > You may want to put FreeBSD on it's own disk until you get it working.
>
> I already tried to use usb stick with only BSD partitions, but I guess
> there is no harm in checking this with internal disk also.

I tried once again from the beginning. Here is step by step log what did I do.

First, I created a VM on PC and installed FreeBSD from iso image.
FreeBSD-13.0-RELEASE-amd64-disc1.iso, sha256:
f78d4e5f53605592863852b39fa31a12f15893dc48cacecd875f2da72fa67ae5

After booting VM and login to FreeBSD:

root@freebsd:~ # cd /usr/src/
root@freebsd:/usr/src # make -s -j3 buildworld buildkernel TARGET_ARCH=powerpc64 KERNCONF=QORIQ64

--------------------------------------------------------------
>>> World build completed on Sat Apr  9 12:50:02 CEST 2022
>>> World built in 3697 seconds, ncpu: 4, make -j3
--------------------------------------------------------------

--------------------------------------------------------------
>>> Kernel build for QORIQ64 completed on Sat Apr  9 12:54:16 CEST 2022
--------------------------------------------------------------
>>> Kernel(s)  QORIQ64 built in 254 seconds, ncpu: 4, make -j3
--------------------------------------------------------------

root@freebsd:/usr/src # make -C release cdrom TARGET_ARCH=powerpc64 TARGET=powerpc KERNCONF=QORIQ64
[long output without errors]

Then I connected X5000 drive to VM using SATA->USB converter, and then:

root@freebsd:/ # gpart destroy -F da0
da0 destroyed
root@freebsd:/ # gpart create -s MBR da0
da0 created
root@freebsd:/ # gpart add -t fat16 -s 512M da0
da0s1 added
root@freebsd:/ # gpart add -t freebsd da0
da0s2 added
root@freebsd:/ # gpart create -s BSD -n 20 da0s2
da0s2 created
root@freebsd:/ # gpart add -t freebsd-ufs -s 512G da0s2
da0s2a added
root@freebsd:/ # gpart add -t freebsd-swap -s 16G da0s2
da0s2b added
root@freebsd:/ # gpart show
=>        63  4000797296  da0  MBR  (1.9T)
          63           1       - free -  (512B)
          64     1048576    1  fat16  (512M)
     1048640  3999748712    2  freebsd  (1.9T)
  4000797352           7       - free -  (3.5K)

=>         0  3999748712  da0s2  BSD  (1.9T)
           0  1073741824      1  freebsd-ufs  (512G)
  1073741824    33554432      2  freebsd-swap  (16G)
  1107296256  2892452456         - free -  (1.3T)

root@freebsd:~ # newfs_msdos -F16 /dev/da0s1
/dev/da0s1: 1048256 sectors in 32758 FAT16 clusters (16384 bytes/cluster)
BytesPerSec=512 SecPerClust=32 ResSectors=1 FATs=2 RootDirEnts=512 Media=0xf0 FATsecs=128 SecPerTrack=63 Heads=255 HiddenSecs=0 HugeSectors=1048576

root@freebsd:/ # newfs /dev/da0s2a
/dev/da0s2a: 524288.0MB (1073741824 sectors) block size 32768, fragment size 4096
	using 839 cylinder groups of 625.22MB, 20007 blks, 80128 inodes.
super-block backups (for fsck_ffs -b #) at:
 192, 1280640, 2561088, 3841536, 5121984, 6402432...

root@freebsd:/ # mkdir /mnt/fat
root@freebsd:/ # mkdir /mnt/bsd
root@freebsd:/ # mount -t msdos /dev/da0s1 /mnt/fat
root@freebsd:/ # mount /dev/da0s2a /mnt/bsd
root@freebsd:/ # cp /usr/obj/usr/src/powerpc.powerpc64/stand/powerpc/uboot/ubldr /mnt/fat/
root@freebsd:/ # wget https://people.freebsd.org/~jhibbits/cyrus_p5020.dtb -O /mnt/fat/bsd_cyrus_p5020.dtb
root@freebsd:/mnt/bsd # openssl sha256 /mnt/fat/bsd_cyrus_p5020.dtb
SHA256(/mnt/fat/bsd_cyrus_p5020.dtb)= 0fbbc5937e9fe9d34e19fe2f39b3c754cbbfee7a89e4ae59b31ab9a37206e339
root@freebsd:/ # cd /mnt/bsd/
root@freebsd:/mnt/bsd # tar xf /usr/obj/usr/src/powerpc.powerpc64/release/base.txz
root@freebsd:/mnt/bsd # tar xf /usr/obj/usr/src/powerpc.powerpc64/release/kernel.txz
root@freebsd:/mnt/bsd # cd
root@freebsd:~ # umount /mnt/fat
root@freebsd:~ # umount /mnt/bsd

After that I turned off VM, disconnected drive and connected it to the X5000
as solo drive (no more SATA devices, first SATA port). In U-Boot I did:
X5000> fatload sata 0:1 $loadaddr ubldr
reading ubldr
965376 bytes read in 26 ms (35.4 MiB/s)
X5000> fatload sata 0:1 $fdtaddr bsd_cyrus_p5020.dtb
reading bsd_cyrus_p5020.dtb
65536 bytes read in 41 ms (1.5 MiB/s)
X5000> fdt addr $fdtaddr
X5000> fdt boardsetup
X5000> setenv loaderdev disk1s2a
X5000> setenv bootargs vfs.root.mountfrom=ufs:/dev/ada0s2a
X5000> bootelf $loadaddr
## 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='disk1s2a'
Found U-Boot device: disk
  Checking unit=1 slice=2 partition=0... good.
Booting from disk1s2a:
/
can't load 'kernel'

Type '?' for a list of commands, 'help' for more detailed help.
loader> show
LINES=24
console=uboot
currdev=disk1s2a:
interpret=OK
loaddev=disk1s2a:
prompt=loader>
script.lang=forth
twiddle_divisor=1
usefdt=1
loader> lsdev
disk devices:
        disk0 (MMC)
        disk1 (SATA)
        disk1s1: DOS/Windows
        disk1s2: FreeBSD
        disk1s2a: FreeBSD UFS
        disk1s2b: FreeBSD swap
        disk2 (SATA)
Non-NCQ command time out
Non-NCQ command time out
Non-NCQ command time out
net devices:
        net0:

Unfortunatelly result was the same as before. The reason for error
"Non-NCQ command time out" is no device connected to the second SATA
port.

Is there any step I missed during this procedure?

- widelec-BB