# What to install on a Raspberry Pi with FreeBSD 15.1

## 1. The base system

After the card is written and the board boots ([Raspberry Pi basics](/rpi/#before-starting-freebsd-on-the-card); without a network, log in over the [serial console](/rpi/serial/)), as root:

```sh
passwd                      # root
passwd freebsd
sysrc ntpd_enable=YES ntpd_sync_on_start=YES
service ntpd start
```

None of the three test boards kept the right time across a power cut; with a clock in the past, `make` skips rebuilding modules that look newer than their sources.

### config.txt

The Raspberry Pi firmware reads `config.txt` from the FAT partition of the card, mounted at `/boot/msdos`. Any computer can edit it with the card in a reader, which is the way back when a change stops the boot.

Pi 4 and Zero 2 W, as the FreeBSD 15.1 image writes it (read from the test Zero 2 W):

```ini
[all]
arm_64bit=1
dtparam=audio=on,i2c_arm=on,spi=on
dtoverlay=disable-bt
device_tree_address=0x4000
kernel=u-boot.bin

[pi4]
hdmi_safe=1
armstub=armstub8-gic.bin
```

- `dtoverlay=disable-bt` puts the PL011 UART on header pins 8 and 10: that is the [serial console](/rpi/serial/). Keep it.
- `dtparam=audio=on` is needed for [sound](/rpi/audio/) on the Pi 4.
- Zero 2 W: the file must not contain `dtoverlay=mmc`. That overlay switches the Wi-Fi bus off; `install.sh` warns about it.
- Lines for a screen (`hdmi_*`) can follow in a second `[all]` block; the test Zero has its own 1024x600 mode there.

Pi 5, booted through the UEFI firmware (v0.3 on the test board; the same file is at `/boot/efi/config.txt`):

```ini
armstub=RPI_EFI.fd
device_tree_address=0x1f0000
device_tree_end=0x210000
framebuffer_depth=32
disable_overscan=1
usb_max_current_enable=1
force_turbo=1
enable_uart=1
dtparam=uart0_console
```

- `enable_uart=1` and `dtparam=uart0_console` give the console on the 3-pin UART connector.
- No line is needed for Wi-Fi or the fan.

The Pi 4's own file was not read for this page (the board was offline); it uses the same image file, so the `[pi4]` block above applies.

### Kernel sources

Drivers built on the board need the kernel sources. Only `usr/src/sys` is used:

```sh
fetch https://download.freebsd.org/releases/arm64/aarch64/15.1-RELEASE/src.txz
tar -C / -xf src.txz usr/src/sys
```

On a Pi 4 build with one job (`make`, not `make -j4`): a sagging power supply once killed the compiler there with "illegal instruction".

## 2. Which driver goes on which board

| Driver | Pi 5 | Pi 4 | Zero 2 W | Repository | Page |
|---|---|---|---|---|---|
| `cywfm` Wi-Fi | yes | yes | yes | [freebsd-rpi-wifi](https://github.com/spagu/freebsd-rpi-wifi) | [Wi-Fi](/rpi/wifi/) |
| `rp1fan` fan | yes | n/a | n/a | [freebsd-rpi-fan](https://github.com/spagu/freebsd-rpi-fan) | [Fan](/rpi/fan/) |
| `vchiq`, `bcm2835_audio` sound | n/a | yes | not tried | [freebsd-rpi-audio](https://github.com/spagu/freebsd-rpi-audio) | [Sound](/rpi/audio/) |
| `ng_h4` and tools, Bluetooth | blocked | built, power line only | simulator only | [freebsd-rpi-bt](https://github.com/spagu/freebsd-rpi-bt) | [Bluetooth](/rpi/bluetooth/) |
| `rpitemp` | works | built | works | [freebsd-rpi-soc](https://github.com/spagu/freebsd-rpi-soc) | [SoC](/rpi/soc/) |
| `rpifreq`, `rpiwdog`, `rpirng` | works | n/a | n/a | [freebsd-rpi-soc](https://github.com/spagu/freebsd-rpi-soc) | [SoC](/rpi/soc/) |
| `rpipower` | n/a | built | works | [freebsd-rpi-soc](https://github.com/spagu/freebsd-rpi-soc) | [SoC](/rpi/soc/) |
| `rp1` and its children | GPIO, Ethernet, PWM1 work; UART, I2C, SPI transmit only | n/a | n/a | [freebsd-rpi-rp1](https://github.com/spagu/freebsd-rpi-rp1) | [RP1](/rpi/rp1/) |

For daily use on a board today: Wi-Fi everywhere, plus the fan on a Pi 5. The rest is for testing and reports.

## 3. The commands, driver by driver

Wi-Fi (`cywfm`), from a checkout of [spagu/freebsd-rpi-wifi](https://github.com/spagu/freebsd-rpi-wifi):

```sh
make install-firmware        # Zero 2 W: tools/fetch-firmware.sh -i -c 43436s
                             # Pi 5:     tools/fetch-firmware.sh -i -b raspberrypi,5-model-b
make module
make install                 # /boot/modules, kldxref, man page
sysrc kld_list+=cywfm wlans_cywfm0=wlan0 create_args_wlan0="country XX" ifconfig_wlan0="WPA DHCP"
```

Fan (`rp1fan`, Pi 5), from [spagu/freebsd-rpi-fan](https://github.com/spagu/freebsd-rpi-fan):

```sh
make module
install -m 555 driver/rp1fan.ko /boot/modules/
sysrc kld_list+=rp1fan
kldload rp1fan
```

Sound (Pi 4), from [spagu/freebsd-rpi-audio](https://github.com/spagu/freebsd-rpi-audio), with `/usr/src/sys` installed (`make` applies patches 0001 to 0004 to a copy and leaves `SYSDIR` unchanged):

```sh
make all SYSDIR=/usr/src/sys
kldload ./driver/vchiq/vchiq.ko ./driver/bcm2835_audio/bcm2835_audio.ko
sysctl dev.pcm.0.dest=1      # headphone jack
```

Bluetooth (Zero 2 W first), from [spagu/freebsd-rpi-bt](https://github.com/spagu/freebsd-rpi-bt), with the radio's UART freed from the console:

```sh
make module tools
make install
sysrc rpibt_enable=YES
service rpibt start
```

SoC modules, from [spagu/freebsd-rpi-soc](https://github.com/spagu/freebsd-rpi-soc):

```sh
make modules
kldload ./driver/rpitemp/rpitemp.ko && sysctl hw.rpitemp
```

The RP1 drivers (Pi 5), from [spagu/freebsd-rpi-rp1](https://github.com/spagu/freebsd-rpi-rp1): `make modules`, `make install`, `make load`; their [page](/rpi/rp1/) lists what runs on the board and what does not.

## 4. The public part in one script

<span class="badge badge-ok">works</span> Run on 3 December 2026 on a Pi 4 Model B, a Pi 5 Model B and a Zero 2 W, all on FreeBSD 15.1-RELEASE-p7. Each run installed into a separate directory (`DESTDIR`), not into the live system, and the module installed matched the one already running on those boards byte for byte. The Pi 400 path (a build from source) has run only in the test suite.

### What the script installs

| Board | Wi-Fi (`cywfm`) | Fan (`rp1fan`) |
|---|---|---|
| Pi 4 Model B | prebuilt module and firmware | n/a |
| Pi 5 Model B | prebuilt module and firmware | built on the board |
| Zero 2 W | prebuilt module and firmware | n/a |
| Pi 400 | built on the board | n/a |

Sound, Bluetooth, the SoC modules and the RP1 drivers are not in it. Their pages list the build steps from each repository.

Requirements: FreeBSD 15.1 or newer on arm64, root, and a network connection (Ethernet or a serial console session with a cable plugged in). A build on the board also needs the kernel sources in `/usr/src/sys`; the prebuilt Wi-Fi path does not. Older FreeBSD versions are refused.

### Run it

<ol class="steps">
<li>

Download the script and read it. It is plain `sh`, about 200 lines:

```sh
fetch https://freebsd.tradik.com/install.sh
less install.sh
```

</li>
<li>

See what it would do without changing anything:

```sh
sh install.sh -n
```

</li>
<li>

Install, as root. With `-e` the modules are also added to `kld_list` in `/etc/rc.conf`, so they load at every boot:

```sh
sh install.sh -e
```

</li>
<li>

Load them and set up the network. The script prints the `rc.conf` lines at the end; the [Wi-Fi page](/rpi/wifi/#option-b-install-on-a-running-board) explains each one. Keep `/etc/wpa_supplicant.conf` at mode 0600.

```sh
kldload cywfm
```

</li>
</ol>

Options: `-n` dry run, `-e` load at boot, `-b` build Wi-Fi from source even when a prebuilt module exists, `-d dir` working directory (default `/var/tmp/freebsd-tradik-install`).

### What it does, step by step

1. Checks for FreeBSD 15.1 or newer, arm64 and root.
2. Reads the board model: from the device tree on the Pi 4, Pi 400 and Zero 2 W, from SMBIOS on the Pi 5 (which boots through UEFI firmware). Any other board stops the script.
3. Wi-Fi: looks up the newest release of [spagu/freebsd-rpi-wifi](https://github.com/spagu/freebsd-rpi-wifi/releases) built for the running FreeBSD version, downloads it, and checks the archive against `SHA256SUMS` and every file inside against its own list. On a Pi 5 the same firmware files are also installed under the Pi 5 names. Without a matching release, it downloads the source, builds `cywfm.ko` and fetches the firmware with the repository's `tools/fetch-firmware.sh`, which checks each file's SHA-256.
4. Fan (Pi 5 only): downloads [spagu/freebsd-rpi-fan](https://github.com/spagu/freebsd-rpi-fan) and builds `rp1fan.ko`.
5. Installs the modules into `/boot/modules` and the firmware into `/boot/firmware`, then runs `kldxref`. A module that is already there is kept as `<name>.ko.bak`.
6. On a Zero 2 W, warns when `config.txt` still has `dtoverlay=mmc`, which switches the Wi-Fi bus off.

It does not touch `wpa_supplicant.conf`, passwords or network settings, and it loads nothing.

### Undo

```sh
sysrc kld_list-="cywfm rp1fan"
rm /boot/modules/cywfm.ko /boot/modules/rp1fan.ko
kldxref /boot/modules
```

To go back to a previous module instead, rename `<name>.ko.bak` to `<name>.ko`. The firmware files in `/boot/firmware` are harmless when no driver uses them.

### When it stops

| Message | Meaning |
|---|---|
| `needs FreeBSD 15.1 or newer` | Upgrade first; older releases are not supported. |
| `board '...' is not supported` | The board is none of the four above. A [board report](/rpi/wifi/#report-a-board) helps add it. |
| `checksum mismatch` | A download does not match its published SHA-256. Nothing was installed. Run it again; if it repeats, report it. |
| `needs the kernel sources in /usr/src/sys` | A build is needed. Extract `src.txz` of the running release, or at least its `usr/src/sys`. |
| `build failed` | The last 20 lines of the build log are printed; the whole log is in the working directory. |
