Suspend to RAM doesn't always turn the display back on

Please post any bugs you have found
Post Reply
Message
Author
buzby01
Posts: 15
Joined: Sun 11 Mar 2012, 06:27

Suspend to RAM doesn't always turn the display back on

#1 Post by buzby01 »

1stly I'd like to say thanks to the open source community and I'm lovn' Puppy so far. I'm running Macpup 5.2.8 on a Pendo netbook (d425 atom, Ralink 3090 wireless network card and an Intel n10 integrated graphics controller) and it runs really well however the suspend to ram, intermittently, does not wake properly.

About 1 out of every 4 times that I put it to sleep the screen does not turn back on nor does the WLAN card. Being a netbook with a small battery a working sleep function is fairly important to me and any help with this would be much appreciated

To suspend I use acpitool-s. To get it to suspend automatically I have to install acipd and acipd support and then in setting/screensaver I set the time and suspend on blank. I can't get the sleep button or lid to make it suspend either which would be good if you could help me with this as well. I tried setting the hardware switches with no success

I'm also new to the world of open source so you'll have to talk to me like I'm a child

cheers

User avatar
bigpup
Posts: 13886
Joined: Sun 11 Oct 2009, 18:15
Location: S.C. USA

#2 Post by bigpup »

Maybe install this laptop tools pet.
http://www.murga-linux.com/puppy/viewto ... 125#563125
The things they do not tell you, are usually the clue to solving the problem.
When I was a kid I wanted to be older.... This is not what I expected :shock:
YaPI(any iso installer)

buzby01
Posts: 15
Joined: Sun 11 Mar 2012, 06:27

#3 Post by buzby01 »

Thanks bigpup for getting back to me so quickly. The laptop.pet has helped out a lot. The lid closing and sleep button know work but it still doesn't recover from sleep properly with a blank screen and the wireless card does not come on either. The only sign of life is the led and the cpu fan.

Cheers

User avatar
Karl Godt
Posts: 4199
Joined: Sun 20 Jun 2010, 13:52
Location: Kiel,Germany

#4 Post by Karl Godt »

For the screen :

Which X servers are you running ? Xorg or Xvesa ?

If Xorg, which xorg _drv.so is used ? vesa or intel or i8**[OLD] ?

Does the Xorg driver vary ? One boot intel , another boot vesa ?

Have a look in /etc/X11/xorg.conf for the lines similar like

Identifier "Card0"
Driver "i810" #card0driver
VendorName "Intel Corporation"

Do you have two cards mentioned in xorg.conf ?
like
Identifier "Card0"
Driver "nv" #card0driver
VendorName "nVidia Corporation"

Identifier "Card1"
Driver "radeonhd"
VendorName "Gammagraphx, Inc. (or missing ID)"

?

*

For the WLAN card i would suggest to find out the kernel driver name and unload it
with " modprobe -rv DRIVER_NAME "

and reinserting it with " modprobe -v DRIVER_NAME " and rerun the setup .

Otherwise a script to do this would be neccessary before running acpitool -s .

Rename acpitool to acpitool.bin and create a wrapper shellscript called /usr/bin/acpitool with content like this :

Code: Select all

#!/bin/sh
#
#bring the network down:
function bring_down(){
#do code here

}
bring_down
pup_event_backend_modprobe_protect --stop
sleep 10s #to let the system settle
acpitool.bin -s
sleep 5s
pup_event_backend_modprobe_protec --daemon
Good Luck !

buzby01
Posts: 15
Joined: Sun 11 Mar 2012, 06:27

#5 Post by buzby01 »

Thanks karl godt. sorry for the late reply. I selected to be notified by email from this forum but obviously It didn't. Will give what you said a try and get back to you. I probably wont be able to do this till after Easter though

Further information since my last post:

I have read that acpitool has issues with CPU scaling and I have noticed it crashes more often when switching between ac and battery, so I have been modifying the scripts from the pet big pup suggested and things have been getting better but I'm afraid I don't really know what I'm doing. ATM the computer typically sleeps and resumes as long as I don't unplug or replug the AC

Thanks again

User avatar
pemasu
Posts: 5474
Joined: Wed 08 Jul 2009, 12:26
Location: Finland

