FreeBSD/ARM on the Raspberry Pi family

What is Raspberry Pi?

The original Raspberry Pi launched in early 2012 as an inexpensive ($35) PC based on a Broadcom BCM2835 SoC. It was developed by the UK-based Raspberry Pi foundation as an inexpensive system for educational use. As of April 2013, it had sold over a million units.

There are many versions of the Raspberry Pi. Where links are shown, they lead to information about models currently being sold.

Due to the bewildering number of versions, some earlier versions are not listed here.

The original "Model B" includes Ethernet, 2 USB ports and originally included 256MB RAM. First shipped in Feb 2012. Can be identified by the lack of mounting holes and "(c) 2011" on the board

After late 2012, "Model B" was updated with 512MB RAM. This version can be identified by the two mounting holes and "(c) 2011,2012" on the board.

"Model A" was released in early 2013. It lacks Ethernet, has only one USB port, 256MB RAM and is somewhat cheaper than the Model B.

The "Model B+" released in July 2014 has 4 USB ports, micro SD, lower power consumption, more GPIO pins and 512MB RAM.

The Raspberry Pi 2 released in February 2015 has 4 USB ports, micro SD slot, a new 900 MHz quad-core ARM Cortex-A7 CPU, 1GB RAM and complete compatibility with Raspberry Pi 1.

The Raspberry Pi 3 uses the BCM2837 SoC, quad-core 1.2GHz ARM Cortex-A53,1GB LPDDR2 SDRAM, 10/100 Ethernet (via USB).

The Raspberry Pi 2 v1.2 uses the same SoC as the Raspberry Pi 3 rather than the SoC from earlier Raspberry Pi 2 models.

The Raspberry Pi 3B+/Pi 3A+ use the BCM2837B0 SoC , 1.4GHz 64-bit quad-core A53 (ARMv8) processor, 1GB/512MB LPDDR2 SDRAM, Gigabit Ethernet (via USB channel, maximum throughput of 300Mb/s)/No Ethernet (A+ model).

The Raspberry Pi 4 uses the BCM2711 SoC (a re-implementation of BCM283X on 28nm), 1.5GHz quad-core 64-bit ARM Cortex-A72 (ARMv8) processor, 1, 2 or 4GB of LPDDR4 SDRAM, full-throughput Gigabit Ethernet, dual-band 802.11ac wireless, two USB 3.0 and two USB 2.0 ports, dual 4K monitor support, VideoCore VI graphics, 4Kp60 HEVC video hardware decoding, USB-C power.

The Raspberry Pi Hardware and Raspberry Pi revision codes pages have much more detailed information about models.

Raspberry Pi and FreeBSD

FreeBSD has supported the original Raspberry Pi since November, 2012 and Raspberry Pi 2 since March, 2015.

If you have questions, please ask on the freebsd-arm@ mailing list.

Xorg

How to Boot the Raspberry Pi

As of January 2013, FreeBSD-CURRENT fully supports either a video console (you'll need a USB keyboard and display connected) or it can be configured to use a serial console (you'll need a USB to TTL Serial Cable such as the one sold by Adafruit.com). OTG-capable boards, such as Zero, provide virtual serial console when connected to an USB host.

After connecting video, keyboard, and inserting the SDHC card, you connect power to actually boot.

Pre-Built Images

For Raspberry Pi Zero use the image for RPI-B. For Raspberry Pi 4 use the image for RPI3.

The default passwords for the images are freebsd/freebsd and root/root .

How to Build Your Own Images

Raspberry Pi and Raspberry Pi 2 are supported by the Crochet build tool.

Building an image for Raspberry Pi 2

Anatomy of Raspberry Pi Boot Images

Raspberry Pi 3 or Pi 4

A FreeBSD bootable image for Raspberry Pi3+Pi4 has both FAT and UFS partitions containing the following :

