Manawyrm Digs Deep Into Raspberry Pi Power Optimization to Slash the Boot Time to Just 3.5 Seconds
From turning off unnecessary peripherals to compiling a custom kernel, Manawyrm delivers a masterclass in power optimization.
Pseudonymous maker "Manawyrm" has been working on getting the most out of a solar-powered Raspberry Pi Zero 2 W — by optimizing its boot time down to just 3.5 seconds, minimizing wasted power during startup.
"A while ago, the SolarCamPi project, a off-grid solar-powered Wi-Fi camera, was built," Manawyrm explains. "In this project, a Raspberry Pi Zero 2 W is being booted into Linux, a picture is taken, Wi-Fi connectivity is established and the Pi is shut down again (to save power). This repeats every couple of minutes to always deliver a fresh image to a cloud service. Each second the Pi Zero is powered up uses valuable electricity, which is a scarce resource in a solar-powered device (at least in West European winters…)"
The SolarCamPi project was already heavily optimized in a variety of ways, from tweaking the software to ensure the process of uploading the picture to the remove server required as little time as possible to shutting the Raspberry Pi Zero 2 W single-board computer down when images aren't being captured — leaving only one real area for further improvement: the time spent waking the Raspberry Pi up from its slumber to capture the picture.
Using a Nordic Semiconductor Power Profile Kit II and a USB-SD-Mux — - "it's an interposer between a microSD Card and a DUT [Device Under Test] with a USB-C interface [so] a computer can 'steal' the microSD Card from the DUT, rewrite its contents and then plug the microSD card back into the DUT, without ever having to touch the device" — Manawyrm set about trying out a various things to speed the from-cold power draw and overall boot time of a Debian 12 "Bookworm" image.
At stock settings, the system took around 12 seconds to boot — drawing a total of 1.9 Amp-seconds (As) of energy. Disabling the Raspberry Pi's HDMI output, activity and camera LEDs, lowered this to 1.62As — and disabling the "force_turbo" setting in the boot config lowered that still further to 1.58As. Further gains were found by disabling EDID probing, given the HDMI output was already disabled, disabling probing for the EEPROM on Hardware Attached on Top (HAT) accessories, LCD displays, and cameras other than the one specific camera used in the build, dropping the boot time to 4.75s.
"At this point, loading the kernel is one of the slowest operations," Manawyrm found. "This load is being done by the GPU (!) with the internal, proprietary [Broadcom] VideoCore-IV processor. It’s possible that the loader code is just inefficient and slow, it’s also possible that it is using very conservative settings." Overclocking the GPU improved the load times by 20 per cent, after which Manawrym set about using Buildroot to create a custom kernel with as many features disabled as possible — and storing it uncompressed, trading a longer load time for an energy saving now it no longer needs to be decompressed.
With all of those changes, the Raspberry Pi Zero 2 W booted to user-code in just 3.5 seconds, drawing 0.364As in the process — while dropping the power input down to 3.6V, from the stock 5V, reduced the energy draw still further, taking the project from 1.82 Watt-seconds (Ws) at 5V to 1.438Ws at 3.6V. "We just decreased the energy consumption by another 20%, just by operating the switch-mode-regulators at a more ideal operating point," Manawyrm explains. "This requires further testing for stability/reliability of course (as it’s technically out-of-spec), but this is a very impressive result."
The full project write-up, including a work-in-progress Buildroot tree and a Raspberry Pi configuration file, is available on KittenLabs.
Freelance journalist, technical author, hacker, tinkerer, erstwhile sysadmin. For hire: freelance@halfacree.co.uk.