Howto ACPI



Author : Sylvestre Ledru (questions, comments, do not hesitate ...)
Version francaise
Return to the linux page
If you like this howto and you want to thank me for my work : here is my wishlist on Amazon - France or my Amazon US wishlist :)
If you are a corporation and you make some business thanks to my howto, we'll love to have a present from you (or just tell me who is using my howto).

New (25/08/2003), Kernel :
Since the new kernel (2.4.22), this ACPI patch is by default included in it.
New (08/11/2003), suspend / hibernate :
I finaly successed to install and configure the suspend mode !

What is ACPI ?
ACPI is a quite old technology but it is pretty badly supported by the officiel Kernel. ACPI is developped by a consortium of few corporation like Intel, compaq, IBM ... The aim of the technology is to provide a remplacement for APM.
It is very usefull on laptops (power management, temperature ...).
Unfortunately, specifications are not very well followed by constructors, so, developments are quite difficult.

How install ACPI ?

First, visit the opensource website (http://acpi.sourceforge.net) and download the appropriate version for your kernel.
For example, I have a 2.4.20 kernel. So, I will download this file : acpi-20021212-2.4.20.diff.gz which provides an update for the official kernel (ACPI in the official kernel used to suck).

I suppose that you have the sources of the kernel in the /usr/src/linux directory.
We have to patch the kernel (don't worry, it is very easy) :
# cd /usr/src/linux
# wget http://url/acpi-20021212-2.4.20.diff.gz
# gunzip acpi-20021212-2.4.20.diff.gz
# patch -p1 < acpi-20021212-2.4.20.diff
it will patch the kernel.

A new option in the kernel menu will appear in 'General Setup' :
'ACPI support'.
In the menu, you can add these options :
AC Adapter, Battery, Button, Fan, Processor, Thermal Zone.
But sometime, the BIOS doesn't support these options.
Select what you need (as module or as static), recompile your kernel, install it and reboot.

Now, your kernel supports ACPI, but you need to install a program in order to 'manage' ACPI.
Under Debian, apt-get install acpid should be enought.

You should have some files in the /proc/acpi directory like /proc/acpi/info.
If you don't have the file, there is an error (so, check if you made any mistakes). Otherwise, ACPI should work fine on your computer.
For example, cat /proc/acpi/battery/BAT1/state gives me (when my laptop is plugged) (here, it is BAT1 but sometimes it is BAT0) :
present: yes
capacity state: ok
charging state: unknown
present rate: 0 mA
remaining capacity: 4192 mAh
present voltage: 16736 mV

It is also possible to get more informations like in /proc/acpi/battery/BAT1/info :
present: yes
design capacity: 4400 mAh
last full capacity: 4192 mAh
battery technology: rechargeable
design voltage: 14800 mV
design capacity warning: 300 mAh
design capacity low: 200 mAh
capacity granularity 1: 32 mAh
capacity granularity 2: 32 mAh
model number: 00 00 00 00
serial number: 30 00 00 00 00 00 00 00 00
battery type: 00 00 00 00
OEM info: 00 00 00 00

If you want a more friendly user interface than cat or less, you can install acpi (apt-get install acpi) which is a client.
For example, at the moment, on my laptop, acpi provides theses informations :

[11:39:58][sly@reloaded] /proc/acpi$ acpi -V
Battery 1: discharging, 82%, 01:56:53 remaining
Thermal 1: ok, 43.0 degrees C
AC Adapter 1: off-line


It exists a gkrellm plugin called gkacpi. It is quite bugged because of the lack of standardisation with ACPI but the source code (C) is quite easy to understand.

Suspend / Hibernate mode :
Thanks to Jan's Linux Log, I just successed to enable the suspend computer mode !! This means that I can press the power button to stop the computer and press again to restore my session and everything !! Great stuff !!
In order to get that stuff :
You have to patch your kernel with swsup (Software Suspend For Linux) :

cd /usr/src/
wget http://heanet.dl.sourceforge.net/sourceforge/swsusp/swsusp-2.0-rc2-whole.bz2
bunzip2 swsusp-2.0-rc2-whole.bz2
cd linux
patch -p1 < ../swsusp-2.0-rc2-whole

Unselect the SMP option (in Processor type and features), select Software Suspend and Relaxed /proc/swsusp permissions (in General Setup), select Enhanced Real Time Clock Support (in Character devices). Recompile your kernel and install it.
You have to specify also in your Linux Loader (lilo or grub) the name of the swap partition where will be stored the image :
for example, with lilo, it will be :

append="resume=/dev/hda7"

(change 7 for your configuration).
Download the suspend.sh script on the same website as the patch (This script is called suspend-script) and install it (./suspend.sh --install as root). This script will add some stuff regarding to your linux distribution (it manages at least Suse, Mandrake, Debian, Redhat, Gentoo and Slackware).
Edit the /etc/suspend.conf file and change SWSUSP_FORCE_SUSPEND_MODE="0" to SWSUSP_FORCE_SUSPEND_MODE="acpi"
If you successed to install everything, you should have your laptop suspended by executing /usr/local/sbin/hibernate.
You can make your own "shortcut" : if you press the power button, it will hibernate your computer. Edit the /etc/acpi/events/power file and add in it :

event=button[ /]power
action=sudo /usr/local/sbin/hibernate

And configure your sudo :

Host_Alias LOCALHOST=localhost,yourhost
ALL LOCALHOST=NOPASSWD: /usr/local/sbin/hibernate *

And it should work !!

Author : Bryan N Iotti (fedoracoreuser_at_yahoo.it) poste le 23/03/2004 15:38
Comment :
I must really thank you, since the part about patching the kernel saved me a lot of time ( kompare wouldn't work) Thanks again!
Reply to this comment

Author : () poste le 10/05/2004 21:08
Comment :
yh
Reply to this comment

Author : luc (luky457_at_hotmail.com) poste le 25/05/2004 05:03
Comment :
Aprés la mise en place de l'acpi sur mon compaq, la température est bien gérée par contre le ventilateur tourne toujours au ralenti (sous windows il s'arrête régulièrement).

Ma batterie a donc une autonomie réduite et je me demande si le fait que le ventilateur tourne en continue ne va pas user mon pc "plus vite"?
Reply to this comment

Author : asdf (asdf_at_asdf.asdf) poste le 12/06/2004 05:44
Comment :
asdf
Reply to this comment

Author : David Masover (ninja_at_slaphack.com) poste le 14/12/2004 06:01
Comment :
Here's my own quick guide:

Use the kernel's built in swsusp. swsusp-2.0 will be there eventually, but I try to keep the number of patches I use down so that they don't conflict.

Do add a resume= to your kernel options, even though it will also be compiled in somewhere. I use grub, so the step here was a little different.

Use ACPI if you can, and if you can, disable APM support.

Roll your own suspend/hibernate scripts and be prepared to spend a lot of time. Swsusp 2.0 or no, you may have to spend a LOT of time getting it working on your particular laptop.

For me, I had to make sure that I chvt'd out of X, unloaded my wireless driver, saved the clock, then suspended, then undid those in reverse order, and running hdparm AND WAITING FOR IT TO COMPLETE before starting X.

Use a recent 2.6 vanilla kernel, if possible. Until very recently, I couldn't get my networking to work after a suspend-to-disk, only suspend-to-ram.

I reccomend setting the power button to suspend-to-RAM, and have a manual setting to suspend-to-disk. This is because of the relative differences in starting times. If you suspend-to-ram by accident (tap the power button on laptop), you don't have to wait nearly as long as if you had suspended-to-disk.

Also, because suspend-to-disk takes so long to start back up, you won't be using it terribly often, or you'll lose more power than you save. Better to just close the lid so that your LCD isn't drawing power, set the disk to spin down reasonably often, and use reiser4 or XFS to maximize time between disk access.
Reply to this comment

Author : http://rzr.online.fr/q/ACPI (http://rzr.online.fr/q/ACPI) poste le 08/01/2005 11:56
Comment :
How to enable the lid switch ?
Reply to this comment

Author : Parag (paragnaphade_at_hotmail.com) poste le 13/04/2005 08:32
Comment :
will my linux machine will hibernate after this patch
Reply to this comment

Author : Noel Cower () poste le 14/04/2005 18:50
Comment :
Thanks a lot for this, really helped me getting this power management stuff working. Cheers!
Reply to this comment

Author : Leon Brooks (leon-sylvestre_at_cyberknights.com.au) poste le 28/05/2005 10:01
Comment :
I have an AOpen 1547, their forums redirected me here. If I suspend using KDE's power monitor applet, the machine suspends within 2 seconds (orange LED, the whole ritual); if I then hit the power button again I resume within about 3 - *but* the backlight doesn't come on so I can't see anything on the display. Same thing in both text and X. Running Mandrake's current Cooker RPM-set, which is kernel 2.6.11-8mdk and suspend-scripts-1.8.9-1mdk (/proc/acpi/info says 20050211).

If anyone knows what I can do to interest the backlight in reawakening, I would be most grateful. I've gotten everything *else* on this cheap laptop working (http://aopen1547.cyberknights.com.au/) and would like to complete the set before I retire the beastie. (-:
Reply to this comment
Author : anonymouse (mataglap(at)yahoo[d0t]com) poste le 13/04/2006 21:34
Comment :
you need backlight lcd controls in your kernel...
Reply to this comment


Author : someth|ng (strips at tiscali no) poste le 06/06/2005 10:14
Comment :
When i suspend and reboot my wireless card (orinco/prism I), and infrared port won't detect or autoconfigure the located access points or infrared devices. Why is this happening? Anyone had the same problem with a solve?
HP Pavilion ZE5244
Reply to this comment

Author : MIngZ (zhumingvictor_at_hotmail.com) poste le 22/09/2005 02:36
Comment :
Is this same as the hibernate we using in WinXP? Is it "suspend to disk" or just "suspend to memory"?
Reply to this comment

Author : trip_points () poste le 29/01/2006 18:38
Comment :
This is fine but my attempts to get trip_points to work on a asus m2400 m2a have failed. but asus mail and wireless lights can be activated. Hope they fix trip_points... or actualy make senseable points for active mode.
Reply to this comment

Author : robertn (robertn_at_slingshot.com) poste le 08/07/2006 16:11
Comment :
#!/bin/bash
uname -r
2.4.21-0.33mdk.test

/usr/src/linux
patch -p1 acpi-20040326-2.4.27.diff
segmentation fault

Hmm, what gives? This .diff was the closest one to my Mandrake 9.1 kernel. Did I screw up the kernel sources with this now?

Thanks for any response.

RobertN
Reply to this comment


Comment closed because of the spam