Running NetBSD -current on the Raspberry Pi 4 with 8GB of memory

Tags: netbsd, rpi4, arm, unix

A number of open source operating systems support the Raspberry Pi 4. For those preferring a Unix rather than a Linux there are several BSDs which you can choose from: OpenBSD1, NetBSD or FreeBSD2. I decided I’d like to use NetBSD for this project. At the time of writing the latest stable release of NetBSD (9.1) does not appear to support the Raspberry Pi 43. The experimental development branch of NetBSD (-current) does support the Raspberry Pi 4 albeit that there are some additional steps to get a working system compared with a standard install of the NetBSD arm64 port using a stable release of NetBSD. At least at the moment (as far as I am aware) the use of additional open source UEFI firmware is needed. There are several reports on the NetBSD ARM Port Mailing List confirming4 that -current can be used successfully on the Raspberry Pi 4. I tried a number of approaches based on intuition, adapting the standard install instructions and reading mailing list posts with varying degrees of success. I reached the point where I was able to successfully boot NetBSD -current but was unable to automatically boot from a USB drive without having to manually set USB as the preferred boot device on each boot over a serial cable. I then found some excellent instructions written in July 2020 by Michael Cheponis5. An advantage of the approach he summarises is that there is no need to boot from or even have available an SD card once the system has been installed. This suited me well as I intend to boot my Pi directly from a 2.5” NAND SSD plugged into one of the USB ports using a SATA to USB 3.0 adapter. This approach has the further advantage that if I wanted to run another OS temporarily (say Raspberry Pi OS to update the EEPROM) I could boot from a micro SD without messing with my installed NetBSD system on the SATA-connected SSD.

Establishing a serial connection between the device and laptop

I don’t have a conveniently accessible HDMI-capable monitor or TV at the moment. On this basis I will be installing the operating system on the Pi using a serial connection to my laptop.

I used a simple USB to UART serial console cable6. No instructions seemed to be provided with the cable but a quick websearch confirmed the following with respect to the colour of the cables and the relevant GPIO pins: Green: Tx White : Rx Black: GND. By consulting a pinout diagram 7 I established that I needed to plug the black, white and green wires into the 3rd, 4th and 5th GPIO pins of the (second) back row of pins, counting from the left (when the device is orientated landscape with the GPIO pins furthest away). I understand that the red wire can be used to power the RPi but I decided to use the mains power adapter that I had bought with the Raspberry Pi 4.

My laptop current runs OpenBSD which includes the cu serial terminal emulator program8. The USB to UART cable showed up on OpenBSD as ucom0 at uplcom0.

doas cu -l cuaU0 -s 115200

On NetBSD the relevant device is /dev/ttyU0. Should users of other operating systems not have cu available they probably will have a variety of alternative serial communication programs at their disposal such as minicom. In the cu example here:

  • doas is the OpenBSD minimalist substitute for sudo to temporarily execute commands as the root user,
  • the -l flag specifies the ‘line’ to use which depends on the terminal device that you are using, and
  • the -s flag specifies the speed of the connection which for the Raspberry Pi 4 should be set at 115200.

Update the Raspberry Pi 4 firmware (EEPROM)

The Raspberry Pi 4 has firmware stored in hardware flash memory9 (EEPROM). The EEPROM version which shipped with my device needed updating to support booting from USB. There are several ways of doing this but the approach suggested in the mailing list post by Michael Cheponis was to download the latest Raspberry Pi OS10, dd this over to a micro SD card consistent with the standard install instructions and then boot the Pi with the serial cable connected. Once logged in (as I recall the default user is pi and the password is raspberry), issue the relevant commands to update the packages database and update (if necessary) the software used to install updated EEPROM firmware:

sudo apt update 
sudo apt full-upgrade 
sudo reboot 
sudo rpi-eeprom-update 
sudo rpi-eeprom-update -a  # if an update is available 
sudo shutdown

I did this and initially was unable to boot the Pi. It turns out that the latest firmware Raspberry Pi OS made available was from April 2020 and is not recent enough11 to boot from USB. At the time of writing it is necessary to change to the “latest” update channel for the EEPROM firmware (formerly known as “stable”) to update to an EEPROM firmware version that will boot without the SD card being present12.

To do this I edited /etc/default/rpi-eeprom-update and changed FIRMWARE_RELEASE_STATUS="default" to FIRMWARE_RELEASE_STATUS="latest" then re-ran the EEPROM update software: sudo rpi-eeprom-update -a -d. I ran this with the -d flag as recommended here 13.

