nRF52840 Boot Time Optimization in NCS

Hi everyone,

I'm experiencing an unexpectedly long boot time on my nRF52840 device using NCS v3.2.0. Could you help me verify if this boot time is normal, or suggest any possible causes?

Setup:

  • Platform: nRF52840
  • SDK: NCS v3.2.0
  • Code Base: peripheral_hids_keyboard (with custom modifications)
  • Board Configuration: Custom board, currently without bootloader

What I did:
To measure boot time, I added timing signal logs at different stages of the boot process. Here are my results:

EARLY
                ~4.8ms
PRE_KERNEL_1
                434ms <-- take long time on here
PRE_KERNEL_2
                76us
POST_KERNEL
                459us
main thread

The code I used for the measurement is as follows:

int prek1_marker(const struct device *dev) {
    gpio_pin_configure(GPIO1_DEV, 2, GPIO_OUTPUT);
    gpio_pin_set(GPIO1_DEV, 2, 1);
    return 0;
}
SYS_INIT(prek1_marker, PRE_KERNEL_1, 0);

int prek2_marker(const struct device *dev) {
    gpio_pin_set(GPIO1_DEV, 2, 0);
    return 0;
}
SYS_INIT(prek2_marker, PRE_KERNEL_2, 0);

int postk_marker(const struct device *dev) {
    gpio_pin_set(GPIO1_DEV, 2, 1);
    return 0;
}
SYS_INIT(postk_marker, POST_KERNEL, 0);

int main(void)
{
    gpio_pin_set(GPIO1_DEV, 2, 0);
    // ...
}

If anyone has experience with boot timing on nRF52840 or suggestions on what could cause the delay at PRE_KERNEL_1, your input would be greatly appreciated. Thank you!

Related