sd_softdevice_disable() not returning during transport shutdown in DFU Bootloader

My setup of the buttonless BLE DFU secure bootloader using SDK15.2 isn't launching the application after a successful OTA package transfer. Using RTT and breakpoints, I narrowed down the issue to sd_softdevice_disable() inside nrf_sdh_disable_request(). The bootloader code execution disappears inside the SVCALL to disable the softdevice. What could be causing this behavior?

I'm finding it really difficult to narrow down the cause. My bootloader implementation matches almost identically with the examples except for: using bonds, buttonless DFU service, VS_UUUID_COUNT set to 2, RTT ON and in the same RAM section as the application, flash start/size for the bootloader, using the RC clock source. I set the RAM start and size to:

So the program does not return from sd_softdevice_disable()? I haven't experienced that before. Can you read out the Core registers while the code is "stuck"? You can do this with the --readregs command in nrfjprog. E.g., nrfjprog --readregs. I would be happy to try debugging it here as well if you are able to share your project.

nrf_sdh_disable_request() never returns and the system current draw stays around 2.4mA until the watchdog resets the nRF52.

* Power up reset* Start SD and do some measurements* Begin sleep mode (disables the SD)* Wake on GPIOTE event* Start SD and do some measurements* Begin sleep mode (disables the SD) disabling the SD never returns.

The first disable functions just fine, the one after the soft reset hangs.After a watchdog reset I can repeat the procedure.

I'm probably going to work around the issue by using a GPIOTE+RTC based wake and resetting the nRF52 using the WD timer.The WD timer seem to be slightly cheaper (on avg.) than using the RTC, but since it isn't possible to disable the WD using a software reset I'm probably going that way.

Hi Visti, I assume you are using the clock driver? In that case it's important to note that the driver will attempt to release the LF clock source when the NRF_SDH_EVT_STATE_DISABLED event is raised by nrf_sdh_disable_request(), this is not possible to do when WDT is enabled. The program will therefore become stuck in the while (nrf_clock_lf_is_running()){} loop. You can call nrf_drv_clock_lfclk_request(NULL) after softdevice enable to keep the LF clock on.