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 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

Version

ARCH

Releases

Snapshots

RPI-B

armv6 (all)

11+, 12+

11-STABLE, 12-STABLE, 13-CURRENT

RPI2

armv6 (11) or armv7 (12+)

11+, 12+

11-STABLE, 12-STABLE, 13-CURRENT

RPI3

aarch64 (all)

12+

12-STABLE, 13-CURRENT

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 :

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

Raspberry Pi 2

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

?

OK (both device and host)

OK (both device and host)

watchdog

OK

OK

?

?

?

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

As of June 06, 2020: the new RPI4 8GB RAM model is currently definitely not bootable with FreeBSD under UEFI. Not even with updated files / patches / firmwares of any kind. This is due to a change in the hardware. Robert Crowston managed to boot with current u-boot with limitations : https://marc.info/?l=freebsd-arm&m=159146889006384&w=2

RPI4 UEFI

status 30th/March/2020 :

with permission of @jmcneill (NetBSD) & @AndreiWarkentin of

https://rpi4-uefi.dev/

I want to report what cool things they develop and discuss there :

rpi4_uefi_1.png

So, for us at first the good news: RPI4-UEFI, which allows us to dual-boot the RPi4 from either Device Tree or ACPI (! USB-support! ) is able to boot FreeBSD although they never wrote one line of code in fbsd-src .. how cool is that .. while at the moment the "bad" news is : there's a little work to do for us to reach the root-login ...

rpi4_uefi_2.png

rpi4_uefi_3.png

panic when booting in ACPI-mode :

xhci0: <Generic USB 3.0 controller> iomem 0x600000000-0x600000fff irq 0 on acpi0
panic: Misaligned access from kernel space!
cpuid = 0
time = 1
KDB: stack backtrace: .....

.. assuming here :

https://svnweb.freebsd.org/base/head/sys/dev/usb/controller/generic_xhci.c?revision=347343&view=markup#l113

boot freeze in Device Tree mode :

.....
gpioled0: <GPIO LEDs> on ofwbus0
gpioled0: <led1> failed to map pin
gpioregulator0: <GPIO controlled regulator> on ofwbus0
gpioregulator0: cannot get pin 0
gpioregulator0: cannot parse parameters
device_attach: gpioregulator0 attach returned 6 .....

.. assuming here :

https://svnweb.freebsd.org/base/head/sys/dev/gpio/gpioregulator.c?revision=355358&view=markup#l255

well, let's quickly change from bad to very good news for us :

@jmcneill `s Genet-driver is merged (while afaik as of version 1.7 not yet merged in RPI4-UEFI-release, but they work very fast) :

https://github.com/pftf/edk2-platforms/commit/70b85db9ddb1be293de04576d3dd293370c7c8eb

they work on uefi-netboot (afaik ready) ...

and last but not least just my two cents of an assessment at first glance :

https://rpi4-uefi.dev/ is the most advanced place for all RPI4-BSD's where we should take a look at or step into.

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

status May/2020 :

download pre-built u-boot binary 2020.04 (from sysutils/u-boot) for RPI4:

https://sourceforge.net/projects/rpi4u-boot-2020-04-fbsdonly/files/u-boot.bin/download

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

while HDMI-output is supported we currently don't have access to USB yet..

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 you just have to overwrite u-boot.bin with the appropriate one from sysutils :

1. https://www.freshports.org/search.php?query=u-boot-rpi4&search=go&num=10&stype=name&method=match&deleted=excludedeleted&start=1&casesensitivity=caseinsensitive. -> RPI4

2. https://www.freshports.org/search.php?query=u-boot-rpi3&search=go&num=10&stype=name&method=match&deleted=excludedeleted&start=1&casesensitivity=caseinsensitive -> RPI3

'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

arm/Raspberry Pi (last edited 2020-06-06 18:50:56 by KlausKüchemann)