Preparing the boot media

  1. In a web browser download the zipped NetBSD -current image for the evbarm-aarch64 architecture14 after checking which of the recent builds of -current (also known as HEAD) built successfully15 to pick a good one (remember these are moving-target development snapshots and not stable releases). It is the arm64.img.gz file that is needed available in the relevant subfolder for the evbarm-aarch64 architecture such as https://nycdn.netbsd.org/pub/NetBSD-daily/HEAD/<SNAPSHOT_DATE>/evbarm-aarch64/binary/gzimg/.

  2. Open a terminal, change directory (cd) to the location of the download and unzip or gz -d to get an arm64.img.

  3. Plug the USB drive (or SATA drive with USB 3.0 adapter) into a USB port on your machine. Use dmesg or other appropriate tool depending on your operating system to find the correct device to burn the disk image to (in my case /dev/sd2). ONLY PROCEED IF YOU ARE ABSOLUTELY SURE YOU UNDERSTAND THIS – otherwise you risk wiping you running system.

  4. Copy over the disk image onto the USB drive using a tool such as dd. You need to copy it over to the raw block device using a command such as dd if=arm64.img of=/dev/rsd2c bs=1m. Obviously, change the of= line to suit your situation. The disk image has an FFS partition and an MS-DOS partition, both of which are needed to boot successfully.

  5. Mount the MS-DOS partition e.g. doas mount /dev/rsd2i ~/USB

  6. Download the latest experimental Raspberry Pi 4 UEFI Firmware Image16 from Github. At the time of writing the latest version was 1.22 e.g. https://github.com/pftf/RPi4/releases/download/v1.22/RPi4_UEFI_Firmware_v1.22.zip

  7. Unzip these files into a directory and cd to that directory.

  8. Copy over the files to the mounted MS-DOS partitiion e.g. cp -Rp * ~/USB

  9. umount the MS-DOS partition and plug the USB into your RPi4.

Getting the UEFI firmware to recognise more than 3GB of memory and booting NetBSD

  1. Open up and configure your serial terminal emulator. Turn on the power and your Raspberry Pi should start booting and you should start to see text scrolling up in the serial terminal.

  2. When given the option press ESC to enter the UEFI configuration screens. Under the ‘Advanced Configuration’ screens for the Raspberry Pi menu item find the “Limit RAM to 3 GB” option and disable it17. Reboot.

  3. NetBSD should boot up and re-size the root partition to occupy your whole USB disk.

  4. Login as root (there is no password). Type passwd to set a root password and useradd -m -G wheel <user> to set up a non-privledged user as a member of the wheel group18.

  5. You should now have a working NetBSD system. Type man afterboot to start getting to know the system. At this point you should also find out your local IP address on your network. You could use ifconfig on the running system or assuming IP addresses on your local network are assigned using DHCP you can probably use your router web user interface to find out. At this point you may want to configure the Pi with a static IP address or assign a fixed IP address to the MAC address of the network adaptor on the Pi using your router web interface or similar.

  6. Once you know the IP address of the Pi on the network, shut the Pi down using shutdown -p now, remove the serial cable from the Pi, reboot, and you should be able to SSH into the Pi as the unprivileged user you just set up.


  1. https://www.openbsd.org/arm64.html↩︎

  2. https://lambdaland.org/posts/2020-12-23_freebsd_rpi4/↩︎

  3. https://wiki.netbsd.org/ports/evbarm/raspberry_pi/↩︎

  4. https://mail-index.netbsd.org/port-arm/2020/06/09/msg006740.html↩︎

  5. https://mail-index.netbsd.org/port-arm/2020/07/27/msg006904.html↩︎

  6. https://shop.pimoroni.com/products/usb-to-uart-serial-console-cable#show-reviews↩︎

  7. https://projects-raspberry.com/raspberry-pi-4-pinout/↩︎

  8. https://lambdaland.org/posts/2020-12-23_freebsd_rpi4/↩︎

  9. https://www.raspberrypi.org/documentation/hardware/raspberrypi/booteeprom.md↩︎

  10. https://www.raspberrypi.org/software/a↩︎

  11. https://mail-index.netbsd.org/port-arm/2020/07/28/msg006907.html↩︎

  12. https://www.raspberrypi.org/documentation/hardware/raspberrypi/booteeprom.md)↩︎

  13. See 9.↩︎

  14. https://nycdn.netbsd.org/pub/NetBSD-daily/HEAD/↩︎

  15. https://releng.netbsd.org/cgi-bin/builds.cgi↩︎

  16. https://github.com/pftf/RPi4↩︎

  17. See 4.↩︎

  18. https://en.wikipedia.org/wiki/Wheel_(computing)↩︎