#6 Post by pemasu »

If it is just screen backlight which does not work...you could edit /etc/acpi/sleep.sh script by addint vbetool commands there....
You will need vbetool package for it. Probably in lucid repo.
And see this post.... http://www.murga- ... 669#615669

And the subsequent posts...
It might work or not..and there was the simpler command after that post also....
Last edited by pemasu on Mon 02 Apr 2012, 12:22, edited 1 time in total.

buzby01
Posts: 15
Joined: Sun 11 Mar 2012, 06:27

#7 Post by buzby01 »

Thankyou Permusa but I'm sorry to say it did not work. After suspending with the modified sleep and then waking it would go back to sleep again. The second time it would wake but still had the intermittent crashes. I don't think it is a screen back-light but rather a system crash on resume.

I've had a little success modifying some of the acpi scripts but I'm afraid I don't know what I'm doing. Will post some more details about these mods and maybe they might help you pinpoint my problem

karl godt
Looked up the xorg.config and found that the driver is Intel driver and that it is the only one mentioned in then file. I will try the network stuff later. I have some assignments due and not enough time to do them

Thanks again to everybody

User avatar
Karl Godt
Posts: 4199
Joined: Sun 20 Jun 2010, 13:52
Location: Kiel,Germany

#8 Post by Karl Godt »

buzby01 wrote: ATM the computer typically sleeps and resumes as long as I don't unplug or replug the AC

Thanks again
acpitool -s suspends to RAM . If the ac gets unplugged and the battery empty, everything in RAM gets lost .

What your are looking for is apparently to suspend to disk .

This would be done by

acpitool -S (big S) .

Therefore you would need a grub entry with something like

"resume=/path/to/swap -partition" after root=/dev/xy .Don't know if this works for frugals .

buzby01
Posts: 15
Joined: Sun 11 Mar 2012, 06:27

#9 Post by buzby01 »

sorry Karl godT, I must not have explained myself properly. The battery does not get any where near flat I was just meaning that the phenomenon ocours more often if I switch between running the computer on AC to running it on battery power alone and vise versa. For instance the netbook is running on battery power alone and then I plug in the AC and after a while I put my netbook to sleep, it is much more likely to crash.

Thanks though for the aciptool -S command. Thats handy to know

buzby01
Posts: 15
Joined: Sun 11 Mar 2012, 06:27

Crash on resume

#10 Post by buzby01 »

Okay, Ive finally realised that it is not going to be easy to fix this. I have done everything in this post so far with no success.

This is a summary of what I have done. The results, however, must be taken with a grain of salt as the crashes seem to be completely random and therefore I will just state a range which the crashes occurred between

Initial install of laptop-acpi-batteries-tools-pet0.0.1.pet
Expected crash every 1-4 suspends

Modifications to powersave.sh ans performance.sh
Hashed out as follows:

#if [[ $? != 0 ]]; then
# exit
#fi
Expected crash every 1-8 suspends

Modifications sleep.sh
Replace /usr/local/Frisbee/disconnect and reconnect with:
wpa_cli disconnect and reconnect and add sleep 4 on the next line
Hashed out lines as follows:
#[ $$ != $PID ] && exit
#rfkill unblock all
Expected crash every 1-17 suspends

Installed xorghigh --> no change
Upgraded xdrivers --> no change
Turned of wifi and blacklisted rt2860sta and uninstalled wpa_gui --> no change (to check if it was the wifi causing the issue)

