Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Bootloader doesn't load application with watchdog

Hi,

I've recently enabled the watchdog in our project which included buttonless DFU. Project is based on FreeRTOS, SDK14.0, S132 v5.0.0 on custom board nRF52.

Since the bootloader is currently in a locked state and can't be modified, I set the watchdog timeout in the application to 5 minutes.

What I'm seeing right now is that upon DFU failure, the bootloader hangs just before launching the application on:

 

nrf_drv_clock_uninit();

Specifically on:

    while (nrf_clock_lf_is_running())

Which tells me that it can't turn off the LF clock since the watchdog is using that. Am I correct?
The device recovers after a watchdog reset.

Without the watchdog code, the bootloader works well.

My application settings are the following:

#define CLOCK_ENABLED 1
#define CLOCK_CONFIG_LF_SRC 1
#define CLOCK_CONFIG_IRQ_PRIORITY 7

main function flow:

    ret_code_t err_code = nrf_drv_clock_init();
    APP_ERROR_CHECK(err_code);
    nrf_drv_clock_lfclk_request(NULL);
    ...
	
	//Configure WDT.
	nrf_drv_wdt_config_t config = NRF_DRV_WDT_DEAFULT_CONFIG;
	
	err_code = nrf_drv_wdt_init(&config, wdt_event_handler);
	APP_ERROR_CHECK(err_code);
	err_code = nrf_drv_wdt_channel_alloc(&m_channel_id);
	APP_ERROR_CHECK(err_code);
	nrf_drv_wdt_enable();
	...
	//init GPIO
	...
	//init SD & Freertos

Like in the WDT example.
Bootloader's settings are 

#define CLOCK_ENABLED 1
#define CLOCK_CONFIG_LF_SRC 1
#define CLOCK_CONFIG_IRQ_PRIORITY 7

and nothing else has changed regarding the clocks and watchdog.

What could be the reason for the failure? Can I integrate the watchdog at this stage?

Thanks.

Parents
  • Hi,

    The bootloader implementation attempts to clean up everything before booting the app. The reason for doing this is to ensure that the app boots into the same state as it would if you didn't have a bootloader present.  This could be useful if you had an app that didn't use the LF clock source. Although, most applications uses it.

    The WDT will automatically request the LF clock as you said, and I'm afraid the only solution apart from not using WDT is to remove clock uninit from the bootloader code. 

Reply
  • Hi,

    The bootloader implementation attempts to clean up everything before booting the app. The reason for doing this is to ensure that the app boots into the same state as it would if you didn't have a bootloader present.  This could be useful if you had an app that didn't use the LF clock source. Although, most applications uses it.

    The WDT will automatically request the LF clock as you said, and I'm afraid the only solution apart from not using WDT is to remove clock uninit from the bootloader code. 

Children
Related