Firefly Open Source Community

Title: Firefly-RK3399 fan control [Print This Page]

Author: abutkov    Time: 2/10/2019 03:31
Title: Firefly-RK3399 fan control
Last edited by abutkov In 2/10/2019 20:41 Editor

I noticed that according to schematics FAN_12V is switched with Q20 that is controlled by Q21 over BL_EN line. And the latter corresponds to GPIO1_A1. So if I export the correct gpio number I can write a simple script that reads temperature from /sys/class/thermal/thermal_zone0/temp and turns the fan on/off due to setpoint (t_high and t_low for hysteresis).
Supposing GPIO1_A1 should be 33 I do:
  1. echo 33 > /sys/class/gpio/export
  2. echo out > /sys/class/gpio/gpio33/direction
  3. echo 0 > /sys/class/gpio/gpio33/value
Copy the code
And see  the fan keeps turnung. Please correct me if I'm wrong with that idea or I just picked the wrong number for gpio.

UPD1: Seems I have to desolder 10K R702 from PWR_EN_SYS and put it on R701

Author: abutkov    Time: 2/10/2019 23:40
Last edited by abutkov In 2/10/2019 20:43 Editor

It was a kind of surgery to perform soldering, I've lost original 0402 so had to put 0805 with wire
And finally it does work:
  1. #!/bin/bash

  2. FAN_ON_TEMP="39000"    # operating temperature range in milliC
  3. FAN_OFF_TEMP="35000"   # OFF is less than ON for hysteresis

  4. if [ ! -d /sys/class/gpio/gpio33 ];
  5.     then
  6.     echo 33 > /sys/class/gpio/export;
  7.     echo out > /sys/class/gpio/gpio33/direction;
  8. fi

  9. echo 1 > /sys/class/gpio/gpio33/value;

  10. while [ 1 ]; do
  11.   read CPUTEMP < /sys/class/thermal/thermal_zone0/temp
  12.   if [ "$CPUTEMP" -gt "$FAN_ON_TEMP" ]; then echo 1 > /sys/class/gpio/gpio33/value; fi
  13.   if [ "$CPUTEMP" -lt "$FAN_OFF_TEMP" ]; then echo 0 > /sys/class/gpio/gpio33/value; fi
  14.   sleep 30
  15. done
Copy the code
You can even create  a systemd service if you wish.
Author: penguin    Time: 2/12/2019 11:07
Great work! Thanks for sharing!




Welcome Firefly Open Source Community (https://bbs.t-firefly.com/) Powered by Discuz! X3.1