Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
HOWTO: Getting APM suspend to work
View unanswered posts
View posts from last 24 hours

Goto page 1, 2  Next  
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
thechosen0ne
n00b
n00b


Joined: 23 Jan 2004
Posts: 36

PostPosted: Tue Mar 23, 2004 9:31 pm    Post subject: HOWTO: Getting APM suspend to work Reply with quote

Despite my best searching, the documentation out there for setting up APM suspend seems to be pretty minimal. I realize that ACPI is the new standard, but the code and drivers out there still seem to be in the developing stages. Here goes. I used an IBM Thinkpad 600x for this, but it should be pretty generic as long as your computer's bios supports APM.

1. Compile APM into your kernel

Make sure your /usr/src/linux symlink points to your kernel source folder
Code:

#cd /usr/src/linux
#make menuconfig

Power management options (ACPI, APM)  --->
  [*] Power Management support   

ACPI (Advanced Configuration and Power Interface) Support  --->
  [ ] ACPI Support

APM (Advanced Power Management) BIOS Support  --->
<*> APM (Advanced Power Management) BIOS support
  [ ]   Ignore USER SUSPEND
  [*]   Enable PM at boot time
  [*]   Make CPU Idle calls when idle
  [ ]   Enable console blanking using APM
  [ ]   RTC stores time in GMT
  [ ]   Allow interrupts during APM BIOS calls
  [ ]   Use real mode APM BIOS call to power off

Then save and exit.

You may have to change one or more of the APM options to make things work correctly, but this should give you the best default power management using APM. If you have problems suspending later on, try a different kernel configuration to see if it works.

Next, compile and copy your new kernel into /boot (done with 2.6 kernel, check handbook for 2.4 commands)
Code:

#make bzImage modules modules_install
#mount /boot
#cp arch/i386/boot/bzImage /boot/kernel-2.x.y
#cp System.map /boot/System.map-2.x.y
#rm /boot/System.map
#ln -s /boot/System.map-2.x.y /boot/System.map


now before you unmount /boot, run
Code:

#nano -w /boot/grub/grub.conf

and add the parameter apm=on acpi=off to your kernel parameters

The code is the same for lilo, just a different file. Once you are done with this part, you can unmount /boot and reboot with your new apm-ready kernel!

2. Emerge and Test ampd

ampd is a daemon that handles apm requests, basically, the thing that allows you to tell the computer to suspend. Emerging is pretty straightforward, run
Code:
#emerge apmd


Now you want to start apmd and use rc-update to make it run at boot
Code:
#/etc/init.d/apmd start
#rc-update add apmd default


Configuration shouldn't take much as long as you have apm support in your kernel. To test that apm works, you should be able to do the following:
To see information about AC status and battery info
Code:
#apm

To standby (on my system just turns the monitor off)
Code:
#apm -S

To suspend (the real goal of this howto)
Code:
#apm -s


If these commands don't work, go back to Step 1 and check out the kernel options. Some computers have weird BIOS's that linux has ways around using the different options. Otherwise, continue on.

3. Configure apmd Events
You may notice after suspending that your network card or sound stops functioning. Fortunately, apmd has a way around this, using scripts placed in /etc/apm/event.d/ . They are executed every time the system suspends/resumes. Here are the scripts in my event.d directory, you can add your own if you have other things you would like run on suspend/resume:

/etc/apm/event.d/alsa
Code:

#!/bin/sh
#<br />
case "$1" in
resume)
        /etc/init.d/alsasound start
        ;;
suspend)
        /etc/init.d/alsasound stop
        ;;
esac


/etc/apm/event.d/usb
Code:

#!/bin/sh
case "$1" in
        suspend)
                /etc/init.d/hotplug stop
                ;;
        resume)
                /etc/init.d/hotplug start
                ;;
esac


/etc/apm/event.d/pcmcia
Code:

#!/bin/sh
case "$1" in
        suspend)
                /sbin/cardctl eject
                ;;
        resume)
                /sbin/cardctl insert
                ;;
esac


The pcmcia script will cause any pcmcia cards to be reloaded (network cards, etc). It is like pulling the card out of the slot and reinserting it.

Make sure that for each script you make it executable using
Code:
chmod +x scriptname


