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

How to use the watchdog when DFU

Hi

I opened the Watchdog in the user application,and do nothing in the bootloader.Then when I use DFU,the CPU reset appears.How can I to deal with it?

And when I upgrade willful termination APP(nRF Toolbox),the CPU(nRF52832)is down,and can't work.Do you have any suggestions on how to solve this fault tolerance?

Thank you!

Parents Reply Children
  • The Secure Bootloader in SDK v15.2.0 handles this automatically. It will check if the WDT is enabled, if yes, then the bootloader will feed the WDT periodically so that it does not time out. 

    So you dont have to add any code that feeds the WDT in the bootloader as this is already included. 

    Best regards

    Bjørn

  • Ok. thanks.

    Actually I was getting an issue while dfu. when nrf set to boot mode it resets due to WDT and app started working normally as I have set WDT reload value to 3000.

    after I have changed it to 60000( 60 sec ), all works fine yeserday. I have set nrf to boot mode then completed dfu process and app updated.

    Can you please explain the reason?

  • The bootloader should feed the WDT in an infinite loop, see

    /**@brief Continually sleep and process tasks whenever woken.
     */
    static void loop_forever(void)
    {
        while (true)
        {
            //feed the watchdog if enabled.
            nrf_bootloader_wdt_feed();
    
            app_sched_execute();
    
            if (!NRF_LOG_PROCESS())
            {
                wait_for_event();
            }
        }
    }

    as well as start a timer that feeds the WDT periodically

    void nrf_bootloader_wdt_init(void)
    {
        static bool initialized = false;
    
        if (initialized)
        {
            return;
        }
    
        if (nrf_wdt_started())
        {
            uint32_t wdt_ticks = nrf_wdt_reload_value_get();
    
            NRF_LOG_INFO("WDT enabled CRV:%d ticks", wdt_ticks);
    
            //wdt_ticks must be reduced to feed the watchdog before the timeout.
            uint32_t reduced_timeout_ticks = MAX((int32_t)wdt_ticks - MAX_FLASH_OP_TIME_TICKS,
                                                 NRF_BOOTLOADER_MIN_TIMEOUT_TICKS);
    
            /* initial watchdog feed */
            wdt_feed();
    
            NRF_LOG_INFO("Starting a timer (%d ticks) for feeding watchdog.", reduced_timeout_ticks);
            nrf_bootloader_wdt_feed_timer_start(reduced_timeout_ticks, wdt_feed_timer_handler);
    
            NVIC_EnableIRQ(WDT_IRQn);
        }
        else
        {
            NRF_LOG_INFO("WDT is not enabled");
        }
    
        initialized = true;
    }
    
    static void wdt_feed_timer_handler(void)
    {
        NRF_LOG_INFO("Internal feed");
        wdt_feed();
    }

    Can you debug the bootloader when the WDT interval is set to 3seconds and check that you enter the wdt_feed_timer_handler()?

  • yes I'll check.

    today I have checked with different WDT reload values. It's working fine with 15000 but not below than that.

Related