Fan speed controller with custom speed curve

Thank you @jean for this, and for pointing me in the direction of fw-ectool!

I have a small side question: on Arch, installing the fw-ectool-git package works fine, producing the ectool binary as expected. However, passing in --interface=lpc prevents things from working (as opposed to not specifying any value for --interface, or using --interface=fwk which doesn’t seem to be documented by works, added here):

$ sudo ectool --interface=lpc fanduty 0
Missing Chromium EC memory map.
Unable to establish host communication
Couldn't find EC

It’s just interesting that lpc works for you but not for me, given that we are both on a Framework laptop? Again, everything works fine for me if I avoid specifying lpc, I’m just curious why we see different behavior on the same(?) hardware. Perhaps we are using different version of ectool?

Indeed !
It still works for me when removing the interface parameter, my mistake.
I can’t remember why I came to the conclusion that this parameter was required, but it clearly isn’t :laughing:
I’ve updated the repo (along with a new feature, Strategies).
Thanks @dgquintas !

As of why does it work fine on ubuntu with --interface=lpc and not on Arch, I have no answer. Not very willing to dig but if someone knows, please let us know :nerd_face:

I made this account just to thank you for this. I was almost going to return my framework because the fans were wayy too loud and I couldn’t concentrate on my work because of them.

4 Likes

This is amazing work @jean ! Thanks for sharing. This thread should be pinned somewhere for visibility! I’d agree that the default fan curve seems overly aggressive.

My only suggestion for potential improvement would be a slow ramp up / down when a new target fan value is set. Would just be slightly nicer sound-wise. But I understand would make the code more complex when we can only set discrete values through ectool.

Do you have an idea of how frequently it’s possible to update the duty value using ectool? Could it be done multiple times per second for example? Not sure if this would have performance implications. This is interesting actually, I might have a play!

Thanks @BenVosper !

You can get a slower ramp up by increasing the MovingAverageInterval parameter in your config.
For ramp down however, the script takes the minimum temperature between average temp and current temp, so it’s an instant change in fan speed whenever the cpu load decrease suddenly.
To make the ramp down just as smooth as the ramp up, you can remove these 2 lines: fw-fanctrl/fanctrl.py at main · TamtamHero/fw-fanctrl · GitHub
and replace them with this:

currentTemp = self.getMovingAverageTemperature(self.movingAverageInterval)

If this new behavior works for you, feel free to make it configurable, PRs are welcomed :smiley:

About ectool, it’s a very lightweight program so there won’t be performance implications if you trigger it frequently, but I don’t think that the fan itself can mechanically react to more than 1 request/sec. Not 100% sure about it though, let me know if you fiddle with it and find something interesting !

I created an updated version of TamtamHeros fw-fanctrl which enables automatic switching between two custom fan curves depending on if the laptop is charging or discharging. I created a pull request for this. Until its merged into the original fw-fanctrl the updated version is available in my GitHub repository.

The current charging status of the laptop is read from the following file:
/sys/class/hwmon/hwmon2/device/status
On my Framework Laptop running Pop OS 22.04 this works. I don’t know yet if this path works for all Framework Laptops on all Linux distributions. So any feedback is appreciated.

2 Likes

I’ve just published an update which allows to change the strategy more easily: you can now type fw-fanctrl lazy or fw-fanctrl medium or any other strategy available in the config file without having to mess with the running service.

To get it, you can just pull the latest main and run the install script again.

3 Likes

Nice feature/bugfix from @emrebicer: Fans keep working after suspend · Issue #6 · TamtamHero/fw-fanctrl · GitHub
If you’re living like me in a cold/temperate country and you don’t do heavy computation, you might have not noticed it but the fan was not actually stopped by fw-fanctrl when going to sleep. Now it is :slight_smile:

Fix from @Gronkdalonka for 12th gen intel CPUs: Fix core temp reading for 12th gen by Gronkdalonka · Pull Request #10 · TamtamHero/fw-fanctrl · GitHub

I’ve extended the great work of @jean with an cinnamon applet make the switch between strategies easier.

Framework FanCTRL - Fan Strategy Control Applet for Cinnamon

This applet allows you to control the fan speed strategies of Framework laptops directly from your desktop. It uses fw-fanctrl / framework-ec to select different fan speed strategies.

Installation

Make sure fw-fanctrl is installed.

Via Cinnamon Applet Store
- Right click on the menu bar.
- Open "Applets".
- Click on "Download" tab.
- Search for "FanCTRL".
- Click on the install icon next to the applet name.

The applet should now be available in your Applets settings panel. Add it to your panel to start using it.

Via Git

Clone the git repository:

git clone https://github.com/not-a-feature/fw_fanctrl_applet

Copy the applet to your local Cinnamon applets directory:

cp -r fw_fanctrl_applet/files/* ~/.local/share/cinnamon/applets/

The applet should now be available in your Applets settings panel. Add it to your panel to start using it.

License

Copyright (C) 2023 by Jules Kreuer - @not_a_feature
This piece of software is published unter the GNU General Public License v3.0

Go to LICENSE.md to see the full version.

4 Likes

Following the release of Framework’s 16" laptop, I’ve been working on an update of fw-fanctrl to add support for AMD CPUs and also for dGPU.

I don’t have a 16/dGPU, and the person who helped me (thanks @hasecris !) has a 16 but no dGPU. It would be nice to have a dGPU owner try the update a bit before I release it. Here’s the PR with preliminary support: Add AMD/16" support by TamtamHero · Pull Request #21 · TamtamHero/fw-fanctrl · GitHub
Feedback can be given on this issue: [Feature] Support for Framework 16 · Issue #20 · TamtamHero/fw-fanctrl · GitHub

Edit: merged
Edit2: new update to fix 13" AMD

1 Like

Any application to control the fans in Windows?

It shouldn’t be that hard to make the code run on Windows using ectool, but you will need to disable secure boot to install the EC driver, which is the biggest problem. Otherwise, what would need to change in the source code is the whole running-as-a-service part and checking for temperatures (but you could also call ectool to get the temperatures).

Thanks for the reply. How do I disable secure boot?

For those who use gnome-shell, I made this simple extension to manage fw-fanctrl modes:

image

Requisites
You need to have fw-fanctrl installed.

If you want to install it directly, here is the gnome-shell extensions link:
https://extensions.gnome.org/extension/7053/fw-fanctrl/

Made a general purpose tray icon ui that should work on any DE over here,

It’s available on AUR for arch linux users

1 Like

Looks like AUR package is missing the PKGBUILD - it downloads a symlink to a non-existent file instead of an actual text file.

Ok, I think I fixed it, let me know if there’s anymore problems

1 Like

I’m grateful, because this seems to be working, but I’m having some problems with the terminal interface: ‘-q’ does nothing. ‘–list-strategies’ does nothing. ‘–run’ just causes a bunch of concerning print-outs:

Exception in thread Thread-1 (startServerSocket):
Traceback (most recent call last):
  File "/usr/lib/python3.12/threading.py", line 1073, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.12/threading.py", line 1010, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/bin/fw-fanctrl", line 118, in startServerSocket
    os.remove(COMMANDS_SOCKET_FILE_PATH)
PermissionError: [Errno 13] Permission denied: '/run/fw-fanctrl/.fw-fanctrl.commands.sock'
Error getting I/O privilege: Operation not permitted
Cannot find I2C adapter
Unable to establish host communication
Couldn't find EC

…but ‘–resume’ DOES work and causes the fan speed to change. ‘–pause’ also seems to work as intended.