Now when you run apm -s you should have sound, usb, pcmcia working when you resume. You can check the output of #dmesg and it should have some info about things that have been restarted. That's it! Please let me know if I forgot anything!

EDIT: I'm going to start experimenting with ACPI, because I think support is finally starting to come around for my Thinkpad 600X... we'll see. I'll post a similar howto if I get it working.

RE-EDIT: I seem to have found a howto, check it out. I certainly will https://forums.gentoo.org/viewtopic.php?t=147898


Last edited by thechosen0ne on Thu Jun 03, 2004 6:07 am; edited 3 times in total
Back to top
View user's profile Send private message
MaxDamage
l33t
l33t


Joined: 03 Jan 2004
Posts: 650
Location: Oviedo, Spain

PostPosted: Thu Mar 25, 2004 4:24 pm    Post subject: Reply with quote

I'm recompiling the kernel right now. When I reboot I will tell you the results. I thought suspending under Linux wasn't possible :P

My desktop PC is an Athlon XP 2000, 512MB RAM PC-333, and Gigabyte GA-7VAX board with KT400a chipset, integrated via82xx soundcard and integrated realtek ethernet card.

EDIT: Yes, both suspend and standby work. Nice guide ;)
_________________
La PDA de tungsteno
Back to top
View user's profile Send private message
FonderiaDigitale
Veteran
Veteran


Joined: 06 Nov 2003
Posts: 1710
Location: Rome, Italy

PostPosted: Sun Apr 18, 2004 5:44 pm    Post subject: Re: HOWTO: Getting APM suspend to work Reply with quote

You can simply differentiate scripts by their own name

/etc/apm/SERVICE_NAME
Code:

#!/bin/sh
case "$1" in
        suspend)
                /etc/init.d/$0 stop
                ;;
        resume)
                /etc/init.d/$0 start
                ;;
esac


and symlink /etc/apm/SERVICE_NAME to eg. /etc/apm/event.d/usb

this except, obviously, pcmcia.

BTW, thanks for this guide :)
_________________
Come disse un amico, i sistemisti sono un po' come gli artigiani per l'informatica :)
Back to top
View user's profile Send private message
Gatak
Apprentice
Apprentice


Joined: 04 Jan 2004
Posts: 174

PostPosted: Mon Apr 19, 2004 9:23 am    Post subject: Reply with quote

How does this work with ACPI? There used to be a conflict between APM and ACPI in 2.4 kernels. Is is still in 2.6?
Back to top
View user's profile Send private message
Phk
Guru
Guru


Joined: 02 Feb 2004
Posts: 428
Location: [undef], Lisbon, Portugal, Europe, Earth, SolarSystem, MilkyWay, 23Q Radius, Forward Time

PostPosted: Wed Apr 21, 2004 4:07 am    Post subject: Re: HOWTO: Getting APM suspend to work Reply with quote

thechosen0ne wrote:
Despite my best searching, the documentation out there for setting up APM suspend seems to be pretty minimal.
[...]
That's it! Please let me know if I forgot anything!


Excellent Post, chosenOne! Speakin for me (and many more probably):
THANKX ;)
_________________
"# cat /dev/urandom >> /tmp/life"
Back to top
View user's profile Send private message
Phk
Guru
Guru


Joined: 02 Feb 2004
Posts: 428
Location: [undef], Lisbon, Portugal, Europe, Earth, SolarSystem, MilkyWay, 23Q Radius, Forward Time

PostPosted: Wed Apr 21, 2004 8:12 pm    Post subject: Reply with quote

However........ even doing this i still have a problem:

My "apmd" give a "Oops" crash.... With lots and lots of error-messages....
Anyone knows about this ?
_________________
"# cat /dev/urandom >> /tmp/life"
Back to top
View user's profile Send private message
agaffney
Retired Dev
Retired Dev


Joined: 28 May 2003
Posts: 104
Location: St. Charles, MO

PostPosted: Wed Apr 28, 2004 6:14 am    Post subject: Reply with quote

I seem to have a problem with this on my Thinkpad 770. I'm running gentoo-dev-sources-2.6.4. My PCMCIA NIC is a D-Link DWL-AB650 802.11b card. I'm currently using Linuxant driverloader with it due to weird problems with madwifi-drivers.

