Got a Noctua NF-A4x10 5V PWM hooked up to the 3.3v pin (pin 1), ground (pin 6), and the PWM signal line to GPIO 18 (pin 12) on a Raspberry Pi 4.
Added dtoverlay=pwm,pin=18,func=2
(pwm/pwm-2chan docs) in my /boot/config.txt
& rebooted to route hardware PWM channel 0 to GPIO 18 & enable the Linux kernel PWM driver sysfs interface.
At that point /sys/class/pwm/pwmchip0
existed and I 'exported' PWM channel 0 via:
# echo 0 > /sys/class/pwm/pwmchip0/export
...which created /sys/class/pwm/pwmchip0/pwm0/
:
$ ls /sys/class/pwm/pwmchip0/pwm0/
capture duty_cycle enable period polarity power uevent
Looking at Noctua's PWM specsheet they want a 25 kHz PWM signal, which translates into (1 / 25000) seconds = 40000 nanoseconds.
Dropped that value (40000 ns) into period
, 50% (20000 ns) into duty_cycle
, and 1 into enable
:
# echo 40000 > /sys/class/pwm/pwmchip0/pwm0/period
# echo 20000 > /sys/class/pwm/pwmchip0/pwm0/duty_cycle
# echo 1 > /sys/class/pwm/pwmchip0/pwm0/enable
...and got a (much) quieter fan!
Despite being a 5v fan the NF-A4x10 seems perfectly happy (albeit slower) with both 3.3v power and 3.3v PWM signaling.
Those values can be set at startup via a tmpfiles.d
file (I called mine /etc/tmpfiles.d/pwmfan.conf
):
w /sys/class/pwm/pwmchip0/export - - - - 0
w /sys/class/pwm/pwmchip0/pwm0/period - - - - 40000
w /sys/class/pwm/pwmchip0/pwm0/duty_cycle - - - - 25000
w /sys/class/pwm/pwmchip0/pwm0/enable - - - - 1
And finally you can tweak the EEPROM config (sudo -E rpi-eeprom-config --edit
) to power off the PWM outputs at shutdown so the fan isn't left spinning:
WAKE_ON_GPIO=0
POWER_OFF_ON_HALT=1