I also started running sleep.sh in the terminal and on this line [ $$ != $PID ] && exit I was getting the following errors unitl I hashed it:
[:8541 unary operator expected
(the number would vary each time ranging from 8486-9764)
on this line[ $$ != $PID ] && exit

I also inserted echos in the lines of sleep.sh to see exactly where the script stopped. On a succesful resume it would echo the last one however on a crash it would echo to the point before "acpitool -s". I'm guessing that this means it is a crash because it didn't even run the if statement to detect the ac.

If there is a better way to log this phenomenon (so that I can help you help me) can you instruct me how. I have read something about dmesg but have no idea of how to use it.

Thanking you in advance again

User avatar
d(O o O)b
Posts: 10
Joined: Wed 11 Apr 2012, 05:39
Location: Usually in the middle of some ocean

#11 Post by d(O o O)b »

I am pretty new at this, so I may be missing something obvious.

I am suspending to ram in Lucid 528 frugal hdd install without ACPItool or any other pets as far as I can see.

I simply use

echo mem > /sys/power/state

So far, everything has woken up fine everytime when I touch any key - been doing it for about a week without reboot. I have also wrote a little script which runs in the background and suspends to ram when the lid is closed:-

---------------------------------
#!/bin/sh

# event handler to automatically suspend-to-ram when laptop lid is closed.
# 2012 - d(O o O)b

while true #Endless loop.
do
if grep -q open /proc/acpi/button/lid/LID0/state
then
sleep 5 # minimise resource usage
else
echo mem > /sys/power/state # send the suspend signal
fi
done
--------------------------------------

Not sure if any of this will be of any use.

User avatar
Karl Godt
Posts: 4199
Joined: Sun 20 Jun 2010, 13:52
Location: Kiel,Germany

#12 Post by Karl Godt »

I also started running sleep.sh in the terminal and on this line [ $$ != $PID ] && exit I was getting the
Seems that PID is not filled with something:

bash-3.00# [ $$ != $PID ] && echo "PID of program NOT same as PID variable"
bash: [: 4220: unary operator expected
bash-3.00# PID=999999999
bash-3.00# [ $$ != $PID ] && echo "PID of program NOT same as PID variable"
PID of program NOT same as PID variable


Make sure the scripts dont use any binaries that are not already installed .

If they have something like

bash-3.00# dpkg-query
bash: dpkg-query: command not found

the PID var would not be set correctly
bash-3.00# PID=
bash-3.00# dpkg-query && PID=`ps -C acpid`
bash: dpkg-query: command not found
bash-3.00# echo "$PID"

bash-3.00# [ $$ != $PID ] && echo "PID of program NOT same as PID variable"
bash: [: 4220: unary operator expected

*

Puppy uses some /bin/busybox applets instead of the full ones , which may additionally lack some "-options" .

So third party scripts have to be adjusted for this.

I like Busybox very much, the only thing is losetup not working as it is needed in Puppy Linux .

To find the applets :

for dir in /bin /sbin /usr/bin /usr/sbin;do
find $dir -type l -name "*BB-NOTUSED"
done

*

FWIW : Current Debian Sid acpitool has got a weird patch for kernels 3.x.y .
Have compiled it on Racy and it suspended my asus eee 1005 two times correctly now to RAM .

User avatar
Karl Godt
Posts: 4199
Joined: Sun 20 Jun 2010, 13:52
Location: Kiel,Germany

#13 Post by Karl Godt »

d(O o O)b wrote:I am pretty new at this, so I may be missing something obvious.

I am suspending to ram in Lucid 528 frugal hdd install without ACPItool or any other pets as far as I can see.

I simply use

echo mem > /sys/power/state

So far, everything has woken up fine everytime when I touch any key - been doing it for about a week without reboot. I have also wrote a little script which runs in the background and suspends to ram when the lid is closed:-

---------------------------------
#!/bin/sh

# event handler to automatically suspend-to-ram when laptop lid is closed.
# 2012 - d(O o O)b

while true #Endless loop.
do
if grep -q open /proc/acpi/button/lid/LID0/state
then
sleep 5 # minimise resource usage
else
echo mem > /sys/power/state # send the suspend signal
fi
done
--------------------------------------

Not sure if any of this will be of any use.
Nice. I have modified it a bit first to check things :
Note : the PATH on my asus eee 1005 is slightly different :
/proc/acpi/button/lid/LID/state

Code: Select all

while true;do
LID_STATE=$(</proc/acpi/button/lid/LID/state)
if [ "$LID_STATE" != 'open' ];then
echo "$LID_STATE" >> /tmp/proc_acpi_lid_state.state
fi
sleep 2s
done
which gave me

state: open
state: open
state: open
state: open
state: closed
state: closed
state: closed
state: closed
state: closed
state: closed
state: closed
state: open
state: open
state: open
state: open

buzby01
Posts: 15
Joined: Sun 11 Mar 2012, 06:27

#14 Post by buzby01 »

d(O o O)b

Again there is no difference with the "echo mem > /sys/power/state" still crashed the same way but your post did shed some light on what might be happening.
So far, everything has woken up fine everytime when I touch any key
My netbook has a strange arrangement where the mouse and keyboard are disabled in S3 mode (the only indication that it is in s3 is a blinking led). To wake you have to press the power button. Maybe when trying to resume from sleep pup is having trouble restarting the keyboard, Mouse, etc. I have no idea how to go about testing or fixing this or even if its possible but maybe you guys could help

Karl Godt
Seems that PID is not filled with something:

bash-3.00# [ $$ != $PID ] && echo "PID of program NOT same as PID variable"
bash: [: 4220: unary operator expected
bash-3.00# PID=999999999
bash-3.00# [ $$ != $PID ] && echo "PID of program NOT same as PID variable"
PID of program NOT same as PID variable
Being a noob that post was beyond my abilities at present, I have no idea of what you wanted me to do, sorry.

Thanks again and I really appreciate the lengths you guys are going to try and help me with this

Cheers

User avatar
d(O o O)b
Posts: 10
Joined: Wed 11 Apr 2012, 05:39
Location: Usually in the middle of some ocean

#15 Post by d(O o O)b »

Karl Godt wrote:I have modified it a bit first to check things :
Note : the PATH on my asus eee 1005 is slightly different :
/proc/acpi/button/lid/LID/state

Code: Select all

while true;do
LID_STATE=$(</proc/acpi/button/lid/LID/state)
if [ "$LID_STATE" != 'open' ];then
echo "$LID_STATE" >> /tmp/proc_acpi_lid_state.state
fi
sleep 2s
done
which gave me

state: open
state: open
state: open
state: open
state: closed
state: closed
state: closed
state: closed
state: closed
state: closed
state: closed
state: open
state: open
state: open
state: open
I have expanded the script a bit after finding that my Lucid machine died on me halfway through a movie when the battery ran out.

The script now also checks battery condition (/proc/acpi/battery/BAT0/state) and gives 2 alarms (configurable within the script thru variables 'low' and 'lowlow'). If battery reserve drops below shutdown level (also configurable thru variable 'shutdown') then a controlled shutdown is performed. I prefer this option over 'suspend-to-ram, as an unattended laptop in suspend-to-ram will eventually lose any unsaved data when the battery completely dies.

It uses 'aplay /usr/share/audio/beep_low.wav' and '/usr/share/audio/logout.wav' to give audible notifications, so if any of these are missing from the host system then it will probably hang. It may be necessary to comment them out

The remaining battery time for the warnings is calculated based on power consumption at that particular time, so the actual gap between the warnings may vary if the power consumption is varying.

I know most of this is available in acpi-laptop-tools, but my script has a small footprint and does all I need so far. It was also a nice scripting excercise.
It is listed below in case anyone feels they can use it

-------------------------------------------------------------------------------------------------------

#!/bin/sh

#===========================================================================#
# event handler for basic power management 2012 - d(O o O)b #
# #
# Automatic suspend-to-ram when laptop lid is closed #
# Configurable alarms for LOW and LOWLOW battery level #
# Controlled Shutdown at LOWLOWLOW #
# #
#===========================================================================#

#------------------------USER ADJUSTABLE VALUES--------------------------------

timeout=20 # Alarm dialog timeout - allows program to continue if
# dialog not accepted

low=10 # Low alarm setpoint (minutes)
lowlow=4 # LowLow alarm setpoint (minutes)
shutdown=2 # Controlled Shutdown setpoint (minutes) - 2 is OK for frugal
# may need longer for USB Savefiles to safely save

#------------------------------------------------------------------------------

let "low += 1" let "lowlow += 1" let "shutdown += 1"
flag1=0 flag2=0 #unset the low battery flags for initialization
while true #Endless loop.
do
if grep -q open /proc/acpi/button/lid/LID0/state
then
if grep -q discharging /proc/acpi/battery/BAT0/state
then
batteryLife=$(echo "scale=0;$(grep remaining /proc/acpi/battery/BAT0/state|awk '{print $3}') * 60 / $(grep rate /proc/acpi/battery/BAT0/state|awk '{print $3}')"| bc)
if (($batteryLife < $lowlow)) && (($flag2 == 0))
then
aplay /usr/share/audio/beep_low.wav /usr/share/audio/beep_low.wav /usr/share/audio/beep_low.wav
Xdialog --title "Very Low Battery Warning" --timeout $timeout --msgbox "$batteryLife minutes remaining \n Plug in or shut down immediately," 10 50
flag2=1 flag1=1 #prevents looped reporting
fi
if (($batteryLife < $low)) && (($flag1 == 0))
then
aplay /usr/share/audio/beep_low.wav /usr/share/audio/beep_low.wav
Xdialog --title "Low Battery Warning" --timeout $timeout --msgbox "$batteryLife minutes remaining \n Plug in soon." 10 50
flag1=1 #prevents looped reporting
fi
if (($batteryLife < 3))
then
Xdialog --title "Controlled Shutdown" --timeout 5 --msgbox "$batteryLife minutes remaining \n System going into controlled shutdown." 10 50
aplay /usr/share/audio/logout.wav
wmpoweroff
fi
else
flag1=0 flag2=0 #unset the low battery flags if we are on charge
fi
sleep 5 # minimise resource usage
else
aplay /usr/share/audio/beep_low.wav
echo mem > /sys/power/state # send the suspend signal if lid is closed
fi
done
Attachments
pwrman.tar.gz
Basic Laptop Power Management Script
(1.03 KiB) Downloaded 674 times
Ran away from Redmond 2012 ----- Never going back :wink:
Acer 5332 -- Lucid 528.004 frugal -- usb bluetooth audio

User avatar
d(O o O)b
Posts: 10
Joined: Wed 11 Apr 2012, 05:39
Location: Usually in the middle of some ocean

#16 Post by d(O o O)b »

:oops: Ooops!

Just noticed I missed an update in the pwrman script
At present, the 'shutdown' variable does not have any effect.
It is necessary to modify line 45 :-

if (($batteryLife < 3))

change to:-

if (($batteryLife < $shutdown))

-------------------------------------------------------------------------------------------

As the dalek said to the dustbin - anyone can make a mistake
Ran away from Redmond 2012 ----- Never going back :wink:
Acer 5332 -- Lucid 528.004 frugal -- usb bluetooth audio

User avatar
vtpup
Posts: 1420
Joined: Thu 16 Oct 2008, 01:42
Location: Republic of Vermont
Contact:

#17 Post by vtpup »

Nice script!

(But wouldn't it be better if you went back and edited your correction into your earlier post and the downloadable script?)

ps. I had to edit BAT0 to BAT1 and LID1 to LID for my laptop using Racy 53.

Other users should check their /proc/acpi/....... directory names to likewise adjust the script if needed.

I put the script in /root/my-applications folder and made a link to it in the /root/Startup folder. Be sure to test the script before doing this, or you may find as I did, that you get unexpected suspends or even shutdowns as soon as Puppy starts. If so, simply boot into puppy with the pfix=ram parameter, and mount your savefile. Then delete the link in /root/Startup.

The script works great for me now -- just what I was looking for!


Now to get a suspend after a period of inactivity -- with video player exception -- saw a script around here for that, too.

edit:
here it is (mousuo.sh):

http://murga-linux.com/puppy/viewtopic.php?t=36109

For that one I commented out the wmpoweroff command line and substituted the suspend command from the pwrman script. Also removed the "Exit" line so that it would continue to loop.

Works well. The only drawback is that if it goes into suspend, I assume the pwrman script will not shut down the computer for a low battery while in suspend.

However I get the benefit that there will be longer period of inactivity until a loss of battery power, and it is likely I will see the blinking suspend LED at some point before the battery runs out. I can then resume and shut down programs, save data, or plug in.
[color=darkblue]Acer Aspire 5349-2635 laptop Tahrpup.[/color]
[color=blue]Acer R11 and C720 Chromebks Bionicpup64[/color]
[color=olive]Acer Iconia A1-830 tablet no pup[/color]
[color=orange]www.sredmond.com[/color]

Post Reply