0
\$\begingroup\$

I am not very experienced with Embedded Linux, just some projects with the Raspberry Pi.

I would like to know if there are any recommended ways to shutdown the Embedded Linux if the device's power is removed suddenly, or if common-practice is to just ignore it.

\$\endgroup\$
  • \$\begingroup\$ if power is removed, I don't see how you'd shut down, or do you mean if some external power is removed and you still have some time? In that case, you'd just have something that triggers a userland process to initiate the shutdown routine. \$\endgroup\$ – Marcus Müller Oct 4 '19 at 18:20
  • \$\begingroup\$ Yeah, something like that, like: "do people that implement Embedded Linux, on environments where power cab be (and usually is) just cut-off, make protections on the hardware to give the OS time to proper shut-down, like with super-caps, or don't they even care at all?" \$\endgroup\$ – mFeinstein Oct 4 '19 at 18:24
1
\$\begingroup\$

A journaling filesystem is less prone to corruption, so ext4 is used, still it is not 100% safe. By default in raspbian you have option flags in fstab, that upon power up, it does a filsystem check and repairs corrupted SD card.

Well there are lot of UPS boards, but many of them are useless, they just invoke sudo shutdown -h nowscript at detected power outage and the capacitors supply the board for few seconds. But if you reconnect the power before the capacitors are drained out, then the board won't start again automatically.

A good UPS has to have an additional MCU that handles the correct sequence. For example the Beaglebone has an standalone PMIC, but they never thought about to use it correctly. Most of these boards are stamped in millions copies, but they lack of very basic functionality, shutdown sequence.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ I see, so to be on the safe side of things the common practice is to use a PMIC + caps? \$\endgroup\$ – mFeinstein Oct 4 '19 at 18:47
  • \$\begingroup\$ A journaling file system is one thing, but if the storage device's internal, closed flash translation layer isn't safe against unexpected shutdown, neither a journal nor keeping the block device allegedly read only is necessarily enough to save things. Modern MLC flash SD cards are made to store vacation pictures with multiple bits crammed next to each other as analog levels that need to be occasionally maintained just from reading, it's not made to store root filesystems. \$\endgroup\$ – Chris Stratton Oct 4 '19 at 18:56
  • \$\begingroup\$ @mFeinstein There are some UPS boards, that use an Atmel or PIC MCU as PMIC. It is also essential that UPS has separate connection for power in and out, those UPS boards which use the same 5V pin and they have a bidirectional DC DC converter (for charging and draining caps) are useless, because after the shutdown the power has to be taken off. Not necessarily it has to be a PMIC with all bells and whistles, but also not a general DC DC converter IC. \$\endgroup\$ – Marko Buršič Oct 4 '19 at 19:11
  • \$\begingroup\$ @Chris yeah I read about it, but most production embedded Linux devices use EEPROM right? So this shouldn't be a problem? \$\endgroup\$ – mFeinstein Oct 4 '19 at 19:16
  • \$\begingroup\$ @mFeinstein um, flash memory is eeprom (it's just not called that), and yes, that is a problem, still. (a camera is an embedded system, you mean industrial embedded systems, and they tend to eMMC flash &similar technologies, often at higher price per GB, but that really doesn't help you with storage consistency in case of an unexpected poweroff – proper power management that gives your board a heads up before the lights go out is necessary. A raspberry pi isn't an industrial embedded device at all – the SoC is just a TV settop box SoC, and thus has none of the desirable hardware features.) \$\endgroup\$ – Marcus Müller Oct 4 '19 at 20:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.