first sound Pi 4, FreeBSD 15.1. The repository is not public yet.
Before these modules /dev/sndstat on a Pi 4 running arm64 FreeBSD was empty. Sound on the Pi goes through the VideoCore GPU firmware, and the kernel talks to the firmware over VCHIQ. The drivers in the FreeBSD tree assumed 32-bit pointers, so on arm64 they did not build.
What works
pcm0attaches on the Pi 4, and a test melody plays on the 3.5 mm jack with 0 underruns.- The firmware answers VCHIQ protocol version 8.
Not done yet: HDMI audio (not tried), detach and kldunload, the Zero 2 W (not tried). The Pi 5 is out of scope: it has no analogue jack and its audio path is different.
Build and load
Apply the two patches to the kernel sources:
patches/0001-vchiq-arm64.patchandpatches/0002-bcm2835_audio-arm64.patch. The second one also fixes the audio message size, which is 20 bytes on the wire.Build both modules against the source tree:
cd driver && make SYSDIR=/usr/src/sysLoad them, VCHIQ first:
kldload ./vchiq/vchiq.ko ./bcm2835_audio/bcm2835_audio.koPick the output:
sysctl dev.pcm.0.dest=1 # 0 auto, 1 headphone jack, 2 HDMI
The bug that kept it silent
The first builds loaded and played nothing. The fix was memory barriers in remote_event_signal, the function that tells the VideoCore firmware new data is waiting in shared memory. With them in place the tone and the melody came out of the jack.