Running OpenBSD on Raspberry Pi 3

       1945 words, 10 minutes

Step 1 was getting my hands on Raspbian. Step 2 was running OpenBSD on the Raspberry Pi 3 Model B. I had quite a few try & fails but it booted, installed and ran properly in the end. Full story follows.

The Hardware

To install OpenBSD 6.3 on the Raspberry Pi 3 V1.2, I used a 128MB microSD card (to host the installer), a microSD to USB adapter, a no-name 30GB USB stick, a TTL to USB Converter and an RJ45 Ethernet cable.

All was done from a Macbook Pro using macOS 10.13.5. Preparation commands shouldn’t differ that much if using *BSD or Linux.

I booted both OpenBSD 6.3 and 6.3-current but hardware support was the same. No WiFi interface…

Step by step procedure

Grab your favorite OpenBSD installation release file. I used miniroot63.fs.

Erase the microSD and USB stick. This may not be absolutely required but I like to start from real scratch.

# diskutil list

# diskutil unmountDisk /dev/disk2
# dd if=/dev/zero of=/dev/disk2 count=4096
(...)
# diskutil eject /dev/disk2
Disk /dev/disk2 ejected

# diskutil unmountDisk /dev/disk3
# dd if=/dev/zero of=/dev/disk3 count=4096
(...)
# diskutil eject /dev/disk3
Disk /dev/disk3 ejected

Insert the microSD card back into the MacBook, ignore the macOS initialize message and copy the miniroot file onto the card.

# diskutil list
(...)
/dev/disk2 (external, physical):
#: TYPE NAME SIZE IDENTIFIER
0: *126.0 MB disk2

# dd if=miniroot63.fs of=/dev/disk2 bs=1m
21+0 records in
21+0 records out
22020096 bytes transferred in 7.937130 secs (2774315 bytes/sec)

# diskutil list
(...)
/dev/disk2 (external, physical):
#: TYPE NAME SIZE IDENTIFIER
0: FDisk_partition_scheme *126.0 MB disk2
1: Windows_FAT_32 BOOT 4.2 MB disk2s1
2: OpenBSD 13.6 MB disk2s4

# diskutil eject /dev/disk2
Disk /dev/disk2 ejected

To be able to boot from the USB stick, the Raspberry has to be “patched”. This is done by enabling a flag in the OTP. You’ll have to insert the microSD card in the Mac and edit the BOOT/config.txt file adding a simple line of code.

# echo "program_usb_boot_mode=1" >> /Volumes/BOOT/config.txt

Insert the microSD in the RPI3 microSD slot, the USB stick in one of the RPI3 USB plug. Plug the ethernet cable in the RPI3. Connect the RPI3 and the Macbook using the USB to TTL Adapter.

From my Terminal, I used the following command to access the console :

# cu -l /dev/cu.usbserial -s 115200 | tee cu.log

Power the RPI3 using the microUSB power cable. I used a microUSB-USB cable and pluggued it into the USB3 of my Synology. It Worked ok. Although the console sometimes popped up voltage warnings.

Check in the console that everything boots:

U-Boot 2018.03 (Mar 20 2018 - 04:28:27 -0600)

DRAM: 948 MiB
RPI 3 Model B (0xa02082)

U-Boot 2018.03 (Mar 20 2018 - 04:28:27 -0600)

DRAM: 948 MiB
RPI 3 Model B (0xa02082)
MMC: mmc@7e202000: 0, sdhci@7e300000: 1
Loading Environment from FAT... *** Warning - bad CRC, using default environment

Failed (-5)
In: serial
Out: vidconsole
Err: vidconsole
Net: No ethernet found.
starting USB...
USB0: Core Release: 2.80a
scanning bus 0 for devices... 4 USB Device(s) found
scanning usb for storage devices... 1 Storage Device(s) found
Hit any key to stop autoboot: 0

U-Boot> usb storage
Device 0: Vendor: USB Rev: 1100 Prod: Flash Disk
Type: Removable Hard Disk
Capacity: 30720.0 MB = 30.0 GB (62914560 x 512)

