Page 1 of 4

Wake from halt

Posted: Tue Dec 04, 2012 11:27 pm
by dom
If you shutdown, e.g.

Code: Select all

sudo halt
The Pi goes into a lower powered state. There is no way of waking up from this state without power cyling.
I've now added a way to wake the board through GPIO.
A falling edge on GPIO1 or GPIO3 will wake the board up, and it will continue to boot into linux.

Note: this the the same GPIO used by safe mode, so touching a jumper onto the safe mode pin will cause the board to wake up.
http://www.raspberrypi.org/phpBB3/viewt ... 29&t=12007

Re: Wake from halt

Posted: Tue Dec 04, 2012 11:39 pm
by jojopi
dom wrote:There is no way of waking up from this state without power cyling.
P6. Or on a Rev1 board, carefully tapping a resistor between TP2 and the SoC end of R15.

But it will be great to have an easy method. Thanks!

Re: Wake from halt

Posted: Wed Dec 05, 2012 9:28 pm
by plugh
I assume you are talking about a true 'wake' (cpu continues after the halt instr.) not a reset/reboot (a la P6)?

Neat idea; means something on that I2C bus can bring system out of 'deep sleep'...

Re: Wake from halt

Posted: Thu Dec 06, 2012 12:57 am
by Dweeber
Cool.... now you could have a Shutdown button... (does a shutdown) and a Restart Button.... and an OS On/Off LED on the outside of a case.

Re: Wake from halt

Posted: Thu Dec 06, 2012 5:36 am
by rpdom
Thanks dom, that's a very handy option to have.

I've added a "restart" push button to my Pi setup :-)

Re: Wake from halt

Posted: Thu Dec 06, 2012 4:59 pm
by dom
plugh wrote:I assume you are talking about a true 'wake' (cpu continues after the halt instr.) not a reset/reboot (a la P6)?

Neat idea; means something on that I2C bus can bring system out of 'deep sleep'...
Yes. The "halt" state puts VideoCore to sleep early in bootcode.bin code.
Before the clocks are set up (we are running from oscillator), before the ARM or GPU hardware block are enabled. Before sdram is enabled (it runs from the L2 cache).

The gpio interrupt wakes the core and it continues booting(rather than resetting the chip, which would have a similar effect).

Re: Wake from halt

Posted: Thu Dec 06, 2012 7:29 pm
by Dweeber
I gave this a shot and it works great.

Re: Wake from halt

Posted: Tue Jan 01, 2013 10:26 am
by cbvicious
I'm sorry to say I'm feeling painfully stupid. Can Someone post a picture of exactly how to wake from halt?

Re: Wake from halt

Posted: Tue Jan 01, 2013 1:11 pm
by sdjf
cbvicious wrote:I'm sorry to say I'm feeling painfully stupid. Can Someone post a picture of exactly how to wake from halt?
You are not the only one feeling lost. One of those threads linked to above has a link to an eLinux page that is supposed to explain how to do this, and there is a good picture there, but the picture is useless if the text still leaves unanswered questions for those of us not used to doing this kind of stuff.

http://elinux.org/RPI_safe_mode

Do we leave a wire there all the time or just put it there when needed? Someone mentioned a paper clip would work, but that would mean more than wire going between 5 and 6, that wouldn't be okay, would it?

Re: Wake from halt

Posted: Tue Jan 01, 2013 1:18 pm
by dom
cbvicious wrote:I'm sorry to say I'm feeling painfully stupid. Can Someone post a picture of exactly how to wake from halt?
This feaure is now in the main firmware tree, so updating with rpi-update is sufficient.

Do a:

Code: Select all

sudo halt
To wake up, you need to short the two pins indicated here:
http://www.raspberrypi.org/phpBB3/viewt ... 29&t=12007
(e.g by attaching a jumper, or for the more advanced by attaching some external circuitry)

Re: Wake from halt

Posted: Tue Jan 01, 2013 3:31 pm
by KenT
Dom

Is there any practical difference between this and the Reset pin P6 introduced on the Rev. 2 board.

In experiments by raspi.tv here http://raspi.tv/2012/making-a-reset-swi ... spberry-pi It seems this can do a restart without recycling power.

Re: Wake from halt

Posted: Tue Jan 01, 2013 3:58 pm
by dom
KenT wrote:Is there any practical difference between this and the Reset pin P6 introduced on the Rev. 2 board.
This scheme avoids reloading bootcode.bin, but otherwise the two schemes are pretty much identical (as long you have a rev2 board).

Re: Wake from halt

Posted: Wed Jan 02, 2013 2:50 pm
by ++bahjatk++
I am still clueless.
If I do a "sudo halt" (My Pi is yet to arrive so...) will the power go off ?
And whether it does or not, how do I wake up after I connected pins 5 and 6 ? (what do I click?)

Re: Wake from halt

Posted: Wed Jan 02, 2013 3:14 pm
by Burngate
++bahjatk++ wrote:If I do a "sudo halt" will the power go off ?
No
Power is not switched - in fact quite a bit is involved in making your average PC switch itself off after shutdown, and indeed getting it to come back up after that with a push button.
Not quite as much as having the power button on an Apple keyboard.

