This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Secure bootloader timeout not working on S132 15.3 SDK with logging disabled

I am running into a strange issue. I want the bootloader to start automatically when I power on the device and then start the application if there is no activity after 30 seconds. 

To do that I've done the following changes:
1. Change NRF_BL_DFU_INACTIVITY_TIMEOUT_MS to 30000 in sdk config
2. Change dfu_enter_check in nrf_bootloader.c to always return true
3. Change inactivity_timeout in nrf_bootloader.c to do "nrf_bootloader_app_start();" instead of "bootloader_reset(true);" if the app is valid. but for tests i also made it just jump in without the check 

But it never launches the app and I'm not sure the timer is even hit or expires. 

Now here is the weird part, with the pca10040_ble_debug project, this all works as expected. I then made the change where I enabled NRF_LOGGING_ENABLED with Segger RTT in the non-debug version. I had to also expand the flash size for these changes. When logging is enabled, then it all works as expected again!

I should add that I checked the debug version's public key to match my non-debug public key, so they are the same and the app I'm loading over OTA works on both versions. If I remove my forced true from dfu_enter_check in the non-debug version, it launches the app just fine.

Why is this happening? What is special about logging that would make this timeout work but not without it? I'm stuck at this point but would prefer not to release a larger bootloader with logging if I don't have to. I can't debug the version that's failing, and the debug version is working fine Disappointed

Thank you in advance for any suggestions.

  • One possible problem might be code with side effects inside an NRF_LOG_xxx statement - this would be eliminated in the release build.

    You CAN debug release code by turning on debugging symbols.The optimizer will shuffle the code around quite a bit, but GDB is still somewhat usable. Oh, and being able to read the disassembly helps a lot.

    Just remember to put breakpoints before you enable and after you disabled the softdevice, as a running SD must not be halted.

  • Thank you for this information. I switched to use Segger Studio and was able to debug a bit easier. I think the problem I'm running into is that when I try to do 'nrf_bootloader_app_start();' inside the activity timeout handler, after dfu_check already returned true, that it does not jump to the application code properly and encounters some errors. However I can't seem to hit breakpoints within the code that does that. 

    I'm still stuck but hopefully will figure this out. I'm surprised starting bootloader on power up then timing out to the app isn't a more common use case. I really did not expect this to be so difficult.

  • I've solved this by checking the NRF_POWER->RESETREAS register in dfu_check. If it's 0 it means it work up from total system off and I'll start the bootloader. For anything else I'd want application to start, which includes the reset issued by the bootloader after its inactivity timeout.

Related