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

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

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 .

https://rpi4-uefi.dev/

rpi4_uefi_1.png

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

rpi4_uefi_2.png

rpi4_uefi_3.png

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)

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

arm/Raspberry Pi (last edited 2020-06-16 09:32:22 by KlausKüchemann)