Controlling the fan speed of the Acer Extensa 5235

Tagged:  

Recently, I bought an Acer Extensa 5235, and I must say: regarding the price tag, it's a really good notebook. Ubuntu 10.04 is running fine and I only had to tweak a few little things (controlling the brightness is a bit of a hassle; I had to manually bind keys to call xbacklight).

One thing is pretty bad though: the fan control. While it's not that loud, the lowest rpm is still way too high and also starts very early (at 40 degrees). Unfortunately, using 'fancontrol' won't work, since the fan cannot be directly controlled through PWM. However, digging through a thread in the wonderful German Acer user forum revealed that you can control the fan by directly writing in the proper EC registers. Before we continue, a word of warning:

The following can permanently damage your notebook. Use at your own risk! I hope you know what you're doing, because I surely don't!

If you write in the wrong EC registers, you could do bad things (like activating some kind of BIOS or HD password), so you better don't mess with them. Also, the correct EC registers can be different for different BIOS versions. My Acer has the Bios version v0.3219 - if yours is different… well, you've been warned. Nothing of the following is officially documented in any way.

You can also easily completely halt the fan, without the possibility to get it running again without rebooting, so be careful and watch the temperature through lm-sensors, and reboot immediately when the notebook gets too hot.

Still with me? OK… First off, there's a kernel module called acerhdf, which was made for the Acer Aspire One, but which also worked for my notebook by using force_product="AOA150" and force_bios="v0.3301" as parameters. Using this module, you can specify at which temperatures the fan should start, but you can not control the actual fan speed. Therefore, you can just make the fan start at a higher temperature (which will eventually be reached, since even when idle you cannot cool the processor passively). If that is OK with you, just use this module.

To use a lower fan speed: Get the script acer_ec.pl, put it in /usr/local/bin, and modify your sudoers that you can use this script as normal user without password (I know, I know…). Install lm-sensors and make sure that calling 'sensors' gives you a temperature which somehow makes sense. Make sure that

sensors | sed -ne 's/temp.:[^+]*+\([0-9]\+\)\..*/\1/p' | tail -n 1

gives you exactly this temperature and nothing else.

Now you can use a script like this:

#!/bin/sh

TEMPHIGH=55
TEMPLOW=45

# First, spin up to make sure the fan is running
sudo /usr/local/bin/acer_ec.pl := 0x55 0x04 > /dev/null
sleep 3
# Manual mode
sudo /usr/local/bin/acer_ec.pl := 0x55 0x18 > /dev/null
sleep 2
# Set super-low fan speed
sudo /usr/local/bin/acer_ec.pl := 0x5e 0xb7 > /dev/null

sleep 2

# Watch the temperature
while true; do
    TEMP=$(sensors | sed -ne 's/temp.:[^+]*+\([0-9]\+\)\..*/\1/p' | tail -n 1)
    if [ $TEMP -gt $TEMPHIGH ]; then
        echo Activating BIOS fan control
        sudo /usr/local/bin/acer_ec.pl := 0x55 0x01 > /dev/null
        while [ $TEMP -gt $TEMPLOW ]; do
            TEMP=$(sensors | sed -ne 's/temp.:[^+]*+\([0-9]\+\)\..*/\1/p' | tail -n 1)
            sleep 3
        done
        echo Returning to manual fan speed
        sudo /usr/local/bin/acer_ec.pl := 0x55 0x18 > /dev/null
        sleep 2
        sudo /usr/local/bin/acer_ec.pl := 0x5e 0xb7 > /dev/null
    fi
    
    # Reset to manual fan speed, for instance after a resume
    VALUE=$(sudo /usr/local/bin/acer_ec.pl "?=" 0x55 | sed -e 's/.*== //')
    if [ ! $VALUE = "0x18" ]; then
        echo Resetting to manual speed
        sudo /usr/local/bin/acer_ec.pl := 0x55 0x18 > /dev/null
        sleep 2
        sudo /usr/local/bin/acer_ec.pl := 0x5e 0xb7 > /dev/null
    fi

    sleep 3
done

I guess it's pretty self-explanatory. Again: Be careful! The speed might be too low and the fan might halt in a way that switching to BIOS mode won't make it start again. This might also happen in a year or two, when accumulating dirt starts to make the fan less reliable. Oh, and it's a shell script in userland, so it might crash, stop, whatever... as I said: I hope you know what you're doing.