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

    Fullscreen
    1
    static bool dfu_enter_check(void)
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    it's not entering in the following

    Fullscreen
    1
    2
    3
    4
    5
    6
    if (NRF_BL_DFU_ENTER_METHOD_GPREGRET &&
    (nrf_power_gpregret_get() & BOOTLOADER_DFU_START))
    {
    NRF_LOG_DEBUG("DFU mode requested via GPREGRET.");
    return true;
    }
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    the problem is at

    Fullscreen
    1
    nrf_power_gpregret_get()
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    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 ?

    Fullscreen
    1
    2
    sd_power_gpregret_set(0,0xB1);
    sd_nvic_SystemReset();
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    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

  • twittich said:
    There is now one thing left which is not working, if i set the NRF_BL_DFU_INACTIVITY_TIMEOUT_MS it's nothing doing, no difference if set to 0 or any value, no reset at all ?

     '0' disables the inactivity timer so the bootloader will not time out at all. Here's the default setting from sdk_config.h:

    // <i> If 0, no inactivity timer will be used. Values 1-99 are invalid.

    #ifndef NRF_BL_DFU_INACTIVITY_TIMEOUT_MS
    #define NRF_BL_DFU_INACTIVITY_TIMEOUT_MS 120000
    #endif

  • Yes i know the timer and the use of it.

    But i want to use the timer, so that it jumps back to application if no update is started. The wd is now always fed and happy and will not reset the device.

  • Ok, but what is NRF_BL_DFU_INACTIVITY_TIMEOUT_MS set to in your bootloader? 

  • It is now set to 35000.

  • Then the program should enter nrf_bootloader.c:inactivity_timeout() after 35 seconds and reset the device. You may place a breakpoint there to confirm. Maybe the problem is that the bootloader enters DFU mode on subsequent startup rather than booting the app? GPREGRET is not cleared through a soft reset, unlike a WD reset. 

Reply
  • Then the program should enter nrf_bootloader.c:inactivity_timeout() after 35 seconds and reset the device. You may place a breakpoint there to confirm. Maybe the problem is that the bootloader enters DFU mode on subsequent startup rather than booting the app? GPREGRET is not cleared through a soft reset, unlike a WD reset. 

Children
  • Ok i'll test that and look where i should clean it.

    But if the GPREGRET is set and the bootloader enters the dfu mode, one of the first things which is done is " dfu_enter_flags_clear(); " so it should be cleared. And if a reset is done after setting the GPREGRET  register and before clearing it should stay in dfu mode after the reset ?

  • While debugging it goes into the timeout callback and the application is started as usual but without debugging it times out and the device disappear, no update possible and app is not starting. ???

  • That's a bit strange. Suggest that you try this without debugging, then when the program gets in this state, attach a debugger and read out the registers with nrfjprog --readregs. This will return the PC register which tells you where in the code your program is stuck. 

  • It stays in the forever loop even after 10 minutes ?

    I'll test a seperate timer which is started from main and reset the device and set the dfu timeout back to 0.

    Have no idea at the moment...

  • twittich said:
    It stays in the forever loop even after 10 minutes

     Are you sure it's not being reset every 35 seconds, but that it for some reason re-enters DFU mode?