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

WatchDog feeding from bootloader to application and softdevice

Hi,

We have the following problem when start the watchdog from bootloader: the application is started successfully by the bootloader but when enable the softdevice the application gets stuck. The last call we can track (where the application is blocked) is nrf_sdh_enable_request().

Our booloader implementation only start watchdog and application (no signature validation or dfu).

Note that if the watchdog is not enabled the softdevice is started successfully.

Bootloader code:
#define WATCHDOG_COUNTER        30 * 32768 
void init_watchdog() {     
  NRF_WDT->CONFIG = (WDT_CONFIG_SLEEP_Run << WDT_CONFIG_SLEEP_Pos);     
  NRF_WDT->CRV = WATCHDOG_COUNTER;     
  NRF_WDT-> RR [0] = 0x6E524635UL;     
  NRF_WDT->RREN = WDT_RREN_RR0_Enabled << WDT_RREN_RR0_Pos;     
  NRF_WDT->TASKS_START = 1; 
}
....
main()
{
    init_watchdog();
    nrf_bootloader_app_start();
}

The question is how can we make the watchdog started in bootloader can be feed it application without stopping it to start the softdevice?

Thanks,

  Catalin

Parents
  • Hi,

    The problem here is most likely that you have a too short WDT timeout. nrf_sdh_enable_request() calls sd_softdevice_enable() internally, which can take quite some time as it will block until the 32 kHz clock is started, so you need to account for that if you start the watchdog before the call to nrf_sdh_enable_request(). As you can see from the nRF52840 CLOCK electrical specification, the (optional) 32 kHz xtal oscillator startup time alone is typically 0.25 s (tSTART_LFXO).

  • Hi,

     As you can see in the code, the timeout is set to 30 seconds. We measured that after this timeout the board is rebooted.

  • Ah yes, I did not spot that in your code snippet. It seems strange to me, then. I have not been successful in reproducing this issue on my side.

    I simply copied in your init_watchdog() function and called it in the beginning of main() in the debug bootloader for SDK 15 (\examples\dfu\secure_bootloader\pca10040_ble_debug). Then I used the pre-compiled application  ble_app_buttonless_dfu_without_bonds_s132_with_setting_page.hex from the SDK distribution. I can see from the RTT log and LED's that the application starts as expected and starts advertising before it is reset every 30 seconds (due to not feeding the watchdog). So everything seems OK in this test.

    Can you tell me more about what you are doing, or (even better) upload a bootloader and application that demonstrate this issue? Also, do you have a 32 kHz xtal on your board (not that I think it should mater)?

Reply
  • Ah yes, I did not spot that in your code snippet. It seems strange to me, then. I have not been successful in reproducing this issue on my side.

    I simply copied in your init_watchdog() function and called it in the beginning of main() in the debug bootloader for SDK 15 (\examples\dfu\secure_bootloader\pca10040_ble_debug). Then I used the pre-compiled application  ble_app_buttonless_dfu_without_bonds_s132_with_setting_page.hex from the SDK distribution. I can see from the RTT log and LED's that the application starts as expected and starts advertising before it is reset every 30 seconds (due to not feeding the watchdog). So everything seems OK in this test.

    Can you tell me more about what you are doing, or (even better) upload a bootloader and application that demonstrate this issue? Also, do you have a 32 kHz xtal on your board (not that I think it should mater)?

Children
Related