When I suspend ('apm -s' or Fn-F4) and bring it back up, the NIC comes back up (blinking lights) but it doesn't have an IP. If I manually run '/etc/init.d/net.eth0 restart' it takes a few minutes to come back up, but it does work again.

Can I automate this with these scripts (I know the answer is yes, but I'm asking anyway)? Why does it take so long to come back up?
Back to top
View user's profile Send private message
agaffney
Retired Dev
Retired Dev


Joined: 28 May 2003
Posts: 104
Location: St. Charles, MO

PostPosted: Wed Apr 28, 2004 6:40 am    Post subject: Reply with quote

After a little playing around, if I run 'iwconfig eth0 essid "myessid"' and then '/etc/init.d/net.eth0 zap; /etc/init.d/net.eth0 start' right after resuming, it comes up very quickly. It seems to have a hard time associating with the AP. It sees it and is on the correct channel, but it doesn't set the ESSID correctly. Anyone know why?
Back to top
View user's profile Send private message
stahlsau
Guru
Guru


Joined: 09 Jan 2004
Posts: 584
Location: WildWestwoods

PostPosted: Tue Jun 01, 2004 8:00 pm    Post subject: Reply with quote

hi,
nice howto. I´m using ACPI, but the idea about killing alsasound before going asleep helps for that as well ;-))
thx! :-)
Back to top
View user's profile Send private message
Phk
Guru
Guru


Joined: 02 Feb 2004
Posts: 428
Location: [undef], Lisbon, Portugal, Europe, Earth, SolarSystem, MilkyWay, 23Q Radius, Forward Time

PostPosted: Wed Jun 02, 2004 2:29 pm    Post subject: Reply with quote

Sorry to bother you all with this again, but:

After doing everything, and turning on APM, ACPI off, and adding APMD to rc-update, i get a strange "Segmentation Fault", or "OOoops" crash whenever i try to load "apmd"....

What's the problem here? This computer is a laptop, and if suspends perfectly under microshit's os..

Do i need to re-emerge anything?

thanks for the attention []
_________________
"# cat /dev/urandom >> /tmp/life"
Back to top
View user's profile Send private message
thrasher6670
Apprentice
Apprentice


Joined: 04 Aug 2003
Posts: 269
Location: London, Ontario

PostPosted: Tue Jun 22, 2004 4:00 pm    Post subject: Reply with quote

I have added this to gentoo-wiki.com

http://gentoo-wiki.com/HOWTO_APM_Suspend

If anyone sees any changes that need to be made, feel freed to add them, It is a wiki afterall

great HOWTO BTW
_________________
Gentoo-Portage.com - Where the portage meets the web
Gentoo Wiki
Back to top
View user's profile Send private message
Phk
Guru
Guru


Joined: 02 Feb 2004
Posts: 428
Location: [undef], Lisbon, Portugal, Europe, Earth, SolarSystem, MilkyWay, 23Q Radius, Forward Time

PostPosted: Wed Jun 23, 2004 6:00 pm    Post subject: Reply with quote

That's a nice WIKI, that's for your contribution...

BUT!! There's one topic no one ever answered me:

I had the whole system emerged, with APM=OFF and ACPI=ON.
Now, when i do the WIKI steps, i get a "segfault" each time i run apmd or i try to suspend....
WHAT or DO i have to re-compile? :(
_________________
"# cat /dev/urandom >> /tmp/life"
Back to top
View user's profile Send private message
polymorf
n00b
n00b


Joined: 16 Nov 2003
Posts: 7

PostPosted: Tue Jun 29, 2004 10:23 am    Post subject: Reply with quote

Hrm. I went through these steps and they arn't working for me.

I'm running a dell L400. I've compiled support for APM in because in dmesg states that my bios is old and doesn't support ACPI.

then i emerged apmd and it seems to be running fine, but when i run apm -S nothing happens. Even better when i run apm -s, the system seems like its going to suspend - the screen blanks but after a second or so it comes back with:

apm: Input/output error

Anyone seen this before?


thanks!

poly
Back to top
View user's profile Send private message
stahlsau
Guru
Guru


Joined: 09 Jan 2004
Posts: 584
Location: WildWestwoods

PostPosted: Tue Jun 29, 2004 1:22 pm    Post subject: Reply with quote

nope, works here.
Only thing is, sometimes after coming back it opens 317 instances of mozilla, and my aterm scrolls like hell ;-) Dunno what causes this, but i had to laugh so much when it opens 317 mozillas that i didn´t have the chance to get annoyed *lol*
Back to top
View user's profile Send private message
phuber
Tux's lil' helper
Tux's lil' helper


