Title: Stock fan going full tilt on idle: software solution [Print This Page] Author: vga84 Time: 7/13/2022 02:06 Title: Stock fan going full tilt on idle: software solution If you are like me and your fan on ROC-3588S-PC goes full speed when the board is idle then in this thread you are going to find a way to fix it:
I have the v0.1 revision of the board, 3 pin fan header, fan and heatsink integrated together. OS - Ubuntu Minimal. When the board is powered up the fan doesn't spin, but as soon as the OS boots up the fan starts spinning full speed. This is not really what I want - below 50C there's no need to spin the fan at all, so I started digging, and this is what I have found:
There's a systemd service responsible for fan control:
systemctl status firefly-fan.service
Copy the code
It clearly works not the way I want so I checked out the code of the service. For ROC-3588S-PC in the end it starts /usr/bin/firefly_fan_control which is a binary executable. And there's no manual for this firefly_fan_control.
I have quickly reverse engineered this thing and figured out a way to control this fan the way I want:
echo 0 > /sys/class/hwmon/hwmon1/pwm1
Copy the code
This is how the fan speed is set for v0.1 board. 0 = full tilt, 255 = stop.
cat /sys/class/thermal/thermal_zone*/temp
Copy the code
This is how the firefly_fan_control gets the temperature reading. You can take all thermal zones and average, or pick one of them, it's up to you.
Knowing all that you can get the fan curve that you like disabling firefly_fan.service and coding up your own fan control script that gets temperature and writes the desired fan speed as suggested above. I will put my script in the next post after I figure out good parameters for it.
Final thoughts:
A typical PWM fan goes full tilt when there's no PWM signal (for safety reasons I suppose). The fact that for board v0.1 the fan doesn't start spinning right after the board is powered suggests that on v0.1 the fan PWM control is not done as it's done usually. Probably in the board v1.0 with the 4 pin fan connector the fan control is implemented as it usually is and as a result we get an issue with the fan on 0.1 board, caused by software not being aware of the difference between 0.1 and 1.0 boards.
Suggestion to Firefly devs: maybe you add an if branch in firefly_fan_control for v0.1 board to fix this issue or make fan control a human readable script so that people without executable files parsing skill can play with the fan? I certainly know that a lot of people like to setup custom fan curves, they gonna love it.
However even if firefly does nothing about it people with 0.1 board can now fix this issue and everyone who wants a custom fan curve can do that. Author: vga84 Time: 7/13/2022 03:36 Last edited by vga84 In 7/13/2022 04:45 Editor
This is fan control script. Location: /usr/local/bin/fanctl
#print(f"Temp: {temperature:.2f}; Speed: {speed}, Fan Status: {fan_status}")
if temperature > TEMP_MIN:
fan_status = True
elif temperature < TEMP_OFF:
speed = FAN_LEVELS["off"]
fan_status = False
else:
speed = speed if fan_status else FAN_LEVELS["off"]
set_fan_speed(speed)
temperature_delay = temperature
#sys.stdout.flush()
time.sleep(1)
if __name__ == "__main__":
try:
main()
sys.exit(0)
except Exception as e:
print(f"ERROR: {str(e)}")
sys.exit(1) # this will show up in systemd logs as service failure
Copy the code
This is fan control unit file. Location: /etc/systemd/system/fanctl.service
[Unit]
Description=Custom fan control for ROC-3588S-PC
[Service]
Type=simple
ExecStart=/usr/bin/python3 /usr/local/bin/fanctl
[Install]
WantedBy=multi-user.target
Copy the code
After placing this files in suggested location do the following as root:
chown root:root /usr/local/bin/fanctl
chmod +x /usr/local/bin/fanctl
systemctl disable firefly-fan.service
systemctl enable fanctl.service
reboot
Copy the code
Enjoy the fan that is silent when the SOC is idle! Current script settings are:
* Fan is off when SOC is < 45C
* There is a 10C hysteresis at 45C to avoid fan on/off jitter
* Fan is full tilt when SOC is >= 75C
* Temperature is filtered with a linear filter to make fan control more smooth
You can change them as you like or introduce your own fan control system. In case you find any issues with the script please let me know here in this topic.
Welcome Firefly Open Source Community (https://bbs.t-firefly.com/)