Raspberry Pi / fan

Pi 5 fan control: the rp1fan driver

Under FreeBSD the official Pi 5 fan does not spin until the board reaches 85 °C. rp1fan reads the SoC temperature once a second and sets the fan speed from it.

A grey three-bladed fan turning slowly, a raspberry imp beside it and a bubble reading level 2: 5995 rpm.

works Version 0.1.0, Pi 5 Model B only. Tested on FreeBSD 15.0-RELEASE; on 15.1-RELEASE-p7 it builds, attaches at boot and the sysctls read correctly. Source: spagu/freebsd-rpi-fan.

This driver started on 29 November 2026, the day the Pi 5 on the desk got too hot while its fan sat still. The bootloader only switches the fan on above 85 °C, and nothing in FreeBSD switches it on after that.

How it works

The fan connector is driven by channel 3 of the RP1 chip's PWM1 block on GPIO45 (with inverted polarity), and its tachometer is on GPIO29. Once a second the driver reads the SoC temperature from the AVS monitor and picks a speed. It needs no device tree, so it works on UEFI/ACPI boot. It only attaches when the SMBIOS product name is Raspberry Pi 5 Model B and the RP1 chip ID reads 0x20001927.

If the sensor reading is invalid, or the module is unloaded, the fan runs at full speed. Failing loud beats failing hot.

Install

  1. Build and install:

    make module                                    # builds driver/rp1fan.ko
    sudo install -m 555 driver/rp1fan.ko /boot/modules/
    
  2. Load it now and at every boot:

    sudo sysrc kld_list+=rp1fan
    sudo kldload rp1fan
    
  3. Check dmesg. The expected line:

    rp1fan: RP1 at 0x1f00000000, 48.5 C, level 0, speed 0
    

The Makefile also has make load, make status and make unload.

Fan curve

SoC temperatureLevelSpeed (0 to 255)Measured
below 50 °C00 (off)
from 50 °C1753574 rpm
from 60 °C21255995 rpm
from 67.5 °C3175
from 75 °C42509649 rpm at 255

Hysteresis is 5 °C, so the fan does not hunt between two levels.

Sysctls

Read-only, under hw.rp1fan: temp (milli-degrees C), state, speed, rpm, sensor_ok, invalid_reads.

Writable:

SysctlDefaultMeaning
trip0 to trip350000 / 60000 / 67500 / 75000Temperature thresholds in milli-degrees
speed0 to speed375 / 125 / 175 / 250PWM speed for each level
hyst5000Hysteresis
manual-1-1 follows the temperature, 0 to 255 fixes the speed

For a fan that never stops: sysctl hw.rp1fan.trip0=0. Settings meant to persist go in /etc/sysctl.conf. Before loading, kenv can set hw.rp1fan.rp1_base (default 0x1f00000000) and hw.rp1fan.force.

Built with ssg