Joined: 19 Aug 2003
Posts: 106
Location: switzerland

PostPosted: Wed Jun 30, 2004 6:27 pm    Post subject: Reply with quote

I'm having a few troubles getting all this to work. Basically suspend and resume work but the suspend doesn't seem to get called...

My Scripts:
Code:

#!/bin/bash
#/etc/apm/event.d/ac-power
case "$1" in
        change)
                if [ `cat /proc/apm | cut -d"x" -f3 | cut -d" " -f1` -eq "00" ];
                then
                        sync
                        laptop-mode start
                else
                        laptop-mode stop
                fi
        ;;
esac


Code:

#!/bin/bash
#/etc/apm/event.d/on-off

logger "script called with: 0:$0 1:$1 2:$2 3:$3 4:$4 5:$5"

case "$1" in
        suspend)
                logger "Shutting down hotplug, vpn, eth0, ath0 - syncing discs"
                /etc/init.d/hotplug stop
                sudo phuber vpnclient disconnect
                /etc/init.d/net.eth0 stop
                /etc/init.d/net.ath0 stop
                sync
                sleep 1
        ;;
        resume)
                logger "Starting hotplug, eth0, ath0"
                /etc/init.d/hotplug start
                /etc/init.d/net.eth0 start
                /etc/init.d/net.ath0 start
        ;;
esac


When I issue "apm --suspend" on the console I get:
Code:

Jun 30 20:14:38 deadbeef logger: script called with: 0:/etc/apm/event.d/on-off 1:suspend 2:user 3: 4: 5:
Jun 30 20:14:38 deadbeef logger: Shutting down hotplug, vpn, eth0, ath0 - syncing discs
Jun 30 20:15:27 deadbeef logger: script called with: 0:/etc/apm/event.d/on-off 1:resume 2:suspend 3: 4: 5:
Jun 30 20:15:27 deadbeef logger: Starting hotplug, eth0, ath0




When I just close the lid I get:
Code:

Jun 30 20:16:19 deadbeef logger: script called with: 0:/etc/apm/event.d/on-off 1:resume 2:suspend 3: 4: 5:
Jun 30 20:16:19 deadbeef logger: Starting hotplug, eth0, ath0



The apmd version is 3.0.2-r3

Does anyone know why this happens how I can get it working correctly? Thanks!
Back to top
View user's profile Send private message
Caalvin
n00b
n00b


Joined: 15 Apr 2004
Posts: 20
Location: Wiesbaden/Germany

PostPosted: Fri Jul 02, 2004 10:12 pm    Post subject: Reply with quote

hi, first of all, thanks a lot for the hints....
but there is one problem left for me.
a few weeks ago, it possible to set my notebook to suspend by closing the lid, but now it freezed when close the lid. Is there anyone, who has an idea what i have to do...

the notebook is an DELL latitude csx (P3-500)

ciao
torsten
Back to top
View user's profile Send private message
BTR
n00b
n00b


Joined: 16 Jul 2004
Posts: 52

PostPosted: Mon Jul 19, 2004 10:54 pm    Post subject: Reply with quote

What if you want certain services to remain on? Whenever I come out of suspension, eth0 is up fine, but I want it to [i]remain[/i] on while my system's suspended, so I can go away and still access my computer remotely (I have a desktop). As is it seems like the network device goes down while my system's suspended, and that is NOT the behavior I want.
Back to top
View user's profile Send private message
boltronics
n00b
n00b


Joined: 25 Nov 2002
Posts: 49
Location: Melbourne, Australia

PostPosted: Wed Jul 21, 2004 2:41 am    Post subject: Reply with quote

