As some of you remember the prior versions of the Raspberry Pi were a bit sensitive to power cuts, many SD cards were corrupted in the early days of the Pi. What likely made this worse was a lack of good USB power supplies (or the prevalence of really bad ones!). A lot of power supplies don't seem to meet the USB 5v power specification when loaded up. They are fine for charging phones, but not good for powering a Pi. I needed reliable power and battery backup so I proceeded to design and manufacture my own UPS for the Pi. You can see it here: http://www.allspectrum.com/mopower/
Was this a hardware problem? Something in software? Firmware? Maybe a combination? I don't know. I have not seen a good solid answer as of yet. But thinking of this one day, I figured why not give the new Pi and software a good torture test!?! The UPS I built to protect the Pi can just as easily be turned against it!
The UPS controls power to the Pi and normally turns it off when the Pi signals a properly shut down operating system. A few quick software changes and the UPS can cut power immediately without a proper shutdown! With that setup, on April 15th a bit past midnight the power cut torture test began! The UPS was setup with an interrupt timer to power up the Pi every minute, the Pi would boot in about 20 seconds or so and hit an external web server to signal that it successfully started up. Then 15 seconds into a successful startup the Pi would have it's power deliberately cut. The Pi would startup (hopefully!) and have it's power cut each and every minute until something went wrong!
So what happened? Well it has been about 3 weeks since the test began, and it's pretty amazing.. the Pi is STILL BOOTING UP SUCESSFULLY!!! Wow, I didn't not expect this result!
So how many times has this successful boot and powercut occurred? Lets grep the logfile on the external web server.. so as of right now..
# grep -A10000000 "15/Apr/2017:00:31:19" /var/log/httpd/access_log | grep cuttest01 | wc -l
25002
#
Yes, you are reading that right. 25,002 times!!! And the test is still ongoing, one attempt every minute!
So what's next? Well in this test, I did not deliberately write anything to the SD card. This has long been thought of as the cause of the corruption in SD cards, an interrupted write. So the next setup will include some sort of heavy writing to the SD card during the power cut. Maybe a dd to a file somewhere. One of my theories is that the power design of the SD card circuitry changed in the Pi.. possibly with some added capacitors.. to where the SD card had just enough power during a failure to successfully write the last bit of data that came from the SOC.
Did it ever fail to boot? Actually yes, but I have yet to find out why exactly. There were 10 failures to boot, they were spaced very evenly throughout the testing and subsequent boot-ups were successful. A few were unknown with no screen output, but most appeared to be kernel panics of some sort. All in all not bad, a 1 in 2,500 chance of a boot failure is not bad at all. Is the card or OS 100% free of corruption? I do not know, but when I pull it out I can do a checksum test on all the files and compare it to the original. What I do know is that it was good enough to successfully boot up.
Some more details on the setup. The Pi is a model 3 with what I believe is an 8GB unknown manufacture card that came with a noobs bundle on one of my older setups. Installed OS is 2017-04-10-raspbian-jessie-lite with no updates. Connected are an Ethernet cable, HDMI cable/monitor and of course the UPS.
Tell me what you think! Maybe you have some ideas for the next test? And if you are interested in the MoPower UPS, I would appreciate your support of my efforts, you can buy it here:
http://www.allspectrum.com/mopower/
Thanks everyone!
Regards,
-Moses