FAT Partition /dtb - device tree blobs /EFI - bootloader /overlays armstub8-gic.bin armstub8.bin bcm2710-rpi-3-b-plus.dtb bcm2710-rpi-3-b.dtb bcm2711-rpi-4-b.dtb bootcode.bin (first stage boot) config.txt (configuration for start.elf) config_rpi4.txt (RPI4 only) fixup_cd.dat fixup_db.dat fixup_x.dat fixup.dat fixup4.dat fixup4cd.dat fixup4db.dat fixup4x.dat LICENCE.broadcom README start_cd.elf start_db.elf start_x.elf start.elf start4.elf start4cd.elf start4db.elf start4x.elf uboot.bin (third stage: U-Boot loader https://www.freshports.org/sysutils/u-boot-rpi4/ start.elf (second stage boot) start4.elf (RPI4 only)

UFS Partition /boot/kernel (dynamic kernel) ... rest of FreeBSD ...



As of February 2020 the complete RPI4-uSD-image will be soon available with https://reviews.freebsd.org/rS357335

Raspberry Pi 2

Pi2 (bcm2708-* in Pi-armv6):

FAT Partition /dtb /EFI /overlays bcm2709-rpi-2-b.dtb bootcode.bin config.txt fixup_cd.dat fixup_db.dat fixup_x.dat fixup.dat start_cd.elf start_db.elf start_x.elf start.elf u-boot.bin ubldr.bin

UFS Partition /boot/kernel (dynamic kernel) ... rest of FreeBSD ...



DTB Overlays

These are a recent feature. Please see this README for more information.

As of February 2020 : If you encounter e.g. boot-problems from SD-card on the RPI4 try overwriting the whole overlay-folder from RPI-foundation to your SD-card`s msdos-partition .

Features

What works

RPi 1 RPi 2 RPi 3 / RPi 3B+ / RPi 2 1.2 RPi 4 RPi Zero RPi Zero W Wordsize 32 32 64 64 32 32 audio OK OK ? ? Not avail. Not avail. camera Not Tested OK ? ? ? ethernet OK OK OK https://reviews.freebsd.org/D24436 Not avail. Not avail. GPIO OK OK OK ? OK OK HDMI OK OK OK OK OK OK i2c OK OK ? ? OK (12+ needs dt config) OK (12+ needs dt config) SD card OK OK OK OK OK OK SMP Not avail. OK OK ? Not avail. Not avail. SPI OK OK ? ? OK OK USB 2.0 OK OK OK USB 3.0 OK (both device and host) OK (both device and host) watchdog OK OK ? ? ? UEFI/ACPI - - untested test stage ? WiFi Unsupported (BCM43438 Driver) brcmfmac43455-sdio (not yet tethered ) Not avail. Unsupported (BCM43438 Driver) TV Hat ? ? ? ? ? ?

GPIO

Perl, Python and Ruby wrappers for interfacing with the GPIO ioctl are available at https://github.com/gonzoua/freebsd-gpio

Camera

See FreeBSD/arm/Raspberry Pi Camera.

External Displays

Some external displays made for the Raspberry Pi require extra configuration steps to work properly. The manufacturer should have provided these as part of the documentation. The settings are often the same as on Linux-based distributions for the Raspberry Pi. After writing the bootable image to the compact flash card, mount the FAT partition contained on it as msdosfs and open the config.txt file. This can also be done from within the Pi itself, provided the display gives some form of output, otherwise another machine has to be used. The partition is mounted like this after logging in:

/dev/msdosfs/MSDOSBOOT on /boot/msdos (msdos, local, noatime)

A couple of lines are already present in /boot/msdos/config.txt . The lines from the manufacturer have to be added to the end of that file. After saving and exiting the editor, reboot the Raspberry. The updated config.txt file will be loaded and the display should work as expected.

For example, the following lines were added to config.txt to make a 5" touchscreen display from Waveshare work and use the proper resolution:

max_usb_current=1 hdmi_group=2 hdmi_mode=87 hdmi_cvt 800 480 60 6 0 0 0 hdmi_drive=1

Pi-Top

The Pi-Top is a cheap laptop built around the Rpi3

To get the touchpad working add this to your /boot/loader.conf:

usb_quirk_load=YES ums_load=YES hw.usb.quirk="0x258a 0x000c 0x0000 0xffff UQ_CFG_INDEX_1"

Device Configuration

Device Trees, overlays, and parameters

SDIO

SDIO

SDIO is implemented in r348805 and we should tether brcmfmac43455-sdio.bin / brcmfmac43455-sdio.txt to get first WIFI network for the RPI4 .

Known Issues/hints

RPi3

* Booting from a USB connected hard disk - see Bob Prohaska's notes (The hard disk is powered from a powered USB hub.) and https://www.raspberrypi.org/documentation/hardware/raspberrypi/bootmodes/msd.md.

RPI4

September 10, 2020 : for those who boot the RPI4 via u-boot(fdt): we strongly recommend to apply the following patch which prevents file corruptions on USB-transfers specially on large files : https://reviews.freebsd.org/D26344

As of June 16, 2020: the new RPI4 8GB RAM model is now bootable with FreeBSD under UEFI. Andrei Warkentin of rpi4-uefi-dev(VMWare&Arm Holding project)&colleagues gives us a new release, here for download: https://github.com/pftf/RPi4/releases/tag/v1.15 . Information about rpi4-uefi-dev below. this new uefi-release also supports the 1/2/4 GB-models. For details !!please!! visit us on Discord-channel #rpi4-uefi-dev under Server : https://discord.gg/zYydtE.. ACPI-Hacker Greg V has something available for you : D25201, D25203 and D25219 , we are in the testing-stage so these informations have to be understood on per day-basis // Pcie-Hacker Robert Crowston managed to boot with a compilation of current u-boot ' Here's his u-boot-binary for download : https://sourceforge.net/projects/rpi4-8gbram-boot-fbsdonly/files/u-boot.bin/download. If you are interested in, you can try to update to the RPI4/8GBRAM beta-firmware. Download firmware here : https://github.com/raspberrypi/rpi-eeprom/releases . Just erase uSD to FAT32 with https://www.raspberrypi.org/blog/raspberry-pi-imager-imaging-utility/ .. unzip pieprom.zip to uSD, boot it up (green screen on HDMI, success on UART and blinking green light on pcb indicates fw-upgrade-success..it`s also possible that you need to or can overwrite the rpi4-boot files with the current ones : https://github.com/raspberrypi/firmware/tree/master/boot . If you encounter problems with genet0 please overwrite bcm2711-rpi-4-b.dtb with https://sourceforge.net/projects/rpi4-8gb-uboot-bcm2711-backup/files/bcm2711-rpi-4-b.dtb/download or in other words: while you have to update/overwrite e.g. start4.elf&fixup4.dat from Github: please don't update/overwrite bcm2711-rpi-4-b.dtb ! the genet-issue is addressed in : https://reviews.freebsd.org/D25251.

EFI Firmware: Das U-Boot (rev 8224.1792) root@generic:~ # sysctl hw.physmem hw.physmem: 8422461440 root@generic:~ # ping wiki.freebsd.org PING wiki.freebsd.org (96.47.72.84): 56 data bytes 64 bytes from 96.47.72.84: icmp_seq=0 ttl=40 time=145.781 ms 64 bytes from 96.47.72.84: icmp_seq=1 ttl=40 time=114.968 ms ^C --- wiki.freebsd.org ping statistics --- 2 packets transmitted, 2 packets received, 0.0% packet loss round-trip min/avg/max/stddev = 114.968/130.374/145.781/15.407 ms

RPI4-models: 1/2/4 GB RAM :

RPI4 UEFI

Installation: (as of 16th/June/2020 ) use our stock RPI3-image, boot from u-boot , : apply patches : D25201, D25203 and D25219 and make buildkernel, clone the fbsd-root-filesystem of your new compilation to an external SSD-drive or USB-stick. then extract all the downloaded files from rpi4UEFI-dev onto an uSD-card (except overlays(merge instead) because of disable-bt.dtbo for PL011 ) , that's only the UEFI-boot - uSD. If you encounter problems with output on serial/hdmi please 1st enter the RPI4-UEFI-dev- Menu and set the console-settings from graphical to serial. select your USB-drive as the boot-device in UEFI-menu .

, regardless of successful boot or not : please send dmesg to NYC*BUG dmesgd and/or freebsd-arm@freebsd.org

https://rpi4-uefi.dev/

RPI4-UEFI, allows us to triple-boot FreeBSD on the RPi4 from either Device Tree or ACPI or ACPI&Device-tree(both).

you can get their most up-to-date information and hints of all kind if you follow them on their Discord - server : #rpi-uefi-dev

RPI4 u-boot

you want a really working RPI4(both 4&8GB-models) TODAY ? , then read on :

status June/16th/2020 :

We can boot the RPI4 over UART connected to pins 6,8 +10 https://www.raspberrypi.org/documentation/usage/gpio/,

Gigabit Ethernet is supported since :

https://reviews.freebsd.org/D24436

there's a known issue with 'ifconfig down/up' or 'service netif restart' but beside this Gigabit Ethernet will work flawlessly and initializes on boot.

If you have both RPI3+4 gadgets available (RPI4&RPI3 use the same boot-image and in many cases the same source-files in src): you can alternatively(or additionally) boot on both devices from the same SD-card image. to manage this it's currently recommended to overwrite u-boot.bin on the RPI4(both 4GB&8GB)

with the above mentioned Version from Robert Crowston because only then you can get the RPI4 fully working with all current patches(as of June 16th/2020) :

https://sourceforge.net/projects/rpi4-8gbram-boot-fbsdonly/files/u-boot.bin/download

If you want to make yourself familiar with the current patches from RPI4-fdt-main-programmers Mike Karels & Robert Crowston :

you will get a nearly fully working RPI4(both 4&8GB-models) TODAY , means : HDMI/USB keyboard/mouse/USB-HDD/Gigabit Ethernet .

root@generic:~ # usbconfig ugen0.1: <0x1106 XHCI root HUB> at usbus0, cfg=0 md=HOST spd=SUPER (5.0Gbps) pwr=SAVE (0mA) ugen0.2: <vendor 0x2109 USB2.0 Hub> at usbus0, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=SAVE (100mA) ugen0.3: <Mitsumi Electric Hub in Apple Extended USB Keyboard> at usbus0, cfg=0 md=HOST spd=FULL (12Mbps) pwr=SAVE (50mA) ugen0.5: <Mitsumi Electric Apple Extended USB Keyboard> at usbus0, cfg=0 md=HOST spd=FULL (12Mbps) pwr=ON (50mA) ugen0.6: <vendor 0x045b product 0x0209> at usbus0, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=SAVE (0mA) ugen0.7: <vendor 0x045b product 0x0209> at usbus0, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=SAVE (0mA) ugen0.8: <JMicron External Disk 3.0> at usbus0, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=ON (500mA) ugen0.9: <vendor 0x045b product 0x0210> at usbus0, cfg=0 md=HOST spd=SUPER (5.0Gbps) pwr=SAVE (0mA) ugen0.10: <vendor 0x045b product 0x0210> at usbus0, cfg=0 md=HOST spd=SUPER (5.0Gbps) pwr=SAVE (0mA) ugen0.4: <SIGMACHIP Usb Mouse> at usbus0, cfg=0 md=HOST spd=LOW (1.5Mbps) pwr=ON (100mA)

as of today(June 16th/2020)don't apply https://reviews.freebsd.org/D25121 if you want pcie with : https://reviews.freebsd.org/D25068, those patches have to be made compatible before merging.

'make -j4 buildworld buildkernel KERNCONF=xxxx` runs rock solid on the SD-card , whereas you should extend /tmp from 50 to something bigger and keep the device cooled. you can use the NO_CLEAN=yes option to save time after first compilation; the first buildworld/buildkernel lasts many hours...

3. As a workaround after possibly hangs or KPs on boot you can mount the uSD-root-filesystem again on another fbsd-machine and :

root@freebsd# mv kernel.old kernel

Although this is general information for all FreeBSD: another workaround to get back to your previous bootable kernel is e.g. :

1. interrupt the boot process when the current kernel is loading by typing any key 2. 'OK lsdev' shows your mounted disk 3. browse your filesystem with : 'OK ls' and search for kernel.old 4. 'OK unload' 5. 'OK load disk0s2:/boot/kernel/kernel.old/kernel' is a possible command to boot into your previous kernel 6. 'OK boot'

... then fix your boot-issue, make buildkernel and boot back to your prefered kernconf ... and so on ..

As fbsd-RPI4 is in daily development this section will be updated if significant changes are known.

CategoryHowTo