FreeBSD USB Boot on Raspberry Pi 4
By: Alan Thompson
Tags: USB, Freebsd, Raspberry Pi

I’ve been fascinated by the Raspberry Pi since it was first introduced in 2012. I bought my very first one that year. Because they were so inexpensive, I ended up with a few.

The default OS on Raspberry Pi has always been based on Linux, but I prefer FreeBSD. Luckily, FreeBSD has always worked very well on Raspberry Pi.

Even though it can be a fine desktop OS, FreeBSD isn’t really geared toward desktop computing. That’s fine with me because I only use the command line. I suppose it’s the challenge I like: if I actually accomplish something with the command line, I feel victorious. If I want a GUI, I’ll stick with my Mac.

Eventually, I moved on to other things and gave the Pis away. I hadn’t though about the Raspberry Pi in several years, until earlier this year when I happened across the Pi 4. The specs got me interested yet again. The Pi had come a long way! I bought one. Okay, I bought three.

Naturally, my instinct was to download FreeBSD and run it on my brand new Pi with 8GB RAM. I found out pretty quick that only a development version of FreeBSD (13-CURRENT) had support for the Pi 4. I could live with that. What I couldn’t live with is that FreeBSD wouldn’t recognize all the installed RAM on the 8GB model! I could have just enjoyed running 13-CURRENT on my 2 and 4GB models. They run perfectly fine with 13-CURRENT running from a MicroSD card. I could let the 8GB model sit there until a version was released that fully supported it.

I’m not a fan of waiting. I also wanted to run the Pis without a MicroSD card, and use USB storage instead. Why? The MicroSD cards in the Pi are prone to corruption if not treated gently, and I worry they might give out after about a year or so.

Unfortunately, as of November 2021, 13-Current doesn’t support USB boot. It just hangs. The modifications necessary to enable this can be found online, usually discussed in message boards between people much smarter than me. After a couple months of research and a lot of trial and error, I’ve successfully got FreeBSD 13-CURRENT running on the 2, 4, and 8GB Pis. I’ve decided to document the steps I took to get there.

Full Disclosure

I’m a hobbyist with moderate experience with Unix-based operating systems. This article is my best effort to record the steps I went through to achieve my goals. I am not suggesting I did it the “correct” way, that it is secure, practical, or that you should emulate anything I did. If you do decide to try it, please know you do so at your own risk.

The Goal

My goal was to reliably run FreeBSD on a Raspberry Pi 4 using only a thumb drive (no MicroSD card), with either 2, 4, or 8GB of RAM.

The Hardware

Apart from the Pi, I used this thumb drive: [https://www.amazon.com/PNY-Elite-X-128GB-Flash-Drive/dp/B01LFV52T6/ref=pd\_ybh\_a\_16?\_encoding=UTF8&psc=1&refRID=YFQKVA448FCN434ZGJQK] and [https://www.amazon.com/gp/product/B07D7SX9NS/ref=ppx\_yo\_dt\_b\_asin\_title\_o00\_s00?ie=UTF8&psc=1]. I like the small profile because it doesn’t block the other USB ports.

You will also need a MicroSD card, at least temporarily. I used SanDisk Extreme brand.

The Steps

Additional steps are required for the 8GB. Those steps can be found in the next section.

A. Update the Raspberry Pi firmware. When I bought my Pis, the installed firmware did not support USB boot. Any firmware after 2020–09–03-vl805–000138a1 does.

Download and install the Raspberry Pi Imager from [https://www.raspberrypi.org/software/] on your primary machine. Insert a MicroSD card into the computer running Imager. Launch Imager, and click “Choose OS.” Select “Misc utility images”, then “Raspberry Pi 4 EEPROM boot recovery.” Select “Choose SD Card” and select the MicroSD card. After the write and verify cycle is complete, eject the MicroSD card and place it in your Pi. Power on the Pi. After about 10 seconds, you should see the green LED blink rapidly. If you have a monitor connected, you should also see a green splash screen. This indicates success.

B. Prepare the Thumb Drive.

Insert the thumb drive into your primary machine. Download the latest version of the RPI3 snapshot (no RPI4 version is available yet). I used [https://download.freebsd.org/ftp/snapshots/arm64/aarch64/ISO-IMAGES/13.0/FreeBSD-13.0-CURRENT-arm64-aarch64-RPI3-20201105-ef87bd449eb.img.xz], but I’ve since confirmed that 20201112 works, too. Using Imager, click “Choose OS,” then “Use custom”. Select the FreeBSD image you downloaded. Under “Choose SD Card”, select your thumb drive from the list. The Imager will decompress the source file and write it to the thumb drive. Click “Write” to write and verify the image. The Imager will un-mount your thumb drive when it finishes. Remove and re-insert it, because we have to overwrite some files. Download the following files from https://github.com/raspberrypi/firmware/tree/master/boot and replace them on the MSDOS partition of the thumb drive:

— fixup4.dat

— start4.elf

— bcm2711-rpi-4-b.dtb Download u-boot.bin from the following location and replace it on the thumb drive: [https://sourceforge.net/projects/rpi4uboot202010-fbsdonly-klaus/files/u-boot.bin/download]. This is identified as U-Boot version 2020.10 release candidate 5 (special thanks to the Developer who compiled this). [Please note that FreeBSD snapshots dated 12/3/2020 or later include what appears to be U-Boot version 2020.10. However, that version does not appear to support USB boot properly. Therefore, you must continue to use version 2020.10 RC5 until that is resolved — Author]. Eject the thumb drive and insert it into the Pi. Make sure there is no MicroSD card in the Pi and plug it in. The Pi should boot using the thumb drive.

I have noticed that the first boot using USB is quite slow, but subsequent boots are faster. Additionally, a USB keyboard will not work until multi-user mode starts and the USB modules are loaded.

Additional Steps for 8GB RAM

For the 8GB model, you must perform additional tasks in Step 5. The bcm2711-rpi-4-b.dtb file must be compiled from a specific DTS file. This DTB file will also work on the 2 and 4GB models, but is not required for them.

I recommend compiling the DTB on a machine running FreeBSD, but you can compile it on any architecture because it is not an executable file. I used one of the Pis I had running FreeBSD already, because once I figured it out, that proved to be the easiest way. You can also compile it on Linux, but that is up to you. The instructions for FreeBSD are below.