So applying power to your Pi starts it booting, by asserting a power-on-reset.. Halt puts it into a shutdown state, in which nothing useful is happening
Taking the RST pin to 0v (on Rev 2) asserts the same power-on-reset, and so initiates the boot.
Connecting pin 5 to 0v (pin 6) restarts the boot sequence part way through.

So it wakes itself up, more-or-less the same as if you'd just connected the power.

Re: Wake from halt

Posted: Wed Jan 02, 2013 3:17 pm
by redhawk
Does the Pi have the capability for suspend / resume mode??

Richard S.

Re: Wake from halt

Posted: Fri Jan 04, 2013 3:21 am
by cbvicious
Is this functional in the latest RaspBMC?

Re: Wake from halt

Posted: Fri Jan 04, 2013 6:17 am
by bgirardot
sdjf wrote:
cbvicious wrote:I'm sorry to say I'm feeling painfully stupid. Can Someone post a picture of exactly how to wake from halt?
You are not the only one feeling lost. One of those threads linked to above has a link to an eLinux page that is supposed to explain how to do this, and there is a good picture there, but the picture is useless if the text still leaves unanswered questions for those of us not used to doing this kind of stuff.

http://elinux.org/RPI_safe_mode

Do we leave a wire there all the time or just put it there when needed? Someone mentioned a paper clip would work, but that would mean more than wire going between 5 and 6, that wouldn't be okay, would it?
I updated the wiki page above to add info about the wake from halt. It should really be its own page but I am too lazy to create a photo for it at the moment but will do so in the future. Corrections/feeback always welcome.

Re: Wake from halt

Posted: Fri Jan 04, 2013 6:29 pm
by thrillscience
What happens when it wakes from halt? Does it do a long reboot, or does it simply pick up from after where it executed the Halt?

(And I don't see a Halt or Sleep, or Stop instruction in the ARM instruction set, so I'm not clear on how you halt it.)

Re: Wake from halt

Posted: Fri Jan 04, 2013 6:44 pm
by dom
thrillscience wrote:What happens when it wakes from halt? Does it do a long reboot, or does it simply pick up from after where it executed the Halt?

(And I don't see a Halt or Sleep, or Stop instruction in the ARM instruction set, so I'm not clear on how you halt it.)
It is a complete reboot.

Re: Wake from halt

Posted: Sat Jan 05, 2013 8:43 pm
by Ghostbird
I'm confused. I thought that to reboot the Pi, I'd simply create NC switch on the power supply. Pushing it would cycle the power and reboot the pi. What is the added value of this new method?

Re: Wake from halt

Posted: Sun Jan 06, 2013 6:42 am
by milhouse
Is there any possibility of Wake-on-USB support (eg. infrared input)?

I noticed there was a checkin for Wake-on-LAN some months ago, which distribution supports Wake-on-LAN?

Re: Wake from halt

Posted: Sun Jan 06, 2013 12:39 pm
by dom
milhouse wrote:Is there any possibility of Wake-on-USB support (eg. infrared input)?

I noticed there was a checkin for Wake-on-LAN some months ago, which distribution supports Wake-on-LAN?
No. USB driver is only on ARM side, and ARM isn't running after halt.
The WoL commit was just one of a collection of upstream smsc95xx kernel fixes that is not Pi specific.

Re: Wake from halt

Posted: Sun Jan 13, 2013 4:25 am
by Dweeber
Holidays were a blur... Finally got a chance to upgrade my test unit which is on a Adafruit Pi plate to a current kernel that has the new Halt code in it. I already had switches setup to test this with the pre-release before the code made it into the mainstream kernel.

Works like a champ.

Now using two switches (red and green) a couple resistors and a green LED, I am about to solder up some kits to allow me to upgrade my other units so that they have a Request Stop (Red) button, Restart Button (Green) and Green LED to show status of the OS (if OS is running) that I can then mount on the top of the cases I have for the other RPi.

I have a script which runs to watch for the Request Stop button, which when it sees it, tells the OS to do a shutdown.

All of my RPi are headless (no keyboard) so this will allow me to do a safe shutdown, see if it is already running and restart it if needed.

Re: Wake from halt

Posted: Sun Jan 13, 2013 8:11 am
by KenT
Kevin

This sounds very useful for my black box application. How do you drive the LED so that it is guaranteed to be on when not in halt state and off when in halt state?

Re: Wake from halt

Posted: Wed Feb 20, 2013 10:21 pm
by Wolfram23
Dweeber, hi. I'd love to know how you set this up? Is it possible to set up with a single button to do both (on/off, basically)?

I'm putting my Pi in my car. What I want to do is have the Pi powered by the +Batt, so constant power (note: using a 12V->5V Buck converter). Then use a relay on the ACC line, so that the relay closes when my car is powered on. The relay would then complete a GPIO circuit and that would be the wake call. Then when the relay turns off (car turned off), the Pi will watch for that and initiate the halt sequence. I have no problem with the Pi draining such a small amount of power when in halt state.

In the meantime, I'm going to try this out with buttons if I can figure out how. I've got some basic stuff working with the WiringPi library (LEDs come on and off, button even trigger) but I haven't done anything that sends commands to the Pi yet.