U-Boot> boot
switch to partitions #0, OK
mmc0 is current device
Scanning mmc 0:1...
Found EFI removable media binary efi/boot/bootaa64.efi
Scanning disk mmc@7e202000.blk...
Card did not respond to voltage select!
Scanning disk sdhci@7e300000.blk...
Disk sdhci@7e300000.blk not ready
Scanning disk usb_mass_storage.lun0...
Found 4 disks
82780 bytes read in 12 ms (6.6 MiB/s)
## Starting EFI application at 01000000 ...
>> OpenBSD/arm64 BOOTAA64 0.11
boot>
cannot open sd0a:/etc/random.seed: No such file or directory
booting sd0a:/bsd: 2417208+377168+8373432-
+732352 [179732+96+291264+160768]=0xf498
f0
type 0x0 pa 0x0 va 0x0 pages 0x1 attr 0x8
type 0x7 pa 0x1000 va 0x0 pages 0x1ff attr 0x8
type 0x2 pa 0x200000 va 0x200000 pages 0x4000 attr 0x8
type 0x7 pa 0x4200000 va 0x0 pages 0x3e00 attr 0x8
type 0x6 pa 0x8000000 va 0xe0250b000 pages 0x8 attr 0x8000000000000008
type 0x7 pa 0x8009000 va 0x0 pages 0x312c0 attr 0x8
type 0x2 pa 0x392c9000 va 0x392c9000 pages 0x4 attr 0x8
(...)
type 0x2 pa 0x39f41000 va 0x39f41000 pages 0x146a attr 0x8
type 0x5 pa 0x3b3ab000 va 0xe358b6000 pages 0x1 attr 0x8000000000000008
type 0x2 pa 0x3b3ac000 va 0x39f41000 pages 0x54 attr 0x8
type 0xb pa 0x3f100000 va 0xe358b7000 pages 0x1 attr 0x8000000000000000
Copyright (c) 1982, 1986, 1989, 1991, 1993
The Regents of the University of California. All rights reserved.
Copyright (c) 1995-2018 OpenBSD. All rights reserved. https://www.OpenBSD.org

OpenBSD 6.3 (RAMDISK) #212: Sat Mar 24 20:24:43 MDT 2018
deraadt@arm64.openbsd.org:/usr/src/sys/arch/arm64/compile/RAMDISK
real mem = 959180800 (914MB)
avail mem = 892710912 (851MB)
mainbus0 at root: Raspberry Pi 3 Model B Rev 1.2
cpu0 at mainbus0 mpidr 0: ARM Cortex-A53 r0p4
efi0 at mainbus0: UEFI 2.7
efi0: Das U-Boot rev 0x0
simplefb0 at mainbus0: 656x416
wsdisplay0 at simplefb0
wsdisplay0: screen 0 added (std, vt100 emulation)
simplebus0 at mainbus0: "soc"
bcmintc0 at simplebus0
bcmdog0 at simplebus0
bcmrng0 at simplebus0
pluart0 at simplebus0
bcmaux0 at simplebus0
com0 at sim����: ns16550, no workingcom0: console
dwctwo0 at simplebus0
simplebus1 at mainbus0: "clocks"
agtimer0 at mainbus0: tick rate 19200 KHz
usb0 at dwctwo0: USB revision 2.0
uhub0 at usb0 configuration 1 interface 0 "Broadcom DWC2 root hub" rev 2.00/1.00 addr 1
uhub1 at uhub0 port 1 configuration 1 interface 0 "Standard Microsystems product 0x9514" rev 2.00/2.00 addr 2
smsc0 at uhub1 port 1 configuration 1 interface 0 "Standard Microsystems SMSC9512/14" rev 2.00/2.00 addr 3
smsc0: address xx:xx:xx:xx:xx:xx
ukphy0 at smsc0 phy 1: Generic IEEE 802.3u media interface, rev. 3: OUI 0x0001f0, model 0x000c
umass0 at uhub1 port 3 configuration 1 interface 0 "USB Flash Disk" rev 2.00/11.00 addr 4
umass0: using SCSI over Bulk-Only
scsibus0 at umass0: 2 targets, initiator 0
sd0 at scsibus0 targ 1 lun 0: <USB, Flash Disk, 1100> SCSI2 0/direct removable serial.090c1000000000014806
sd0: 30720MB, 512 bytes/sector, 62914560 sectors
bootfile: sd0a:/bsd
boot device: sd0
root on rd0a swap on rd0b dump on rd0b
WARNING: CHECK AND RESET THE DATE!
erase ^?, werase ^W, kill ^U, intr ^C, status ^T

Welcome to the OpenBSD/arm64 6.3 installation program.
(I)nstall, (U)pgrade, (A)utoinstall or (S)hell? i

Proceed to OpenBSD installation. Nothing special here. Network card will be smsc0 and can use DHCP. Using “Whole disk” will automatically create and populate an MSDOS partition to enable booting from the USB stick. At the time of writing, it is not possible to install OpenBSD on the microSD card ; there is no driver for it. Not sure but it seems eMMC is not supported either, yet. The only way to install OpenBSD is to use an USB boot-compatible storage.

