Olimex Support Forum

OLinuXino Android / Linux boards and System On Modules => iMX233 => Topic started by: Chris on February 08, 2015, 05:50:31 PM

Title: How to detect when a shutdown is completed and it's save to power off?
Post by: Chris on February 08, 2015, 05:50:31 PM
As already said in the subject:
How can I detect when a shutdown is completed and it's save to power off? I mean there's no visible information on the board itself, the power led is still on - is there any pin that provides the status "save to power off"?
Title: Re: How to detect when a shutdown is completed and it's save to power off?
Post by: MBR on February 09, 2015, 06:11:10 PM
I think that the easiest way is to use a LED configured as a heartbeat (see https://www.kernel.org/doc/Documentation/leds/leds-class.txt (https://www.kernel.org/doc/Documentation/leds/leds-class.txt)), so the LED will blink as long as the kernel itself is running. When the blinking stops, you can turn the power off.
Title: Re: How to detect when a shutdown is completed and it's save to power off?
Post by: Chris on February 11, 2015, 05:29:51 AM
This method seems not to be very save as user processes stop much earlier than the system shutdown is completed.
Title: Re: How to detect when a shutdown is completed and it's save to power off?
Post by: MBR on February 12, 2015, 01:11:28 PM
The heartbeat (implemented via the LED class) is not a user process, it's a kernel thread, so when you terminate and/or kill all user processes during the shutdown, the heartbeat will be still blinking until the time when the kernel displays "System halted", "Poweroff" or somethink like that.