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

Bootloader with WDT and App_time

Hello:

I am working on a USB bootloader where I have enabled the WDT on entry. After I enable the WDT, the app_timer is set to feed the WDT and to also signal the end of waiting for USB input for a DFU.  When I enable the WDT, neither of the app_timers will not fire and the WDT eventually resets the device.  Our bootloader is set up to go to DFU if the previous processor start was caused by a WDT - the bootloader cycles forever issuing a WDT, going to DFU, issuing a WDT, ...   Is there a solution for this?  I want to leave the WDT enabled but cannot if the app_timer is disabled.

Thanks,

Joer55

  • When I enable the WDT, neither of the app_timers will not fire

    Why is that? Sounds like a bug to me...

  • Hello,

    To confirm I understand this correctly, do the timers run fine as long as you don't enable the WD? WDT will force on the LF RC oscillator if no other LF clock sources are running, so this would have been easier to explain had the app timer not worked when the  WDT was disabled.

    Also, a few more follow up questions:1. are you using the existing "nrf_bootloader_wdt_init()" implementation from the SDK bootloader to start off the reload timer, and is the WDT started before this function call in that case? 2. Does the bootloader at any point try to stop the LF clock while it's being forced on by the WDT? 3. Does DFU work with WDT if you just increase the WD timeout enough?

    Thanks,

    Vidar 

  • Hi Vidar:

    Thanks for your response. 

    - Yes, the app_timer works fine if I do not enable the WDT.  I am enabling the WDT 1st, then the other 2 app_timers following this.

    - I am using SDK 15.0.0 (yes, we do plan to update at some point).

    1) Yes, I am using the existing nrf_bootloader_wdt_init() function (called from the nrf_bootloader_init() function in nrf_bootloader.c).  The WDT is initialized prior to calling this function (using nrfx_wdt_init() / nrfx_wdt_channel_alloc() / nrf_wrt_enable() ) 

    2) I don't believe the bootloader tries to stop the LF clock. My code does not touch the LF clock.

    3) The DFU works successfully (with my current 90 second Watchdog timeout or longer if I program it). I am able to upload a new FW and it successfully launches.  If I do not start uploading a new FW and let the timer run out, the WDT triggers (and not the app_timer that is set for a smaller time duration).  I need the app_timer to trigger before the WDT if possible.

    Thanks Again,
    Joer55

  • Hi,

    Thank you for confirming. I am afraid I need some more time to investigate this on my side.  I have not been able to replicate this with our USB bootloader in SDK 15.0.0 yet. The app timer starts as expected after I modified the bootloader to activate the WDT upon entering DFU mode, even after Soft resets triggered by the Bootloader timeout handler. However, I experience the problem you describe if I use the code posted a few days ago by  instead: https://devzone.nordicsemi.com/f/nordic-q-a/65361/rtc-stops-running-after-soft-reset-with-wdt-enabled. It makes me think it may be timing-related somehow.

    Starting WDT in nrf_bootloader.c:

    static void wdt_start()
    {
        NRF_WDT->CRV = 32768 * 3;
        NRF_WDT->TASKS_START = 1;
    }
    
    
    ret_code_t nrf_bootloader_init(nrf_dfu_observer_t observer)
    {
       ...
       if (dfu_enter)
       {
            wdt_start();
            nrf_bootloader_wdt_init();
    
            scheduler_init();
            ...

    I will ask around to see if there may be a logical explanation for this behavior.

    Best regards,

    Vidar

  • Hi,

    Could you check if your bootloader executes the LF clock start task by calling nrf_clock_task_trigger(NRF_CLOCK_TASK_LFCLKSTART); in timer_init()? As you can see from my update in the other thread I linked to, the RTC will not run unless the app executes LF clock start task.

    Thanks,

    Vidar

Related