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

freertos with wdt reset problem, nrfjprog

Hello

my setup is a nrf52840, the sdk15.3, Softdevice s140.

I'm running an application with freertos and wdt and have the openbootloader and s140 also flashed.

- if in freertos the wdt is disabled and i set the GPREGRET register and make a reset with NVIC_SystemReset, i have to make a reset from outside by nrfjprog -r over jlink and then the dfu device comes up...

- and after update the device over dfu it has to be reset by nrfjprog -r and it resetarts in application as wanted

- If the wdt is enabled and do the same, set the GPREGRET register and make a reset with NVIC_SystemReset, the device restarts in application....

How can i make a reset or restart similar to nrfjprog -r from software so that no jlink is needed ?

Thanks in advance

twittich

Parents
  • Hello Twittich,

    The WD timer is not reset through a NVIC_SystemReset (Reset behavior) so it will keep running on subsequent startup when the program enters DFU mode inside the bootloader.  The bootloader feeds the WD by default for this reason. But you may need to adjust the reload interval if you have a short timeout, see NRF_BL_WDT_MAX_SCHEDULER_LATENCY_MS in the bootloader's sdk_config.h file. 

  • Hello

    Thank you. This i tested already but it's still the same. While debugging the bootloader at the function

    static bool dfu_enter_check(void)

    it's not entering in the following

       if (NRF_BL_DFU_ENTER_METHOD_GPREGRET &&
           (nrf_power_gpregret_get() & BOOTLOADER_DFU_START))
        {
            NRF_LOG_DEBUG("DFU mode requested via GPREGRET.");
            return true;
        }

    the problem is at

    nrf_power_gpregret_get()

    i'm not getting 0xb1 .  If I set this hardcoded to 0xb1 it's starting in dfu mode.....

    But in the application i'm setting it and then make a reset.

    Can I use the sd functions ?

    sd_power_gpregret_set(0,0xB1);
    sd_nvic_SystemReset();

    Or use the GPREGRET2 and change that in the application and bootloader ?

    And regarding the reset of the device after the dfu and update, any idea ?

    Thank you for any help....

    twittich

  • Have seen only that it was in the loop but not that it restarted...

    Where could i place a reset or change to the application any idea?

  • There has to be a difference if in debug mode. The behavior of the timers is quite different.

    If i start a timer with 30 seconds, in function " nrf_bootloader_init() " after "  if (dfu_enter) ". And the callback includes a bool to stop feed the wdt and nvic system reset....  it works, but if run normal it stays in bootloader ?!

  • twittich said:
    If i start a timer with 30 seconds, in function " nrf_bootloader_init() " after "  if (dfu_enter) ". And the callback includes a bool to stop feed the wdt and nvic system reset....  it works, but if run normal it stays in bootloader ?!

    Could you replace the nvic systemreset with a loop that reloads the WD forever, then use the --readregs command to see if the program enters this callback when you're not in debug mode?

    e.g.,

    timer_callback()

    {

        for (;;) {//TODO:feed WD}

    }

      

      

  • I changed the order of initialisation of the timer. In the timer tutorial it's written that first start internal osci, then init app timer and then create and start ..Now my own inactivity timer works and the NRF_BL_DFU_INACTIVITY_TIMEOUT_MS is set to zero. Maybe in the bootloader this order has to be fixed...

    But if i start an update process and the timer times out the device resets and goes to application. Where do i have to stop or/and restart the timer ?

  • The default implementation of the inactivity timer works for me here, but yes, the RTC won't run if you haven't started the LF clock first. That is why nrf_bootloader_dfu_timers.c->timer_init() triggers the LF clock start task. The LF clock is automatically started when the chip goes into debug interface mode so it may explain why the timer only expired when you were debugging.

    The only issue I see here is that we're not reloading WD channel 7. I will report that as a bug internally. 

Reply
  • The default implementation of the inactivity timer works for me here, but yes, the RTC won't run if you haven't started the LF clock first. That is why nrf_bootloader_dfu_timers.c->timer_init() triggers the LF clock start task. The LF clock is automatically started when the chip goes into debug interface mode so it may explain why the timer only expired when you were debugging.

    The only issue I see here is that we're not reloading WD channel 7. I will report that as a bug internally. 

Children
Related