I'm using an edison and mini-breakout board.
I want the user to be able to simply turn our device on and off, but Linux must shutdown safely, closing files, etc.
So the Edison would have to detect the power off. Then do a shutdown. It would have a battery or super cap providing power till the shutdown was complete.
The power draw on the backup battery when shut off should be minimal so it lasts at least a month or so.
Has anyone solved this problem?
You should be able to redefine the program that handles the power button.
But my approach would be to have a circuit with a small Atmel's microcontroller that handles the power button and turns on and off the power to the Edison module, also sending the shutdown request to the Edison. It should sleep all time and only wake up when the button is pressed.
I think this interesting chip does what you want.
LTC2954 sends an interrupt to a microprocessor when a turn on/off button is pressed.
http://www.linear.com/product/LTC2954 Linear Technology - Product Page
INT (Pin 5/Pin 8):
Open Drain Interrupt Output. After a pushbutton turn-off event is detected (tDB,OFF), the LTC2954 interrupts the system (μP) by asserting the INT pin low. The μP would perform power-down and housekeeping tasks and then assert the KILL pin low, thus releasing the enable output.
Thanks for this. It is interesting. Maybe i can use it, but not as illustrated above. The situation is the power will be cut, and i need to go on to a reserve battery until it can shutdown. So there's no possibility for a push button switch.
I'm trying to avoid the expense of building and testing my own circuit. Still looking for something off the shelf, or just using what's already built on the Edison or mini-breakout. Maybe i just have to bite the bullet and make the circuit.
Have you checked if the PMIC of the Edison could work for your goals? take a look at the http://download.intel.com/support/edison/sb/edisonmodule_hg_331189004.pdf Hardware Guide of the Compute Module, (Section 3.5 and Section 5)
You can connect your battery/supercapacitor to the battery connector. There is a program that was posted on the forum that shows the charge of a connected battery. In your daemon, you can measure the charge every minute or so. If the battery discharges too quickly or the level is below some value, you can run the poweroff command.
We worked out something like this:
When the main power goes off, the OnMainPower GPIO goes low, which is monitored by our program which starts to close files and shutdown. When the CPU halts RESET_OUT is supposed to go low, which will turn of the FET finally, and save the reserve battery. When the main comes on again, RESET_OUT goes high again, and the reserve battery can be charged as per normal. I'll let you know if it works when we're done :-)