# ACPI battery problem

## Bonkie

Im trying to get ACPI show my battery status. APCI should be supported by my compaq laptop as it sais here.

 *Quote:*   

>  ACPI compliant

 

I'm using the acpi-sources for my kernel & I have "acpi" in my USE variables.

```
# cd /usr/src/linux

# grep -i acpi .config

# CONFIG_HOTPLUG_PCI_ACPI is not set

# ACPI support

CONFIG_ACPI=y

# CONFIG_ACPI_HT_ONLY is not set

CONFIG_ACPI_BOOT=y

CONFIG_ACPI_BUS=y

CONFIG_ACPI_INTERPRETER=y

CONFIG_ACPI_EC=y

CONFIG_ACPI_POWER=y

CONFIG_ACPI_PCI=y

CONFIG_ACPI_SLEEP=y

CONFIG_ACPI_SYSTEM=y

# CONFIG_ACPI_# CONFIG_ACPI_AC is not set

CONFIG_ACPI_BATTERY=y

# CONFIG_ACPI_BUTTON is not set

# CONFIG_ACPI_FAN is not set

# CONFIG_ACPI_PROCESSOR is not set

# CONFIG_ACPI_THERMAL is not set

# CONFIG_ACPI_TOSHIBA is not set

CONFIG_ACPI_DEBUG=y
```

acpi seems to be loaded at boot & my log shows after starting acpid manually:

```
# tail /var/log/acpid

starting up

1 rule loaded
```

But when i see if it reads my battery status i get:

```
 ls -l /proc/acpi/battery/

total 0 
```

mmm ... What am i forgetting ?? Or should I try to get APM working ??

----------

## kerframil

I recommend you enable the other ACPI options also: ACPI_BUTTON, ACPI_FAN, ACPI_PROCESSOR and ACPI_THERMAL.

You could try using different versions of the ACPI layer. The vanilla-sources has an out-of-date but presumably more reliable layer. gentoo-sources-2.4.19 uses a newer layer which is only used if you emerge those sources with USE="acpi4linux". gentoo-sources-2.4.20-r1 (which is masked) uses the same as ck-sources, dated 15/12/2002. You can also get the latest ACPI layer from its hompage over at sourceforge.net and patch a vanilla kernel yourself.

----------

## Bonkie

tried everything except the vanilla sources ... 

I currently have installed it with APM support and it works so ... guess i'm gonna stick with it  :Smile: 

----------

## zerofunk

I'm pretty sure APM support is more mature than ACPI, so as a general rule if your laptop has both available you probably want to use APM. My laptop only has ACPI and to get it to work, I had to patch the vanilla 2.4.20 sources with the ACPI patches from sourceforge. When you goto configure the kernel, you should also enable all the options for ACPI as kerframil mentioned. Especially the debugging one since it might be helpful, and I think I've read before that everything breaks without (might be fixed now?).

----------

## kerframil

I spoke to someone on IRC recently who had a new Athlon based laptop, and was unable to get it working with APM or ACPI. I suggested trying the new ck-sources kernel (which was updated by Con Koliva on the 10th), and it fixed the problem.

----------

## stratocastor666

Im having very similar problems as well. Will try the ck-sources though. hope they work.

----------

## gordonNgentoo

ck sources?  noob here, would appreciate some verbose instructions.

I'v set USE=" acpi ..." without apm because I know my motherboard only supports acpi  (laptop: acer travelmate 524TE).

dmesg does say the button , fan, and all those nifty acpi detected, but when I hit the Zzz button or the power button, there's no response.  I went as far as I can and searched as much forums as I can, but nothing avail.  I would appreciate some verbose instructions to get this working.  -Thanks Gordon

----------

## gordonNgentoo

ck sources?  noob here, would appreciate some verbose instructions.

I'v set USE=" acpi ..." without apm because I know my motherboard only supports acpi  (laptop: acer travelmate 524TE).

dmesg does say the button , fan, and all those nifty acpi detected, but when I hit the Zzz button or the power button, there's no response.  I went as far as I can and searched as much forums as I can, but nothing avail.  I would appreciate some verbose instructions to get this working.  -Thanks Gordon .

