# Serial console on a Raspberry Pi with FreeBSD

Settings on every board: 115200 baud, 8 data bits, no parity, 1 stop bit, no flow control (115200 8N1). All signals are 3.3 V. A 5 V adapter can damage the board; on an adapter with a voltage jumper, set it to 3.3 V. Never connect the adapter's VCC pin.

The adapters used here are plain USB serial adapters. FreeBSD drives the common chips with `uchcom(4)` (CH340), `uftdi(4)` (FT232), `uplcom(4)` (PL2303) and `uslcom(4)` (CP210x).

## What to have

| Board | Console with boot and kernel messages | Login only, after boot |
|---|---|---|
| Pi 4 Model B | one USB serial adapter on the GPIO header | same |
| Zero 2 W | one USB serial adapter on the GPIO header | same |
| Pi 5 Model B | a cable for the 3-pin UART connector | two USB serial adapters, over USB |

## Pi 4 and Zero 2 W: the GPIO header

<ol class="steps">
<li>

Wire the adapter to the header. Transmit goes to receive:

| Adapter | Header pin |
|---|---|
| GND | 6 (GND) |
| RX | 8 (GPIO14, TXD) |
| TX | 10 (GPIO15, RXD) |

![Wiring diagram: the adapter's GND goes to header pin 6, its RX to pin 8 (TXD) and its TX to pin 10 (RXD). VCC stays free.](/images/serial-header.svg)

</li>
<li>

Nothing to set on the board. The `config.txt` of the FreeBSD image has `dtoverlay=disable-bt`, so the PL011 UART sits on pins 8 and 10, and the kernel uses it as its console: `dmesg` shows `uart0: console (115200,n,8,1)`. `/etc/ttys` starts a login on `ttyu0` because it is the console (`onifconsole`).

</li>
<li>

Open the line on the computer. On FreeBSD:

```sh
cu -l /dev/cuaU0 -s 115200
```

`~.` at the start of a line closes `cu`. On other systems any terminal program set to 115200 8N1 works. Power the board on: the loader, the kernel messages and then the login prompt appear.

</li>
</ol>

The Bluetooth radio of these boards also needs this UART. Taking it for Bluetooth means losing the console here; moving the console to the mini UART stopped a Zero 2 W at boot in 3 boots out of 3 (see [Bluetooth](/rpi/bluetooth/#where-it-is-stuck)).

## Pi 5, option 1: the 3-pin UART connector

The Pi 5 boots FreeBSD through UEFI firmware. Its GPIO header UARTs live on the RP1 chip, which FreeBSD 15.1 GENERIC does not drive, so pins 8 and 10 stay silent at boot. The [`rp1uart`](/rpi/rp1/) module attaches them once loaded, with transmit measured and receive not tested; it does not give a boot console. The console is the separate 3-pin UART connector between the two micro HDMI ports. The test board reports it as:

```text
uart0: <PrimeCell UART (PL011)> iomem 0x107d001000-0x107d0011ff irq 0 on acpi0
uart0: console (115200,n,8,1)
```

![Wiring diagram: a cable from the 3-pin UART connector between the two micro HDMI ports of the Pi 5 to a USB serial adapter, and a USB lead to the computer running cu at 115200.](/images/serial-pi5-cable.svg)

That connector takes a cable with a 3-pin JST SH plug (1.0 mm pitch), with a USB serial adapter at the other end. Check the pin order printed on the board or in its documentation before wiring loose leads. This is the only way to see the loader, kernel messages and a panic on a Pi 5. The `config.txt` there has `enable_uart=1` and `dtparam=uart0_console`.

## Pi 5, option 2: two USB serial adapters over USB

Without that cable, two USB serial adapters give a login, but only after FreeBSD has booted.

<ol class="steps">
<li>

Plug adapter A into a USB port of the Pi 5 and adapter B into the computer. Wire them to each other, transmit to receive:

| Adapter A (Pi 5) | Adapter B (computer) |
|---|---|
| TX | RX |
| RX | TX |
| GND | GND |

![Wiring diagram: adapter A in a USB port of the Pi 5, where a getty runs on cuaU0, and adapter B in the computer. TX of each goes to RX of the other, GND to GND. Login after boot only, no loader and no kernel messages.](/images/serial-pi5-usb.svg)

</li>
<li>

On the Pi 5, adapter A shows up as `cuaU0` (for a CH340: `uchcom0: CH340 detected`). Add a login on it to `/etc/ttys`:

```text
cuaU0	"/usr/libexec/getty 3wire.115200"	vt100	onifexists secure
```

`onifexists` starts the login whenever the adapter is there at boot. After plugging it in later, `kill -HUP 1` makes `init` read the file again.

</li>
<li>

Open adapter B on the computer at 115200 8N1 and press Enter for the login prompt.

</li>
</ol>

What this cannot show: the loader, kernel messages, and a hang or panic. Over the same adapter, kernel messages after boot need `conscontrol add ucom`; the loader tunable `hw.usb.ucom.cons_unit` alone [does not do it](/kernel/ucom-cons-unit-tunable/). For a board that stops during boot, option 1 is needed.

## When the line stays silent

- Swap TX and RX: the most common mistake.
- Check GND: without a common ground the characters come out as garbage or not at all.
- Wrong speed shows as garbage too; everything here is 115200.
- On the computer, `dmesg | tail` after plugging the adapter in shows its device name.
- Day-to-day access is easier over the network: `ssh` once Wi-Fi is up ([what to install](/rpi/install/)). Keep the serial line as the fallback.
