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

  • Yes it isn't entering the application there are different alive indicators, if i remove the comments from " _WFE " it restarts the application normal.

    What did the uncommenting exactly do that the wdt will not time out ?

    Actual if the wdt is set to 40 seconds, the bootloader inactivity to 0 everything works fine if the dfu update is started immidiatly.

    ------

    Now i set the wdt to 5 secs and do the following and after maximum a minute it makes a restart (maybe the inactivity timeout ?), theoretically it has to stay forever in the dfu mode until the update is started  /done.

    I'll try to write directly in the register and guess it's working. First i fill all regs with 0xffffffff and then with the magic number. thats the first i do in the main of the bootloader and then in the forever loop...

    NRF_WDT->RR[0] = 0x6E524635UL;
    NRF_WDT->RR[1] = 0x6E524635UL;
    NRF_WDT->RR[2] = 0x6E524635UL;
    NRF_WDT->RR[3] = 0x6E524635UL;
    NRF_WDT->RR[4] = 0x6E524635UL;
    NRF_WDT->RR[5] = 0x6E524635UL;
    NRF_WDT->RR[6] = 0x6E524635UL;
    NRF_WDT->RR[7] = 0x6E524635UL;

    And just byside is this correct ?

    in the file " nrf_bootloader_wdt.c " in function " static void wdt_feed(void) " the for loop " for (nrf_wdt_rr_register_t i = NRF_WDT_RR0; i < NRF_WDT_RR7; i++) " counts up to smaller than " NRF_WDT_RR7 " , i guess it has to be " <= " .

    inactivity timer expires after 2 minutes by default,

    where is this timer and where is the 2 minutes set ?

  • twittich said:
    What did the uncommenting exactly do that the wdt will not time out ?

     WFE puts the CPU to sleep as long as there are no pending interrupts. So the frequency of your interrupts will then define the reload interval. Without WFE it will be reloaded almost continuously(is not reloaded when processing scheduler tasks). However, I don't see how removing __WFE could cause the program to crash to app_start. Can you read out the the  Program counter (PC) and xPSR registers when this happens?

    twittich said:
    in the file " nrf_bootloader_wdt.c " in function " static void wdt_feed(void) " the for loop " for (nrf_wdt_rr_register_t i = NRF_WDT_RR0; i < NRF_WDT_RR7; i++) " counts up to smaller than " NRF_WDT_RR7 " , i guess it has to be " <= "

     Good catch! Are you enabling channel 7 in your code? That might explain the unexpected WD resets you saw earlier.  

    twittich said:
    where is this timer and where is the 2 minutes set ?

     If you search for 'NRF_BL_DFU_INACTIVITY_TIMEOUT_MS' in your bootloader project you will see where the timeout is configured and find references to the timer instance used for the bootloader timeout. The timer is reloaded during DFU, so the DFU itself is not limited to 2 minutes.  

  • 'NRF_BL_DFU_INACTIVITY_TIMEOUT_MS

    This i know as i said this was set to 0 but i thought because of that " The inactivity timer expires after 2 minutes by default, " you meant another timer.

    With my fix in the loop, the wd feeding at the beginning in main of bootloader and commenting out of __wfe the wd will not timeout and this is set actually to  1.5 sec.

    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 ?

    Good catch! Are you enabling channel 7 in your code?

    Thank you, yes all ...

  • 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.

Related