Wake from halt


49 posts   Page 1 of 2   1, 2
by dom » Tue Dec 04, 2012 11:27 pm
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.
viewtopic.php?f=29&t=12007
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 4059
Joined: Wed Aug 17, 2011 7:41 pm
Location: Cambridge
by jojopi » Tue Dec 04, 2012 11:39 pm
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!
User avatar
Posts: 2122
Joined: Tue Oct 11, 2011 8:38 pm
by plugh » Wed Dec 05, 2012 9:28 pm
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'...
Posts: 24
Joined: Sun Dec 02, 2012 6:58 pm
by Dweeber » Thu Dec 06, 2012 12:57 am
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.
Dweeber A.K.A. Kevin...
My RPI Info Pages including Current Setup - http://rpi.tnet.com
User avatar
Posts: 606
Joined: Fri Aug 17, 2012 3:35 am
Location: Mesa, AZ
by rpdom » Thu Dec 06, 2012 5:36 am
Thanks dom, that's a very handy option to have.

I've added a "restart" push button to my Pi setup :-)
User avatar
Posts: 3931
Joined: Sun May 06, 2012 5:17 am
Location: Essex, UK
by dom » Thu Dec 06, 2012 4:59 pm
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).
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 4059
Joined: Wed Aug 17, 2011 7:41 pm
Location: Cambridge
by Dweeber » Thu Dec 06, 2012 7:29 pm
I gave this a shot and it works great.
Dweeber A.K.A. Kevin...
My RPI Info Pages including Current Setup - http://rpi.tnet.com
User avatar
Posts: 606
Joined: Fri Aug 17, 2012 3:35 am
Location: Mesa, AZ
by cbvicious » Tue Jan 01, 2013 10:26 am
I'm sorry to say I'm feeling painfully stupid. Can Someone post a picture of exactly how to wake from halt?
Posts: 2
Joined: Tue Jan 01, 2013 10:24 am
by sdjf » Tue Jan 01, 2013 1:11 pm
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?
FORUM TIP: To view just one person's posting history, sign in, click on their user name, then click on "Search User's Posts." || This Pi owner is running Arch on 512MB Model B.
Posts: 1303
Joined: Fri Mar 16, 2012 5:20 am
Location: California
by dom » Tue Jan 01, 2013 1:18 pm
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:
viewtopic.php?f=29&t=12007
(e.g by attaching a jumper, or for the more advanced by attaching some external circuitry)
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 4059
Joined: Wed Aug 17, 2011 7:41 pm
Location: Cambridge
by KenT » Tue Jan 01, 2013 3:31 pm
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-switch-for-your-rev-2-raspberry-pi It seems this can do a restart without recycling power.
Pi Presents - A toolkit to produce multi-media interactive displays for museums, visitor centres, and more
Download from http://pipresents.wordpress.com
Posts: 606
Joined: Tue Jan 24, 2012 9:30 am
Location: Hertfordshire, UK
by dom » Tue Jan 01, 2013 3:58 pm
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).
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 4059
Joined: Wed Aug 17, 2011 7:41 pm
Location: Cambridge
by ++bahjatk++ » Wed Jan 02, 2013 2:50 pm
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?)
Posts: 36
Joined: Sun Dec 30, 2012 10:02 am
by Burngate » Wed Jan 02, 2013 3:14 pm
++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.
Wyszkowski's Second Law: Anything can be made to work if you fiddle with it long enough.
Brain surgery is easier than psychoanalysis
User avatar
Posts: 2989
Joined: Thu Sep 29, 2011 4:34 pm
Location: Berkshire UK
by redhawk » Wed Jan 02, 2013 3:17 pm
Does the Pi have the capability for suspend / resume mode??

Richard S.
User avatar
Posts: 3519
Joined: Sun Mar 04, 2012 2:13 pm
Location: ::1
by cbvicious » Fri Jan 04, 2013 3:21 am
Is this functional in the latest RaspBMC?
Posts: 2
Joined: Tue Jan 01, 2013 10:24 am
by bgirardot » Fri Jan 04, 2013 6:17 am
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.
Posts: 517
Joined: Wed Oct 10, 2012 6:20 am
Location: Switzerland
by thrillscience » Fri Jan 04, 2013 6:29 pm
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.)
Posts: 2
Joined: Fri Jan 04, 2013 6:18 pm
by dom » Fri Jan 04, 2013 6:44 pm
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.
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 4059
Joined: Wed Aug 17, 2011 7:41 pm
Location: Cambridge
by Ghostbird » Sat Jan 05, 2013 8:43 pm
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?
Posts: 14
Joined: Thu Aug 16, 2012 1:06 pm
by milhouse » Sun Jan 06, 2013 6:42 am
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?
Posts: 555
Joined: Mon Jan 16, 2012 12:59 pm
by dom » Sun Jan 06, 2013 12:39 pm
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.
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 4059
Joined: Wed Aug 17, 2011 7:41 pm
Location: Cambridge
by Dweeber » Sun Jan 13, 2013 4:25 am
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.
Dweeber A.K.A. Kevin...
My RPI Info Pages including Current Setup - http://rpi.tnet.com
User avatar
Posts: 606
Joined: Fri Aug 17, 2012 3:35 am
Location: Mesa, AZ
by KenT » Sun Jan 13, 2013 8:11 am
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?
Pi Presents - A toolkit to produce multi-media interactive displays for museums, visitor centres, and more
Download from http://pipresents.wordpress.com
Posts: 606
Joined: Tue Jan 24, 2012 9:30 am
Location: Hertfordshire, UK
by Wolfram23 » Wed Feb 20, 2013 10:21 pm
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.
Posts: 73
Joined: Thu Jul 19, 2012 6:50 pm