A simple cape to prevent power-interrupt corruption?

I’ve read about capes that offer batteries to operate the BBB during power interruptions. I’ve read that there is a RTC in the SoC, but software does not support powering with a button cell. I see there is a PMIC onboard, as well as solder pads to allow attachment of a battery. I’ve also read that improperly powering-down the BBB can result in corrupt data/OS/eMMC/uSD.

My question: shouldn’t it be possible to add just a tiny Li Ion battery using the solder pads, and with minor modifications (in userland?) sense when 5v power has been removed (USB client or 5v barrel jack), and then initiate an orderly, but immediate, shutdown? The small battery would be enough for the few seconds until full power down, preventing any memory corruption.

This seems so simple I must be missing something. My goal is to be able to have my BBB project on a timer. Power will be applied/removed based on a rough schedule, an external RTC will provide correct time, and cron will be used to run what’s needed. When power is removed, the system would be properly stopped.

Yes it is possible.

Gerald

Is anyone aware of someone having already done this? I haven’t found anything by searching.

Have you seen this post and discussion?

Personally, I went the full cape route because it gave me more flexibililty for power-up events as well as a very low power (~80uA) power off state.

-Ron

Yes, I did find those. From what I read, it seems that both aim at allowing the BBB to run when there is no mains power. In my application, I don’t have a need for the BBB to maintain functionality when there is no power (other than battery). I’m simply interested in ensuring a safe shutdown sequence when power is removed. It seems from both posts that this has still not been addressed. These methods are focused on keeping the BBB running on battery power; however, when the battery discharges, I saw no discussion about an orderly shutdown occurring. I’m looking for an immediate, but orderly shutdown, and don’t care about sustaining operation (beyond a safe shutdown) when power is removed.

Actually, my initial desire for creating the cape was to have a battery-powered Linux node that could power on, perform some task, and then power itself back off and consume very little power in between. So, the cape will selectively power up the BB on a timeout, an external signal, button press, or DC power restoration. When the BB powers itself down and 3V3 goes away, the cape cuts all power to the BB and then waits for another event. While running, Linux can monitor DC power present and the battery voltage and current through an INA219 on the cape.

Everyone kept asking about a charging circuit and UPS functionality. So, I added that. The charger is a nice little part that does “dynamic power path management” and will augment the DC supply from the battery if necessary and charge the battery when excess DC current is available. The charger will always run when DC is present so you could plug a solar panel into the cape’s DC jack and now the node doesn’t require a battery change (I do plan on using that feature!).

So, for the shutdown, the cape itself doesn’t do anything since that’s a software issue. But since DC power status is reported through a status register over I2C, I used that in a bash script while toying with a “podcast car computer”. I haven’t spent much time on it but it definitely turns itself on and off with the car. I guess the other option would be a kernel module that monitors power good and initiates the shutdown…

-Ron

So perhaps all I’ll need is a small battery (recharged when DC power is available) attached to the pads on the BBB, and some software. I am looking for an orderly shutdown when DC power is removed - the sole purpose of the battery is to provide power just until the BBB can be shutdown properly. No need to be monitoring for a wakeup event (just power back on when DC power is restored). Can you point me to any examples of how to monitor the DC status (through I2C as you say below or any other way) and initiate the shutdown? Thanks.

So perhaps all I’ll need is a small battery (recharged when DC power is available) attached to the pads on the BBB, and some software. I am looking for an orderly shutdown when DC power is removed - the sole purpose of the battery is to provide power just until the BBB can be shutdown properly. No need to be monitoring for a wakeup event (just power back on when DC power is restored). Can you point me to any examples of how to monitor the DC status (through I2C as you say below or any other way) and initiate the shutdown? Thanks.

You need to consider corner cases as well. For example, what happens if the power restores during the shutdown process or what happens if the power dies before BBB is fully booted. This isn’t a trivial issue to resolve and I and others have written about this issue on this mailing list before. Ultimately, you need an external state machine to ensure reliable operations even when the unexpected occurs.

Regards,
John