Choose “Halt” in the end of installation. Unplug USB power. Remove the installation microSD.

Plug microUSB power back and watch OpenBSD booting.

U-Boot 2018.03 (Mar 20 2018 - 04:28:27 -0600)

DRAM:  948 MiB
RPI 3 Model B (0xa02082)
MMC:   mmc@7e202000: 0, sdhci@7e300000: 1
Loading Environment from FAT... WARNING at /usr/obj/ports/u-boot-aarch64-2018.03-aarch64/u-boot-2018.03/drivers/mmc/bcm2835_sdhost.c:438/bcm2835_send_command()!
WARNING at /usr/obj/ports/u-boot-aarch64-2018.03-aarch64/u-boot-2018.03/drivers/mmc/bcm2835_sdhost.c:438/bcm2835_send_command()!
Card did not respond to voltage select!
** Bad device mmc 0 **
Failed (-5)
In:    serial
Out:   vidconsole
Err:   vidconsole
Net:   No ethernet found.
starting USB...
USB0:   Core Release: 2.80a
scanning bus 0 for devices... 4 USB Device(s) found
       scanning usb for storage devices... 1 Storage Device(s) found
Hit any key to stop autoboot:  0
WARNING at /usr/obj/ports/u-boot-aarch64-2018.03-aarch64/u-boot-2018.03/drivers/mmc/bcm2835_sdhost.c:438/bcm2835_send_command()!
WARNING at /usr/obj/ports/u-boot-aarch64-2018.03-aarch64/u-boot-2018.03/drivers/mmc/bcm2835_sdhost.c:438/bcm2835_send_command()!
WARNING at /usr/obj/ports/u-boot-aarch64-2018.03-aarch64/u-boot-2018.03/drivers/mmc/bcm2835_sdhost.c:438/bcm2835_send_command()!
Card did not respond to voltage select!

Device 0: Vendor: USB      Rev: 1100 Prod: Flash Disk
            Type: Removable Hard Disk
            Capacity: 30720.0 MB = 30.0 GB (62914560 x 512)
... is now current device
Scanning usb 0:1...
Found EFI removable media binary efi/boot/bootaa64.efi
WARNING at /usr/obj/ports/u-boot-aarch64-2018.03-aarch64/u-boot-2018.03/drivers/mmc/bcm2835_sdhost.c:438/bcm2835_send_command()!
WARNING at /usr/obj/ports/u-boot-aarch64-2018.03-aarch64/u-boot-2018.03/drivers/mmc/bcm2835_sdhost.c:438/bcm2835_send_command()!
WARNING at /usr/obj/ports/u-boot-aarch64-2018.03-aarch64/u-boot-2018.03/drivers/mmc/bcm2835_sdhost.c:438/bcm2835_send_command()!
Card did not respond to voltage select!
Scanning disk mmc@7e202000.blk...
Disk mmc@7e202000.blk not ready
Card did not respond to voltage select!
Scanning disk sdhci@7e300000.blk...
Disk sdhci@7e300000.blk not ready
Scanning disk usb_mass_storage.lun0...
Found 3 disks
82780 bytes read in 88 ms (918 KiB/s)
## Starting EFI application at 01000000 ...

