A tool to measure how long a Raspberry Pi spends in the bootloader.
$ make
$ sudo ./bootloader_time
SoC uptime: 954.480248s
Linux uptime: 947.800000s
Time spent in bootloader: 6.680248s
The Broadcom SoCs used on Raspberry Pis have a system timer peripheral which starts counting on power up. If we subtract the Linux uptime from this, then it gives us the amount of time spent in the bootloader.
This should work on all Raspberry Pis. All Raspberry Pi SoCs have the system timer peripheral at the same offset from the peripheral base address. The peripheral base address is found dynamically through bcm_host_get_peripheral_address()
.
MIT