pleriche
Posts: 90
Joined: Mon Oct 14, 2013 8:44 am

Shutdown button

Sun Jan 03, 2016 3:10 pm

A shutdown button for an embedded application is very easy to do, but what's harder is how to indicate to a non-technical operator when it's safe to pull the plug.

In the script triggered by the shutdown button I could set a GPIO pin to output and write "1" to it. I could use that output to flash a warning LED until it went to zero on completion of shutdown. But when I try it, the ACT light (on a Pi Zero) continues to flash regularly for several seconds after the GPIO goes to zero. (I'm using Raspbian, if that's relevant.)

I've noticed similarly on the Model B that the ACT light flashes regularly for several seconds at the end of the shutdown sequence.

Can anyone enlighten me as to what it's doing during those final flashes? Is it indeed writing to the SDCard, making it dangerous to pull the plug at that time? Is there another way of determining when the shutdown really has completed?

Regards - Philip

DirkS
Posts: 10345
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: Shutdown button

Sun Jan 03, 2016 3:14 pm

The ACT led blinking is actually indicating that shutdown has finished.
See viewtopic.php?f=28&t=58151, section 'Shutdown procedure'

klricks
Posts: 7123
Joined: Sat Jan 12, 2013 3:01 am
Location: Grants Pass, OR, USA
Contact: Website

Re: Shutdown button

Mon Jan 04, 2016 12:14 am

I always wait for the 10 flashes to complete before pulling the plug. There is of course code still running to make the LED flash but don't know how benign that code is?
Unless specified otherwise my response is based on the latest and fully updated RPiOS Buster w/ Desktop OS.

User avatar
davidcoton
Posts: 4883
Joined: Mon Sep 01, 2014 2:37 pm
Location: Cambridge, UK
Contact: Website

Re: Shutdown button

Mon Jan 04, 2016 12:36 am

Code running and toggling an LED doesn't matter. It's writing to the SDCard (or hard disks, etc) when the power goes that causes a problem. I assume (very dangerous) that any writes (including any buffer flushing) should have finished by the time the flashing stops.
Signature retired

Return to “Advanced users”