3996244+595624+583064+805616 [281462+96+464664/

type 0x0 pa 0x0 va 0x0 pages 0x1 attr 0x8
type 0x7 pa 0x1000 va 0x0 pages 0x1ff attr 0x8
type 0x2 pa 0x200000 va 0x200000 pages 0x4000 attr 0x8
type 0x7 pa 0x4200000 va 0x0 pages 0x3e00 attr 0x8
type 0x6 pa 0x8000000 va 0x20987be000 pages 0x8 attr 0x8000000000000008
type 0x7 pa 0x8009000 va 0x0 pages 0x317f6 attr 0x8
type 0x2 pa 0x397ff000 va 0x397ff000 pages 0x4 attr 0x8
(...)
type 0x5 pa 0x3b3ab000 va 0x20cbb69000 pages 0x1 attr 0x8000000000000008
type 0x2 pa 0x3b3ac000 va 0x39f41000 pages 0x54 attr 0x8
type 0xb pa 0x3f100000 va 0x20cbb6a000 pages 0x1 attr 0x8000000000000000
[ using 994392 bytes of bsd ELF symbol table ]
Copyright (c) 1982, 1986, 1989, 1991, 1993
        The Regents of the University of California.  All rights reserved.
Copyright (c) 1995-2018 OpenBSD. All rights reserved.  https://www.OpenBSD.org

OpenBSD 6.3 (GENERIC.MP) #41: Sat Mar 24 20:06:13 MDT 2018
    deraadt@arm64.openbsd.org:/usr/src/sys/arch/arm64/compile/GENERIC.MP
real mem  = 964644864 (919MB)
avail mem = 905125888 (863MB)
mainbus0 at root: Raspberry Pi 3 Model B Rev 1.2
cpu0 at mainbus0 mpidr 0: ARM Cortex-A53 r0p4
efi0 at mainbus0: UEFI 2.7
efi0: Das U-Boot rev 0x0
simplefb0 at mainbus0: 656x416
wsdisplay0 at simplefb0 mux 1
wsdisplay0: screen 0-5 added (std, vt100 emulation)
simplebus0 at mainbus0: "soc"
bcmintc0 at simplebus0
bcmdog0 at simplebus0
bcmrng0 at simplebus0
pluart0 at simplebus0
bcmtemp0 at simplebus0
bcmaux0 at simplebus0
com0 at sim����: ns16550, no workingcom0: console
dwctwo0 at simplebus0
simplebus1 at mainbus0: "clocks"
agtimer0 at mainbus0: tick rate 19200 KHz
cpu1 at mainbus0 mpidr 1: ARM Cortex-A53 r0p4
cpu2 at mainbus0 mpidr 2: ARM Cortex-A53 r0p4
cpu3 at mainbus0 mpidr 3: ARM Cortex-A53 r0p4
usb0 at dwctwo0: USB revision 2.0
uhub0 at usb0 configuration 1 interface 0 "Broadcom DWC2 root hub" rev 2.00/1.00 addr 1
uhub1 at uhub0 port 1 configuration 1 interface 0 "Standard Microsystems product 0x9514" rev 2.00/2.00 addr 2
smsc0 at uhub1 port 1 configuration 1 interface 0 "Standard Microsystems SMSC9512/14" rev 2.00/2.00 addr 3
smsc0: address xx:xx:xx:xx:xx:xx
ukphy0 at smsc0 phy 1: Generic IEEE 802.3u media interface, rev. 3: OUI 0x0001f0, model 0x000c
umass0 at uhub1 port 3 configuration 1 interface 0 "USB Flash Disk" rev 2.00/11.00 addr 4
umass0: using SCSI over Bulk-Only
scsibus0 at umass0: 2 targets, initiator 0
sd0 at scsibus0 targ 1 lun 0: <USB, Flash Disk, 1100> SCSI2 0/direct removable serial.090c1000000000014806
sd0: 30720MB, 512 bytes/sector, 62914560 sectors
vscsi0 at root
scsibus1 at vscsi0: 256 targets
softraid0 at root
scsibus2 at softraid0: 256 targets
bootfile: sd0a:/bsd
boot device: sd0
root on sd0a (01654b77d1056385.a) swap on sd0b dump on sd0b
WARNING: CHECK AND RESET THE DATE!
Automatic boot in progress: starting file system checks.
/dev/sd0a (01654b77d1056385.a): file system is clean; not checking
setting tty flags
pf enabled
starting network
smsc0: bound to 10.0.0.23 from 10.0.0.1 (xx:xx:xx:xx:xx:xx)
reordering libraries: done.
openssl: generating isakmpd/iked RSA keys... done.
ssh-keygen: generating new host keys: RSA DSA ECDSA ED25519
starting early daemons: syslogd pflogd ntpd.
starting RPC daemons:.
savecore: no core dump
checking quotas: done.
clearing /tmp
kern.securelevel: 0 -> 1
creating runtime link editor directory cache.
preserving editor files.
starting network daemons: sshd smtpd sndiod.
running rc.firsttime
Path to firmware: http://firmware.openbsd.org/firmware/6.3/
No devices found which need firmware files to be downloaded.
Checking for available binary patches... done.
Run syspatch(8) to install:
001_perl
002_libtls
003_arp
004_gif
005_httpd
006_ipseclen
007_libcrypto
008_ipsecout
009_libcrypto
011_perl
starting local daemons: cron.
Sun Mar 25 07:56:40 CEST 2018

OpenBSD/arm64 (bagheera.tumfatig.net) (console)

login: root
Password:
OpenBSD 6.3 (GENERIC.MP) #41: Sat Mar 24 20:06:13 MDT 2018

Welcome to OpenBSD: The proactively secure Unix-like operating system.

Et voilà! Not that hard.

Recommanded readings: