FreeBSD 14.0 on a Raspberry Pi CM4

Per the title. There are some CM4 nodes needing a better home than with Linux, so let’s adapt the standard RPi image with a few changes which are required for the compute modules.

Download the FreeBSD RPi image

cd /tmp

xz -d FreeBSD-14.0-RELEASE-arm64-aarch64-RPI.img.xz

Mounting and Modifying the Disk Image

Mount the decompressed image

mdconfig -a -t vnode -f FreeBSD-14.0-RELEASE-arm64-aarch64-RPI.img -u 0

Create mount-point directories

/mnt/cm4-mdNs1 /mnt/cm4-mdNs2a

Mount U-Boot and UFS Partitions

mount -t msdosfs /dev/md0s1 /mnt/cm4-mdNs1
mount -t ufs /dev/md0s2a /mnt/cm4-mdNs2a

Edit rc.conf for Device Matching

Add some parameters to rc.conf

cd /mnt/cm4-mdNs1
echo "devmatch_enable=\"NO\"" >> etc/rc.conf

Copy the CM4 Firmware DTDs

We’ll copy these to the msdos partition in: /mnt/cm4-mdNs1

cd /tmp

sudo cp -v bcm2711-* /mnt/cm4-mdNs1/

Unmount Detach and ReCompress

cd /tmp
umount /mnt/cm4-mdNs1
umount /mnt/cm4-mdNs2a
mdconfig -d -u 0

mv FreeBSD-13.2-RELEASE-arm64-aarch64-RPI.img FreeBSD-13.2-RELEASE-arm64-aarch64-RPI-CM4.img
xz -z -k FreeBSD-13.2-RELEASE-arm64-aarch64-RPI-CM4.img

DD’it and Boot

Put the CM4 into USB-OTG mode with ‘rpiboot’ or other means, then write the image to the device.

dd if=FreeBSD-14.0-RELEASE-arm64-aarch64-RPI.CM4-Prinzessin.v0-1.img of=/dev/sda conv=sync bs=1M   status=progress
  5367660544 bytes (5.4 GB, 5.0 GiB) copied, 780 s, 6.9 MB/s
  5120+0 records in
  5120+0 records out
  5368709120 bytes (5.4 GB, 5.0 GiB) copied, 1005.83 s, 5.3 MB/s

Example Boot via TTL

Consoles: EFI console  serial port
    Reading loader env vars from /efi/freebsd/loader.env
Setting currdev to disk0p1:
FreeBSD/arm64 EFI loader, Revision 1.1

   Command line arguments: loader.efi
   Image base: 0x39e26000
   EFI version: 2.100
   EFI Firmware: Das U-Boot (rev 8227.1792)
   Console: efi,comconsole (0)
   Load Path: /efi\boot\bootaa64.efi
   Load Device: /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/eMMC(0)/eMMC(1)/HD(1,0x01,0,0x800,0x19000)
Trying ESP: /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/eMMC(0)/eMMC(1)/HD(1,0x01,0,0x800,0x19000)
Setting currdev to disk0p1:
Trying: /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/eMMC(0)/eMMC(1)/HD(2,0x01,0,0x19800,0x9e6800)
Setting currdev to disk0p2:
Loading /boot/defaults/loader.conf
Loading /boot/defaults/loader.conf
Loading /boot/device.hints
Loading /boot/loader.conf
Loading /boot/loader.conf.local
Loading kernel...
/boot/kernel/kernel text=0x2a8 text=0x9b50c0 text=0x25ca5c data=0x14d1b8 data=0x0+0x2c5000 0x8+0x14ba70+0x8+0x174176
Loading configured modules...
/boot/kernel/umodem.ko text=0x2040 text=0x1350 data=0x6f8+0x4 0x8+0xeb8+0x8+0xb2c
loading required module 'ucom'
/boot/kernel/ucom.ko text=0x249f text=0x3370 data=0x920+0x858 0x8+0x1170+0x8+0xb13
can't find '/boot/entropy'
can't find '/etc/hostid'

Hit [Enter] to boot immediately, or any other key for command prompt.
Booting [/boot/kernel/kernel]...
Using DTB provided by EFI at 0x39efb000.
EFI framebuffer information:
addr, size     0x3eac2000, 0x103000
dimensions     592 x 448
stride         592
masks          0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000
WARNING: Cannot find freebsd,dts-version property, cannot check DTB compliance
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 14.0-RELEASE #0 releng/14.0-n265380-f9716eee8ab4: Fri Nov 10 08:59:18 UTC 2023 arm64