----------

## stratocastor666

Doing an emerge ck-sources will auto emerge a 2.4.20 modified kernel into /usr/src/linux-2.4.20-ck  Its supposed to have modifications for ACPI. But I tried it, and still my batter level cannot be read, and hitting power button does nothing. APM will at least show battery level, but no shutdown.

----------

## kerframil

 *Quote:*   

> But I tried it, and still my batter level cannot be read, and hitting power button does nothing. APM will at least show battery level, but no shutdown.

 

 *Quote:*   

> dmesg does say the button , fan, and all those nifty acpi detected, but when I hit the Zzz button or the power button, there's no response.

 

First, you'll need to emerge the ACPI daemon to respond to ACPI events:

```
emerge acpid
```

If you're using a newer ACPI layer other than that included in the vanilla kernel (you are if you're using ck-sources or gentoo-sources-2.4.19 with USE="acpi4linux" or gentoo-sources-2.4.20), then you need to adjust the /etc/acpi/default.sh file, which is the default ACPI event handler script for the daemon. It should look like this:

```
#!/bin/sh

# Default acpi script that takes an entry for all actions

                                                                                

set $*

                                                                                

case "$1" in

        button/power)

                case "$2" in

                        PWRF)   /sbin/init 0

                                ;;

                        *)      logger "ACPI action $2 is not defined"

                                ;;

                esac

                ;;

                                                                                

        *)

                logger "ACPI group $1 / action $2 is not defined"

                ;;

esac
```

The reason it needs to be changed is because the event signals changed in the newer ACPI layers. Stop the daemon, do cat /proc/acpi/event and press the button to discover more.

As for sleep modes and all the rest, well I don't know. Maybe more handler programs have to be defined in default.sh. This warrants futher investigation for sure. I suspect that when you press the "ZZzz" button, the event handle just ends up with "ACPI action _____ not defined" in your syslog. I believe you'd need to cat the event to see what it looks like, and add a hanler to the default.sh script. Something like this perhaps:

```
echo "3" > /proc/acpi/sleep
```

That's supposed to activate ACPI S3 mode, which is Suspend-to-Ram. Don't necessarily expect it to work properly!

As for reading the battery level, well no programs are mentioned here. Compiling things with USE="acpi -apm" might help. Or you can cat the battery status from the /proc interface probably.

By the way, be warned that pressing the power off button does /sbin/init 0 which forcefully powers down, no matter what you are doing! A better script or command could be provided which handles things more gracefully - not shutting down if you're in X for example.

----------

## kerframil

By the way, to get ck-sources:

```
emerge ck-sources

cd /usr/src/

rm linux

ln -s linux-2.4.20-ck3 linux
```

Then set up your kernel in the same way as you normally would. Like this:

```
cd /usr/src/linux

make menuconfig

make dep && make clean bzImage modules modules_install
```

You'll need to mount /boot and copy your bzImage over there of course. Follow the same steps you did in the install guide.

Don't forget to enable all ACPI options in kernel setup (Battery, Thermal Zone ... etc).

----------

## gordonNgentoo

I have a little concern for this new ck kernel, I have a few concerns I'd like to ask:

1)  IF I upgrade my kernel to this ck version, in the future, when I AGAIN upgrade my kernel by doing "emerge gentoo-sources"  what happens???  will I be able to go back to gentoo-sources ?  or will I be stuck at the ck ?  I have a feeling you're going to say that if I do emerge gentoo-sources, I'll get gentoo-sources kernel, and if I did emerge ck-blah blah kernel, I'll get this ck kernel?  Just need confirmation.

2) vanilla kernel.  What's the difference between the vanilla kernel and gentoo's kernel?  

3) am I correct to assume that there's less support (tech support) for the ck kernel compared to the gentoo kernel?  I'm worried about having more potential errors.  (newbie).

4) if there's problem with this new layer thing, why do they even put it in the kernel???  I expect them to at least mark those as "experimental" rather than to have people waste hours of our time trying to figure out what's wrong.   I've had both mandrake and redhat and they had this power mangagement configured correctly.

-Gordon

----------

