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

Serial bootloader watchdog and RTT print issue

Hello,

i am currently developing on nRF52840 using SDK 15.2.0. I have an application and a bootloader. I use the GPREGRET register to boot to bootloader.

I have an issue where the WDT does not get reloaded if i do not have a debug printout in the WDT reload request located in nrf_bootloader_wdt.c:

static void wdt_feed(void)
{
if (nrf_wdt_started())
{
for (nrf_wdt_rr_register_t i = NRF_WDT_RR0; i < NRF_WDT_RR7; i++)
{
if (nrf_wdt_reload_request_is_enabled(i))
{
nrf_wdt_reload_request_set(i);
NRF_LOG_INFO("Feed RR %d wdt", i);
}
}
}
}

Without the NRF_LOG_INFO printout, the wdt reset is performed after the reload period set in the application has expired. With the print, the reload seems to work and the WDT reset is not performed.

I tried using a delay instead of the printout but that did not help.

Is there some known issue that could be causing this?

BR,

tommi

Parents
  • Hi Velho, 

    This is pretty strange. 

    Could you try to test using our buttonless dfu example and the stock DFU bootloader and enable WDT to test ? 
    In our example we don't print RTT log inside wdt_feed(). 

    Do you modify have any modification to the bootloader ? 

  • Ok, i think i got this. The WDT is fed in the "loop_forever"-function in the nrf_bootloader.c file. When there are no debug printouts, the wait_for_event() call puts the device to sleep, and there are no events -> the wdt is never fed. When there are debugs, the log is processed constantly, so wait_for_event() is never called and the processor does not sleep, meaning that the watchdog is fed periodically. The WDT feed timer does not work, as is the case with others. I had no success implementing my own timer function, i will try to make some event that wakes the processor periodically so that the WDT is fed.

  • Hi Tommik, 

    Thanks for updating.

    It depends on how you configure the WDT, there is an option that the WDT shouldn't run when the CPU is in sleep mode. In that case you don't need to periodically wake the CPU up to feed the dog. In other case, a timer is needed. 

  • I tried setting NRFX_WDT_CONFIG_BEHAVIOUR to Pause in SLEEP and HALT in the main app. I use it when configuring the WDT as the value for the behaviour member of the nrf_drv_wdt_config_t struct. Changing it provided no difference in the operation.

    The DFU timer did not work, because nrf_clock_lf_is_running() called in nrf_bootloader_dfu_timers.h returns true even though the clock is not running. Removing the check, and thus calling nrf_clock_task_trigger(NRF_CLOCK_TASK_LFCLKSTART) on timer init made the timers work for both the inactivity timer as well as for the wdt feed timer, and now the bootloader finally works, as the periodic interrupts wake the processor periodically.

  • Hi Tommik, 

    This is very strange, especially the issue with nrf_clock_lf_is_running().

     Just for clarification, do you see the same issue on the stock bootloader example ? Could you let us know how to reproduce the issue here ?

  • The bootloader i am using is the unchanged UART bootloader SW from SDK 15.2.0, which I compile from source. sdk_config and main are from the secure_bootloader\pca10056_uart_debug example.

    From what i understand, the issue is present with other people also, as in this ticket I linked earlier: https://devzone.nordicsemi.com/f/nordic-q-a/35570/entering-dfu-via-gpreget-secure-bootloader-serial-example-not-feeding-wdt-in-sdkv15/

    From that ticket:

    "I suspect that what is happening is that the event loop / app_scheduler is not working for some reason when the WDT is enabled, and neither the app timer for feeding the WDT nor the app timer for NRF_BL_INACTIVITY_TIMEOUT_MS are working. "

    This is the same exact issue I am witnessing. Others seem to circumvent the problem by implementing an own timer to replace the non-functioning timer.

    Steps to recreate:

    Use nRF5_SDK_15.2.0_9412b96 example in examples\dfu\secure_bootloader\pca10056_uart_debug with the following values changed in the sdk_config:

    #define NRF_BL_DFU_ENTER_METHOD_BUTTON 0

    #define NRF_BL_DFU_ENTER_METHOD_BUTTONLESS 1

    #define NRF_BL_DFU_INACTIVITY_TIMEOUT_MS 180000

    #define NRFX_UARTE_DEFAULT_CONFIG_HWFC 1

    #define NRFX_UART_DEFAULT_CONFIG_HWFC 1

    #define NRF_LOG_BUFSIZE 1024

    Other values in sdk_config are as provided in the example.

    Use an application software with the following WDT setting:

    nrf_drv_wdt_config_t config = {
    .behaviour = 1,
    .reload_value = 20000,
    .interrupt_priority = 6,
    };

    Then start the application. Some time after the application has started, do the following functions:

    err_code = sd_power_gpregret_clr(0, 0xffffffff);
    APP_ERROR_CHECK(err_code);

    err_code = sd_power_gpregret_set(0, BOOTLOADER_DFU_START);
    APP_ERROR_CHECK(err_code);

    NVIC_SystemReset();

    The bootloader boots into DFU mode. On my application the bootloader starts into DFU mode, and tries to start the dfu timers but they do not start, and a wdt reset happens shortly after. When commenting out the clock check, thus starting the LFCLK, all works fine.

Reply
  • The bootloader i am using is the unchanged UART bootloader SW from SDK 15.2.0, which I compile from source. sdk_config and main are from the secure_bootloader\pca10056_uart_debug example.

    From what i understand, the issue is present with other people also, as in this ticket I linked earlier: https://devzone.nordicsemi.com/f/nordic-q-a/35570/entering-dfu-via-gpreget-secure-bootloader-serial-example-not-feeding-wdt-in-sdkv15/

    From that ticket:

    "I suspect that what is happening is that the event loop / app_scheduler is not working for some reason when the WDT is enabled, and neither the app timer for feeding the WDT nor the app timer for NRF_BL_INACTIVITY_TIMEOUT_MS are working. "

    This is the same exact issue I am witnessing. Others seem to circumvent the problem by implementing an own timer to replace the non-functioning timer.

    Steps to recreate:

    Use nRF5_SDK_15.2.0_9412b96 example in examples\dfu\secure_bootloader\pca10056_uart_debug with the following values changed in the sdk_config:

    #define NRF_BL_DFU_ENTER_METHOD_BUTTON 0

    #define NRF_BL_DFU_ENTER_METHOD_BUTTONLESS 1

    #define NRF_BL_DFU_INACTIVITY_TIMEOUT_MS 180000

    #define NRFX_UARTE_DEFAULT_CONFIG_HWFC 1

    #define NRFX_UART_DEFAULT_CONFIG_HWFC 1

    #define NRF_LOG_BUFSIZE 1024

    Other values in sdk_config are as provided in the example.

    Use an application software with the following WDT setting:

    nrf_drv_wdt_config_t config = {
    .behaviour = 1,
    .reload_value = 20000,
    .interrupt_priority = 6,
    };

    Then start the application. Some time after the application has started, do the following functions:

    err_code = sd_power_gpregret_clr(0, 0xffffffff);
    APP_ERROR_CHECK(err_code);

    err_code = sd_power_gpregret_set(0, BOOTLOADER_DFU_START);
    APP_ERROR_CHECK(err_code);

    NVIC_SystemReset();

    The bootloader boots into DFU mode. On my application the bootloader starts into DFU mode, and tries to start the dfu timers but they do not start, and a wdt reset happens shortly after. When commenting out the clock check, thus starting the LFCLK, all works fine.

Children
Related