OpenBSD 7.4, Raspberry Pi 3 model B+ Install Guide

I've wanted to try OpenBSD on a Raspberry Pi for a while, and I've finally managed it. The trickiest part for me was the serial cable and the boot sequence that I describe below.

First, you need a microSD card and, if your computer doesn't have a slot for it, a microSD-to-USB adapter. Additionally, you'll need a USB-to-TTL serial cable, like this one from Adafruit. Also, make sure you know enough vi to get by.

Download miniroot74.img and install74.img from the ARM64 release directory. (The .tgz files are the filesets.) Additionally, download the bwfm-firmware-… file from the firmware directory.

Burn miniroot74.img to the microSD card, and install74.img (the full disk image) to the USB drive. Replace /dev/sdX and /dev/sdY with the correct device files!

# cat miniroot74.img >/dev/sdX
# cat install74.img >/dev/sdY

The plan is this: the Raspberry Pi naturally boots from the microSD card, which has the miniroot74.img bootloader on it. We'll tell the bootloader to boot OpenBSD from the USB drive, which has full installation files on it. Then we can safely install a working system to the microSD card, since we're booted from USB.

We need to add WiFi firmware to the USB drive. Create a new partition on the USB drive using cfdisk with 500 megabytes of space (larger than necessary) of type W95 FAT32 (LBA). After this, the drive should have two FAT partitions, one originally from install74.img and one from us.

Then format the partition and copy the firmware to it.

# mkfs.fat /dev/sdY2
# mount /dev/sdY2 /mnt
# cp bwfm-firmware-20200316.1.3p3.tgz /mnt
# umount /mnt

In case it's useful, here's the incantation to mount an OpenBSD UFS partition:

# mount -r -t ufs -o ufstype=44bsd /dev/sda4 /mnt

Now wire the USB-to-TTL cable to the Raspberry Pi. Phrases like “white RX, green TX” are from the perspective of the host computer, so white plugs in to the Raspberry Pi's transfer pin, and green to the Pi's receive pin.

Plug the cable in, and use

$ screen /dev/ttyUSB0 115200

to connect to the serial cable. You may need to add your user to the uucp group or similar; check the permissions with

$ ls -l /dev/ttyUSB0

Then power on the Raspberry Pi. Interrupt the boot process when you see OpenBSD's boot> prompt. Type the following incantation to boot from the USB drive.

disks: sd0* sd1
>> OpenBSD/arm64 BOOTAA64 1.18
boot> boot sd1a:/bsd

You can use commands like

boot> ls sd0a:/

to examine the filesystem before booting. For me, sd0 was the microSD card and sd1 the USB drive.

Now read the ARM-specific INSTALL file and the FAQ's installation entry. Follow the prompts for installation, but consider these notes:

You can now reboot fully from the SD card. Here are some final touches to consider.

If you're not going to add your hostname to DNS (e.g., sappho.sigxcpu.com), make it resolve locally by adding these lines to /etc/hosts:

127.0.0.1 sappho.sigxcpu.com
::1 sappho.sigxcpu.com

To disable relinking system libraries on boot (quite slow), add this to /etc/rc.conf.local (see rc.conf(8)):

library_aslr=NO

To connect to WiFi, you need to get the bwfm firmware files onto the microSD card. But our FAT partition won't show up in OpenBSD because it's not part of the USB drive's disklabel (which lists all partitions OpenBSD should recognize).

The way I fixed this is with the -e option, which opens an interface in vi.

# disklabel -e sd1

Then you can use disklabel -d to output a “default” disklabel (OpenBSD will detect our second FAT partition). The following incantation reads (:r) the default disklabel into vi, selecting the correct line with grep.

:r !disklabel -d sd1 | grep j:

Then move the line below i:, write the changes, and exit. You can mount the partition and load the firmware:

# mount /dev/sd1j /mnt
# fw_update /mnt/bwfm-firmware-20200316.1.3p3.tgz

Now connect to WiFi using the regular ifconfig method.

Happy hacking! See intro(8) and afterboot(8) for what to do with the system now.