Skip to content

Instantly share code, notes, and snippets.

@nuumio
Created June 21, 2020 06:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nuumio/06858ccd8df515569f386a7a00a1cb0d to your computer and use it in GitHub Desktop.
Save nuumio/06858ccd8df515569f386a7a00a1cb0d to your computer and use it in GitHub Desktop.
RK3399 "direct PWM" fan control
# FILE:/etc/udev/rules.d/99-fan.rules
KERNEL=="ff420010.pwm", ACTION=="add", PROGRAM="/usr/local/sbin/fan-control.sh"
#!/bin/bash
# FILE:/usr/local/sbin/fan-control.sh
# Default PWM chip if not set (in udev rules for example)
PWMCHIP="${PWMCHIP:-pwmchip0}"
# Period of 55000 is about 18.2kHz
P=55000
# Few duty cycles that don't cause annoying resonance in my setup
#D=27000
#D=25600
D=23850
#D=22000
#D=21500
#D=20600
#D=18800
cd /sys/class/pwm/${PWMCHIP} && echo 0 > export && cd pwm0/ && echo $P > period && echo $D > duty_cycle && echo 1 > enable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment