an enhanced version of simple macbook pro fan daemon for linux
2012-06-09
I wanted to refresh my C knowledge. At the same time, I was complaining about how much macfanctld aggressively turns the fans of my Macbook Pro under Ubuntu 12.04. Sometimes I am afraid it is going to lift-off.
I took the occasion to give a small contribution to a small opensource project, written in C. Allan McRae’s mbpfan uses a very interesting approach to control the fans, based on the reported temperature. Read his post for more details.
Unfortunately, his program is highly tied to his machine (a Macbook Pro 5,5 13″ with a Core i7). There are many issues when creating a fan daemon for Linux and Apple computers:
-
The location of the sensors is different for different Macbook/Macbook Pro models
- On Allan’s machine, they are located at
/sys/devices/platform/coretemp.0/temp{2,3}_input
- On my Macbook Pro 6,2 15”, they are located at
/sys/devices/platform/coretemp.0/temp{2,4}_input
-
The new Linux Kernel v3.x changed the location of the temperature sensors.
-
mbpfan assumes two processors and a single fan (not true for all MacBook Pros, as Allan wrote). My machine has got two CPU related sensors and two fans.
-
On recent Linux kernels (probably only the v3.x series), a manual control of the fan must be taken.
I wanted to overcome these issues. Rvega’s Fan-Control-Daemon is an enhanced version of mbpfan. I did not have time to see which were the enhancements. Rvega is welcomed to comment here to fill this lack. I forked his project and began to look at these issues.
The approach that my version of Fan-Control-Daemon uses is different. First, the program tries to look at the available sensors located in
/sys/devices/platform/coretemp.0/
. Then, it looks for the available fans in
/sys/devices/platform/applesmc.768/
. The program associates each fan to the sensors. After this, it takes manual control of the fans. From this point the program has the same behavior (and code) of mbpfan, because I like it. I changed the polling frequency to 5 seconds because I find it more suitable for my needs.
I tested Fan-Control-Daemon on my Macbook Pro 6,2 15” with a Core i7. I would like to see it tested on every other possible model, as well. It should work on any GNU/Linux distribution out there, but it was tested with a 3.2.x kernel.
You can clone/download Fan-Control-Daemon/mbpfan on GitHub: https://github.com/dgraziotin/Fan-Control-Daemon. You can download “stable” releases as gzipped tars on the Tag page: https://github.com/dgraziotin/Fan-Control-Daemon/tags You can report issues either as comments here or on the issue tracker.
I am not responsible for any burned Macbook out there.
I would like to warn you that this project was implemented as a C refresh. Memory leaks could be everywhere, as well as bugs. This program is certainly not more evolved than macfanctld, because it only looks for CPU-related sensors. Nevertheless, I am using it everyday and I find its fan control algorithm more quiet but still powerful.
I will probably update it. What is going to be next is:
-
Check for root permissions
-
Check for the required modules applesmc and coretemp
-
Implement debugging messages as an option
-
Create an init.d file for loading it at boot time
-
Implement the make install command
-
Create an Ubuntu deb
At this moment, I did not package the program for any distribution. You have to manually compile it and manually run it. Check the README.md file for more information.
I kept Allan’s PKGBUILD and mbpfan.rc files, but I did not modify them. Somebody using Archlinux should check if they still work fine.
I hope that someone else finds this program useful.
I do not use a commenting system anymore, but I would be glad to read your feedback. Feel free to contact me.