BTR, sounds like you want standby mode instead of suspend mode. See the first post for screen blanking (apm -S). In suspend mode, I believe the CPU goes to sleep and can't be used (hence goes your networking and everything else).
_________________
"Free" as in "free speech", not as in "free beer".
GPG key ID: 0x78FDC750
Back to top
View user's profile Send private message
crafteh
n00b
n00b


Joined: 30 Mar 2004
Posts: 29

PostPosted: Wed Jul 28, 2004 2:54 am    Post subject: Reply with quote

How can I get my keyboard to work after I resume from suspend?
Back to top
View user's profile Send private message
tam
Guru
Guru


Joined: 04 Mar 2003
Posts: 569

PostPosted: Sun Aug 01, 2004 5:58 pm    Post subject: Reply with quote

My Thinkpad T23only suspend if I (auto)load yenta_socket as module and unload this module before suspend:

/etc/apm/event.d/pcmcia

Code:
#!/bin/sh
case "$1" in
        suspend)
                /sbin/modprobe -r yenta_socket
                /sbin/cardctl eject
                ;;
        resume)
                /sbin/modprobe yenta_socket
                /sbin/cardctl insert
                ;;
esac


Too bad, I can't use my wireless LAN card after suspend anyhow.
Back to top
View user's profile Send private message
biatch0
n00b
n00b


Joined: 25 May 2004
Posts: 40

PostPosted: Sat Aug 14, 2004 5:48 am    Post subject: Reply with quote

Here's a question... I've got a Dell Latitude L400, Gentoo is running perfectly with the exception of APM; the only one small problem I have is suspend/wakeup. During short suspend periods of maybe up to one hour, the laptop wakes up perfectly to whatever it was doing before... however, occasionally it refuses to wake up giving me just a blank screen (the screen DID turn on) and nothing more (hammering caps lock would not turn on the blinky little light :roll: ).

Weird thing is that I can't see anything of interest showing up in the logs after a cold reboot (nothing else works). This is a cry for help BTW :oops:
Back to top
View user's profile Send private message
Ben2040
Guru
Guru


Joined: 07 May 2003
Posts: 445
Location: UK

PostPosted: Sat Aug 14, 2004 12:30 pm    Post subject: Reply with quote

Hi

I have a real old Dell Latitude (100Mhz), running Debian, and I did nothing to set up apm or suspending - It just works! I can type apm t check battery, or run a WindowMaker Dockapp for it, and I can press "Fn+Suspend" t osuspend, which turns of the PCMCIA and everything correctly. With or without X running I can then open the lid/press a button to resume and the net comes back up and everything is peachy :)

Does Debian include this style of event scripts?

Ben
Back to top
View user's profile Send private message
badgers
l33t
l33t


Joined: 04 Sep 2003
Posts: 680
Location: Madison, WI

PostPosted: Sat Oct 30, 2004 4:24 pm    Post subject: Reply with quote

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
I followed this with the 2.6.9 love kernel

when I do apm -s the system spins down(the fan on the cpu keeps running) but I can hear the hard drive spin down
then 2 seconds later it starts back up again without me touching anything.
WTF

when you have the choice of the suspend partion, what should I tell it?
/dev/hda3 is what I have
_________________
Abit KD7-S
Athlon XP2500+
166mHz FSB
512 Meg PC3200 Ram running at 166mHz
LiteOn DVD dual Layer burner(hdc)

2.6.17 Suspend2 kernel with no scsi support
Back to top
View user's profile Send private message
Swift
n00b
n00b


Joined: 09 Jun 2002
Posts: 51

PostPosted: Sun Oct 31, 2004 11:07 am    Post subject: Reply with quote

got it working on my t42, only problem left, the script in event.d doesn't seem to be executed (and yes, it is chmod +x)

anyone knows a possible reason?

/e:
solved with:
Code:
[*]   Allow interrupts during APM BIOS calls
Back to top
View user's profile Send private message
Caalvin
n00b
n00b


Joined: 15 Apr 2004
Posts: 20
Location: Wiesbaden/Germany

PostPosted: Sat Sep 24, 2005 11:44 pm    Post subject: Reply with quote

works fine on my Dell Latitude csx.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum