Control speed of fan

The FAN_EN transistor is connected to GPIO3_A0/MAC_TXD2/SPI4_RXD_d.
It’s not a hardware PWM pin, so no hardware speed control.

Workarounds:

  1. Software PWM.
    Do it from the kernel, expose it as software pwm so a real fancontrol program can pick it up.
    Won’t be too heavy – we can lower the frequency to 50Hz or even 10Hz.
    Technically, the current fan control script is a 85.7% PWM at 0.028Hz

  2. Use the 40pin GPIO connector to loopback a real PWM pin to pull the leveler.

  3. Use the GPIO connector from the keyboard to loopback a real PWM pin. Stupidly amusing.

1 Like

I got it working.

Proof of pwm fan ramping up:

Patches uploaded here:

To test fan speed control:

#!/bin/bash
cd /sys/class/pwm/pwmchip0
echo 0 > export
cd pwm0
# 50_000_000ns, 50ms period
echo 50000000 > period
# enable it...
echo 1 > enable
# ramp it...
for i in {20000000,30000000,35000000,40000000,42000000,44000000,46000000,47000000,48000000,49000000,50000000}
do
  echo $i
  echo $i > duty_cycle
  read a
done

Yet pwmconfig doesn’t detect it :joy:
Once we figure it out we can have fancontrol taking over (maybe more advanced fan control? the last steps in the ramps are rather exponential).

PWM-enabled fan control daemon:

Weekend project done in the first night :sunglasses:
Strangely satisfying.

3 Likes

I saw that you did a lot of work adding depreciated pwm-gpio codes.
I would like to know why you didn’t use gpio_fan module?

Also as you have added fan node then why not add thermal trip in dts itself so no need for a python based daemon.

I will give some time to this approach and see if I can get fan to work on kernel level instead of user level.

Thanks for the patches I was looking for the gpio pin used for fan on off.

Some Update :

Because I want pwm_fan instead for speed control, so the first thing to do is to make the system believe there’s an extra pwm.

Nice job on gpio fan, maybe these two can be plugged together?

1 Like

Does the fan have more than 1 speed?

How it’s pwn fan different unless it have multiple speeds?

Yes it does. It’s pwm, so you can have any speed between 0rpm and 6000rpm.

To help people looking for the same problem, on my (new) A06 the script is located at /usr/local/bin/temp_fan_daemon_a06.py, the default MAX_TEMP was set to 66000 (which I guess means 66°C), but rather crucially, the systemd service is called differently - clockworkpi-a06-fan-daemon, but it has been disabled by default.

To check the status, use the command systemctl status clockworkpi-a06-fan-daemon, if it says disabled or killed, do systemctl enable clockworkpi-a06-fan-daemon & systemctl restart clockworkpi-a06-fan-daemon.

BTW you can use the command sensors to quickly check the temperatures (apt install lm-sensors).

aaand… there are two of these scripts. They seem to do approximately the same thing (at least regarding the fan), with some differences in which cores are switched on.

One is indeed at /usr/local/bin/temp_fan_daemon_a06.py, in the .deb package devterm-fan-daemon-cpi-a06. , and you control it with systemctl status devterm-fan-temp-daemon-a06. This one has MAX_TEMP=66000

The other is at /usr/share/clockworkpi-a06-fan-daemon/bin/temp_fan_daemon_a06.py, in the armbian-bsp-cli-clockworkpi-a06 package, and you control it with systemctl status clockworkpi-a06-fan-daemon. This one has MAX_TEMP=55000, with a comment saying “Replace fan-on temperature w/ 55C, rather than 70C which doesn’t seem to be enough to avoid overheating”