Issue when application that uses TASK WDT gets a FOTA with an application that uses simple WDT

Dear All,

Currently I am developing an application that is using the TASK WDT, using nRF COnnect SDK v2.1.0. The application itself works fine. When I tried to do a FOTA, even though the task WDT related to the FOTA operation was treated in time, I was getting a watchdog reset in the middle of the operation without any fault message or anything like that. This was with using the default KConfig settings and the hardware fallback enabled. My task WDT callback looks like this:

/* Callback for Task WDT */
void task_wdt_callback(int channel_id, void* user_data)
{
    task_wdt_t* handle = user_data; // Cast to struct

    /* We have WDT HW fallback to account for, no time to waste */
    LOG_ERR("**** Timeout on ID %u with name %s ****", channel_id, handle->channel_name);
    while (LOG_PROCESS())
        ; // Print all remaining logging
    LOG_PANIC();

    /* Can retry a few times. because we have the ID... Keep a log of which modules timeout? */

    /* Can try to save in persistent memory */

    /* Reboots due to HW WDT Fallback, default delay needed to finish printing */

    /* In case of WDT HW fallback failure, still do a reboot */
    // NVIC_SystemReset(); // Reset reason will be SREQ ...
}


So I was expecting to see the LOG message. Then I realised that it might be that the hardware WDT delay was too short.


After some tweaking I got this setup to be working well:

CONFIG_WATCHDOG=y
CONFIG_WDT_DISABLE_AT_BOOT=n
CONFIG_TASK_WDT=y
CONFIG_TASK_WDT_CHANNELS=15
CONFIG_TASK_WDT_MIN_TIMEOUT=10000
CONFIG_TASK_WDT_HW_FALLBACK=y
CONFIG_TASK_WDT_HW_FALLBACK_DELAY=1000


After fixing this problem I got to a new one. The FOTA file that I am trying to apply was made on nRF Connect SDK v1.6.0 and it is running the regular, hardware WDT.

Once my device downloads the file and tries to apply it, I see the boot banner of that application, sometimes it evens starts running for a short amount of time and then the device is reset and the reset cause is DOG, without any obvious sign as to why does that happen.

I have tried compiling both projects with

CONFIG_WDT_DISABLE_AT_BOOT=y

but this did not make a difference.


Once the download is complete this is what I see:

[00:02:52.891,357] <inf> dfu_target_mcuboot: MCUBoot image-0 upgrade scheduled. Reset device to apply
[00:02:52.914,001] <inf> sodaq_nrf9160_fota: FOTA Completed, rebooting in 5s
*** Booting Zephyr OS build v3.1.99-ncs1  ***
I: Starting bootloader
I: Primary image: magic=good, swap_type=0x4, copy_done=0x1, image_ok=0x1
I: Secondary image: magic=good, swap_type=0x2, copy_done=0x3, image_ok=0x3
I: Boot source: none
I: Swap type: test
I: Starting swap using move algorithm.
I: Bootloader chainload address offset: 0x10000
I: Jumping to the first image slot*** Booting Zephyr OS build v2.6.0-rc1-ncs1  ***
Flash regions		Domain		Permissions
00 03 0x00000 0x20000 	Secure		rwxl
04 31 0x20000 0x100000 	Non-Secure	rwxl

Non-secure callable region 0 placed in flash region 3 with size 32.

SRAM region		Domain		Permissions
00 07 0x00000 0x10000 	Secure		rwxl
08 31 0x10000 0x40000 	Non-Secure	rwxl

Peripheral		Domain		Status
00 NRF_P0               Non-Secure	OK
01 NRF_CLOCK            Non-Secure	OK
02 NRF_RTC0             Non-Secure	OK
03 NRF_RTC1             Non-Secure	OK
04 NRF_NVMC             Non-Secure	OK
05 NRF_UARTE1           Non-Secure	OK
06 NRF_UARTE2           Secure		SKIP
07 NRF_TWIM2            Non-Secure	OK
08 NRF_SPIM3            Non-Secure	OK
09 NRF_TIMER0           Non-Secure	OK
10 NRF_TIMER1           Non-Secure	OK
11 NRF_TIMER2           Non-Secure	OK
12 NRF_SAADC            Non-Secure	OK
13 NRF_PWM0             Non-Secure	OK
14 NRF_PWM1             Non-Secure	OK
15 NRF_PWM2             Non-Secure	OK
16 NRF_PWM3             Non-Secure	OK
17 NRF_WDT              Non-Secure	OK
18 NRF_IPC              Non-Secure	OK
19 NRF_VMC              Non-Secure	OK
20 NRF_FPU              Non-Secure	OK
21 NRF_EGU1             Non-Secure	OK
22 NRF_EGU2             Non-Secure	OK
23 NRF_DPPIC            Non-Secure	OK
24 NRF_REGULATORS       Non-Secure	OK
25 NRF_PDM              Non-Secure	OK
26 NRF_I2S              Non-Secure	OK
27 NRF_GPIOTE1          Non-Secure	OK

SPM: NS image at 0x20200
SPM: NS MSP at 0x20032368
SPM: NS reset vector at 0x32149
SPM: prepare to jump to Non-Secure image.
*** Booting Zephyr OS build v2.6.0-rc1-ncs1  ***
*** Booting Zephyr OS build v3.1.99-ncs1  ***
I: Starting bootloader
I: Primary image: magic=good, swap_type=0x2, copy_done=0x1, image_ok=0x3
I: Secondary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3
I: Boot source: none
I: Swap type: revert
I: Starting swap using move algorithm.
I: Secondary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3
I: Bootloader chainload address offset: 0x10000
I: Jumping to the first image slot[00:00:00.449,462] <inf> spi_nor: W25Q16JV: SFDP v 1.5 AP ff with 1 PH
[00:00:00.449,523] <inf> spi_nor: PH0: ff00 rev 1.5: 16 DW @ 80
*** Booting Zephyr OS build v3.1.99-ncs1  ***
[00:00:00.463,623] <inf> spi_nor: W25Q16JV: 2 MiBy flash
[00:00:00.467,895] <inf> mcuboot_util: Swap type: none

Reset cause(s):
	DOG


This is the same in both cases where I am either disabling or enabling the watchdog at boot on the BIN that I am downloading.

So my question is this:

Is there an issue with compatibility between the TASK WDT and the regular WDT? Is there a way to stop prevent the HW WDT to fire at boot if the previous application was using TASK WDT with HW WDT as a fallback?

Related