-
Notifications
You must be signed in to change notification settings - Fork 11
Raspberry Pi Startup or how long can we pull the plug?
The boot process of the RPi has been explained quite well in this blog article Fast Boot with the Raspberry Pi.
- Hardware and Bootloader (minimum 1.5-2 seconds)
- Kernel (minimum of 0.6 seconds)
- Userspace (minimum of 0.8 seconds)
This is the absolute minimum we can get down to if we tweak the boot process and even recompiling the kernel, meaning that with such a modified system we could get boot times of around 3.5-4 seconds and the first access to the file system after around 2.8 seconds.
If we are looking at normal boot times then you get to between 15-30s for a full boot of a normal Raspbian system, depending on the hardware and the type of RPi.
To verify these times and to get a better understanding of how you system boots you can use the tool systemd-analyze. It provides a graphical representation of the boot process and can in addition show critical paths.
If we want to turn off the power when an RPi has already started to run then we can do this safely only as long as the RPi hasn't started to write to the storage, i.e. as long as the SD card or disk has not been mounted R/W. We can safely assume this to be the case until the kernel has fully started, meaning that we have a safe window for this for the first 2 seconds.
This means that if the ATTiny can determine in the first 2 seconds after it has started (or has been reset) that the battery is below the shutdown level, then it can safely turn off the system without the risk of damaging the storage system.
Since the ATTiny Daemon tries to read the voltages as the first thing after the startup when commencing its normal operation (i.e., the loop()-function) it needs less than a second to determine whether the battery value is below the shutdown level, so it is safe to pull the plug even with a system optimized for a short boot time.