Overview

This tutorial walks you through downloading and configuring the FreeBSD 14.2 image for Raspberry Pi Compute Module 4 (CM4). You’ll enable SSH access, configure the system, and install a custom EFI loader. If you are using a Compute Blade, this guide will work for you as well.

Prerequisites

  1. Raspberry Pi CM4 or a system with an eMMC/SD card.
  2. FreeBSD environment or a system capable of running the required commands.
  3. Your SSH public key for remote access.
  4. Basic familiarity with Unix commands.
  5. A reliable internet connection.

Step 1: Download and Modify the FreeBSD RPI Image

  1. Download the FreeBSD image for ARM64 Raspberry Pi:

    fetch https://download.freebsd.org/releases/arm64/aarch64/ISO-IMAGES/14.2/FreeBSD-14.2-RELEASE-arm64-aarch64-RPI.img.xz FreeBSD-14.2-RELEASE-arm64-aarch64-RPI.img.xz
    
  2. Decompress the image:

    xz -d -v FreeBSD-14.2-RELEASE-arm64-aarch64-RPI.img.xz
    

    This will extract the .img file required for mounting.

  3. Create a virtual device for the image:

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

    This command assigns the image to a memory disk (e.g., /dev/md0).

  4. Mount the image partitions:

    mount -t msdosfs /dev/md0s1 /tmp/1
    mount -t ufs /dev/md0s2a /tmp/2
    
    • Partition /dev/md0s1 (FAT32) is the boot partition.
    • Partition /dev/md0s2a (UFS) is the system root.
  5. Disable devmatch service (optional but recommended):

    sysrc -f /tmp/2/etc/rc.conf devmatch_enable=NO
    
  6. Add your SSH public key for root access:

    mkdir -p /tmp/2/root/.ssh
    chmod 700 /tmp/2/root/.ssh
    fetch -o - https://URL_TO_YOUR_SSH_PUB >> /tmp/2/root/.ssh/authorized_keys
    chmod 600 /tmp/2/root/.ssh/authorized_keys
    

    Replace https://URL_TO_YOUR_SSH_PUB with the actual URL to your public key.

  7. Enable root login via SSH:

    sudo sed -i "" 's/^#PermitRootLogin no/PermitRootLogin without-password/' /tmp/2/etc/ssh/sshd_config
    

Step 2: Install the Custom EFI Loader

For Raspberry Pi, custom EFI loaders improve boot compatibility. You can use the provided custom EFI loader or manually merge it with the official one.

  1. Download the EFI loader:

    fetch http://hackacad.net/files/blade_efi_freebsd_v0.1.tgz
    
  2. Extract the EFI loader to the boot partition:

    tar xvzf blade_efi_freebsd_v0.1.tgz -C /tmp/1
    

    Note: If you prefer not to trust third-party binaries, download the official EFI files from pftf/RPi4 and merge them manually.


Step 3: Finalize the Image and Write to eMMC/SD-Card

  1. Unmount the partitions and clean up:

    umount /tmp/1
    umount /tmp/2
    mdconfig -d -u 0
    
  2. Prepare the Raspberry Pi’s eMMC or SD card:

    • If using a Compute Module 4 (CM4) with eMMC, the SD card will be disabled.
    • Attach the device to your system using USB or a suitable interface.
  3. Install rpiboot to interact with eMMC:

    git clone --depth=1 https://github.com/raspberrypi/usbboot
    cd usbboot
    ./rpiboot
    

    This tool enables communication with the eMMC.

  4. Identify the eMMC device: Run dmesg to identify the correct device (e.g., /dev/mmcblk0).

  5. Write the modified image to the eMMC/SD card:

    dd if=FreeBSD-14.2-RELEASE-arm64-aarch64-RPI.img of=/dev/mmcblk0 bs=1M
    

    Replace /dev/mmcblk0 with your actual device identifier.


Step 4: Optional - Boot from Ubuntu

If you have a Compute Blade DEV setup, you can boot from Ubuntu and transfer the FreeBSD image using a local server.

  1. Start a simple HTTP server on your machine hosting the image:

    python -m http.server 8000
    
  2. Fetch the image from Ubuntu:

    fetch http://server:8000/FreeBSD-14.2-RELEASE-arm64-aarch64-RPI.img
    
  3. Write the image:

    dd if=FreeBSD-14.2-RELEASE-arm64-aarch64-RPI.img of=/dev/mmcblk0 bs=1M
    

References and Acknowledgments

This guide was made possible with the following resources:

Special thanks to those contributing to the FreeBSD and Compute Blade communities.


By following this guide, you should now have FreeBSD 14.2 successfully installed and running on your Raspberry Pi CM4 with proper SSH access and bootloader configuration.