Re: How to Boot FreeBSD Using pftf/RPi4 UEFI

From: Mark Millard <marklmi_at_yahoo.com>
Date: Thu, 21 Sep 2023 09:26:30 UTC
[Andrew T.: for main this lead to
"panic: Assertion smccc_version != 0 . . ."
for today's new snapshot.]

On Sep 21, 2023, at 01:11, Mark Millard <marklmi@yahoo.com> wrote:

> On Sep 20, 2023, at 22:45, ykla <yklaxds@gmail.com> wrote:
> 
>> HI,
> 
> Hello.
> 
>> How to Boot FreeBSD Using pftf/RPi4 UEFI?
>> 
>> I downloaded FreeBSD-14.0-BETA2-arm64-aarch64-disc1.iso and Raspberry Pi 4 UEFI Firmware v1.35 and wrote them to my device. However, when I enable ACPI, my Raspberry Pi 4 automatically restarts after loading. If I disable ACPI and use the device tree, the screen goes black after loading for a while, and nothing is displayed. In both of these cases, there is no output on the serial port. Does anyone know how to configure the serial port for UEFI Firmware? I've used the serial port before with the regular installation method and it worked for output, but with UEFI Firmware, there is no output on the serial port.
> 
> As I remember, pftf/RPi4 defaults to graphical, not serial.
> There is a place in the EDK2 UI to switch it to graphical.
> This status can be saved, which actually updates a data area
> inside its RPI_EFI.fd file so that future boots automatically
> are serial based for the adjusted RPI_EFI.fd .
> 
> I've not tried pftf/RPi4 in some time. It was v1.34
> back then.
> 
> I've never tried running the installer ( *-disc1.iso ).
> I've used older variants of what is now (MBR):
> 
> http://ftp3.freebsd.org/pub/FreeBSD/snapshots/ISO-IMAGES/15.0/FreeBSD-15.0-CURRENT-arm64-aarch64-RPI-20230921-febba4622b60-265435.img.xz
> 
> or (GPT, again: older variant last I tried):
> 
> http://ftp3.freebsd.org/pub/FreeBSD/snapshots/ISO-IMAGES/15.0/FreeBSD-15.0-CURRENT-arm64-aarch64-ROCK64-20230921-febba4622b60-265435.img.xz
> 
> and substituted or added the pftf/RPi4 materials inside the
> msdosfs involved for the USB3 media that I used, leaving
> the FreeBSD UEFI loader materials in place.
> 
> Use of the ROCK64 image means there is no RPi* firmware,
> armstub8* , or boot.bin materials to replace: I just added
> the pftf/RPi4 materials. (So: Simpler.)
> 
> May be I could experiment with more modern materials this
> weekend.

Actually, it should not take long to do a basic, preliminary test:

# dd if=FreeBSD-15.0-CURRENT-arm64-aarch64-ROCK64-20230921-febba4622b60-265435.img of=/dev/da0 bs=1m conv=fsync,sync status=progress
  5210374144 bytes (5210 MB, 4969 MiB) transferred 21.005s, 248 MB/s
5120+0 records in
5120+0 records out
5368709120 bytes transferred in 21.736867 secs (246986330 bytes/sec)

# gpart show -pl da0
=>      40  10485680    da0  GPT  (224G) [CORRUPT]
        40     32728         - free -  (16M)
     32768    102400  da0p1  efi  (50M)
    135168  10350464  da0p2  rootfs  (4.9G)
  10485632        88         - free -  (44K)

# mount -onoatime -tmsdosfs /dev/da0p1 /mnt
# ls -Tlod /mnt/*
drwxr-xr-x  1 root wheel - 4096 Sep 20 23:43:20 2023 /mnt/EFI
drwxr-xr-x  1 root wheel - 4096 Sep 20 23:43:20 2023 /mnt/dtb

# tar -xpf RPi4_UEFI_Firmware_v1.35.zip -C /mnt/
RPI_EFI.fd: Can't set user=1001/group=123 for RPI_EFI.fd: Invalid argument
bcm2711-rpi-4-b.dtb: Can't set user=1001/group=123 for bcm2711-rpi-4-b.dtb: Invalid argument
bcm2711-rpi-400.dtb: Can't set user=1001/group=123 for bcm2711-rpi-400.dtb: Invalid argument
bcm2711-rpi-cm4.dtb: Can't set user=1001/group=123 for bcm2711-rpi-cm4.dtb: Invalid argument
config.txt: Can't set user=1001/group=123 for config.txt: Invalid argument
fixup4.dat: Can't set user=1001/group=123 for fixup4.dat: Invalid argument
start4.elf: Can't set user=1001/group=123 for start4.elf: Invalid argument
overlays/: Can't set user=1001/group=123 for overlays: Invalid argument
overlays/upstream-pi4.dtbo: Can't set user=1001/group=123 for overlays/upstream-pi4.dtbo: Invalid argument
overlays/miniuart-bt.dtbo: Can't set user=1001/group=123 for overlays/miniuart-bt.dtbo: Invalid argument
Readme.md: Can't set user=1001/group=123 for Readme.md: Invalid argument
firmware/: Can't set user=1001/group=123 for firmware: Invalid argument
firmware/Readme.txt: Can't set user=1001/group=123 for firmware/Readme.txt: Invalid argument
firmware/brcm/: Can't set user=1001/group=123 for firmware/brcm: Invalid argument
firmware/brcm/brcmfmac43455-sdio.txt: Can't set user=1001/group=123 for firmware/brcm/brcmfmac43455-sdio.txt: Invalid argument
firmware/brcm/brcmfmac43455-sdio.clm_blob: Can't set user=1001/group=123 for firmware/brcm/brcmfmac43455-sdio.clm_blob: Invalid argument
firmware/brcm/brcmfmac43455-sdio.bin: Can't set user=1001/group=123 for firmware/brcm/brcmfmac43455-sdio.bin: Invalid argument
firmware/brcm/brcmfmac43455-sdio.Raspberry: Can't set user=1001/group=123 for firmware/brcm/brcmfmac43455-sdio.Raspberry: Invalid argument
firmware/LICENCE.txt: Can't set user=1001/group=123 for firmware/LICENCE.txt: Invalid argument
tar: Error exit delayed from previous errors.

# ls -Tlod /mnt/*
drwxr-xr-x  1 root wheel -        4096 Sep 20 23:43:20 2023 /mnt/EFI
-rwxr-xr-x  1 root wheel uarch 2031616 Jun  5 04:12:52 2023 /mnt/RPI_EFI.fd
-rwxr-xr-x  1 root wheel uarch    5051 Jun  5 04:04:18 2023 /mnt/Readme.md
-rwxr-xr-x  1 root wheel uarch   54388 Jun  5 04:12:58 2023 /mnt/bcm2711-rpi-4-b.dtb
-rwxr-xr-x  1 root wheel uarch   54477 Jun  5 04:13:00 2023 /mnt/bcm2711-rpi-400.dtb
-rwxr-xr-x  1 root wheel uarch   54997 Jun  5 04:12:58 2023 /mnt/bcm2711-rpi-cm4.dtb
-rwxr-xr-x  1 root wheel uarch     243 Jun  5 04:04:18 2023 /mnt/config.txt
drwxr-xr-x  1 root wheel -        4096 Sep 20 23:43:20 2023 /mnt/dtb
drwxr-xr-x  1 root wheel -        4096 Jun  5 04:04:18 2023 /mnt/firmware
-rwxr-xr-x  1 root wheel uarch    5397 Jun  5 04:12:56 2023 /mnt/fixup4.dat
drwxr-xr-x  1 root wheel -        4096 Jun  5 04:13:00 2023 /mnt/overlays
-rwxr-xr-x  1 root wheel uarch 2253088 Jun  5 04:12:58 2023 /mnt/start4.elf

# umount /mnt

I connected the USB3 media to the RPi4B here.

Booting and using ESCAPE to enter the EDK2 UI worked fine
on the serial console. (No HDMI cable present.)

Select Device Manager
Select Raspberry Pi Configuration
Select Console Preference Selection
Select Preferred console Serial

Save then Escape out to the main page
Select Reset

Hit enter when prompted

Loading kernel...
/boot/kernel/kernel text=0x2a8 text=0x91a3f0 text=0x2a4d04 data=0x159148 data=0x
0+0x37a000 0x8+0x157ad0+0x8+0x18198e
Loading configured modules...
/boot/kernel/umodem.ko text=0x2040 text=0x1350 data=0x6f8+0x4 0x8+0xeb8+0x8+0xb2
c
loading required module 'ucom'
/boot/kernel/ucom.ko text=0x2590 text=0x2e70 data=0x960+0x858 0x8+0x1278+0x8+0xb
cf
can't find '/etc/hostid'
can't find '/boot/entropy'

Hit [Enter] to boot immediately, or any other key for command prompt.
Booting [/boot/kernel/kernel]...               
No valid device tree blob found!
WARNING! Trying to fire up the kernel, but no device tree blob found!
---<<BOOT>>---
GDB: no debug ports present
KDB: debugger backends: ddb
KDB: current backend: ddb
Copyright (c) 1992-2023 The FreeBSD Project.
Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994
        The Regents of the University of California. All rights reserved.
FreeBSD is a registered trademark of The FreeBSD Foundation.
FreeBSD 15.0-CURRENT #0 main-n265435-febba4622b60: Thu Sep 21 05:44:48 UTC 2023
    root@releng3.nyi.freebsd.org:/usr/obj/usr/src/arm64.aarch64/sys/GENERIC arm64
FreeBSD clang version 16.0.6 (https://github.com/llvm/llvm-project.git llvmorg-16.0.6-0-g7cbf1a259152)
WARNING: WITNESS option enabled, expect reduced performance.
VT: init without driver.
module scmi already present!
real memory  = 3138154496 (2992 MB)
avail memory = 3027505152 (2887 MB)
panic: Assertion smccc_version != 0 failed at /usr/src/sys/dev/psci/smccc.c:81
cpuid = 0
time = 1
KDB: stack backtrace:
db_trace_self() at db_trace_self
db_trace_self_wrapper() at db_trace_self_wrapper+0x30
vpanic() at vpanic+0x19c
panic() at panic+0x44
smccc_arch_features() at smccc_arch_features+0x80
install_cpu_errata() at install_cpu_errata+0x4c
cpu_startup() at cpu_startup+0xac
mi_startup() at mi_startup+0x1d8
virtdone() at virtdone+0x70
KDB: enter: panic
[ thread pid 0 tid 0 ]
Stopped at      kdb_enter+0x44: undefined       f901c27f
db> 

Note: This smccc_version check was added to main [so: 15] yesterday.

But, upto the new smccc_version check, it seemed to be working just
fine.


===
Mark Millard
marklmi at yahoo.com