MCUboot and watchdog behavior on the nrf5340, ncs v3.1.1

Hi,

I'm looking at the watchdog behavior in mcuboot during DFU. Here are the watchdog-related configs I've set:

CONFIG_BOOT_WATCHDOG_FEED=y
CONFIG_WATCHDOG=y

and here are a few things I've noticed:

- Even though the watchdog is fed by the macro `FEED_WDT_INST(id)` in mcuboot_config.h, the watchdog doesn't seem to be started in the first place. This can be checked by calling `nrf_wdt_started_check()` in `mcuboot/boot/zephyr/main.c`, which returns false. This means that the feeding of the watchdog doesn't really do anything.

- The reload value in the CRV registers appears to always be set to 0xFFFFFFFF when mcuboot runs and there doesn't seem to be any way to set it to another value.

Could you have a look at the mcuboot code and check if these are expected behaviors?

Thank you (:

Parents Reply Children
  • While reading the WDT state from the bootloader, please also check the RESETREAS to confirm the reset source (Note: this register is retained across all resets but POR/BOR).

  • So I've injected some code into mcuboot's main.c to read out RESETREAS. Throughout DFU, there were 3 reboots in total (not sure why).

    - 1st reboot, reset reason: watchdog and software

    - 2nd reboot, reset reason: software

    - 3rd reboot, (after which the app starts to run): reset reason: power-on reset

    16:14:08.303: dfu_target_mcuboot: MCUBoot image-0 upgrade scheduled. Reset device to apply
    16:14:08.308: dfu_target_mcuboot: MCUBoot image-1 upgrade scheduled. Reset device to apply
    16:14:09.215: Serial error: [Errno 5] Input/output error
    16:14:10.334: Reopened serial port
    16:14:10.645: *** Delaying boot by 2000ms... ***
    16:14:11.974: *** Booting mcuboot v2.1.0-dev-2b69d93e75bc ***
    16:14:11.988: *** Using nRF Connect SDK v3.1.0-6c6e5b32496e ***
    16:14:11.992: *** Using Zephyr OS v4.1.99-1612683d4010 ***
    16:14:11.997: W: Reset reason: watchdog | software, raw: 0xa
    16:14:12.014: W: watchdog at 0x50018000, CRV: 0xffffffff or 131071999 ms, TASKS_STOP: 0x0, TASKS_START: 0x0, RREN: 0x1, TSEN: 0x0, CONFIG: 0x1, EVENTS_STOPPED: 0x0, started: 0
    16:14:12.023: I: Starting bootloader
    16:14:12.028: D: context_boot_go
    16:14:12.033: I: Line 476, Image index: 0, Swap type: test
    16:14:12.037: D: boot_validate_slot: slot 1, expected_swap_type 2
    16:14:12.042: D: bootutil_img_validate: flash area 0xffa4
    16:14:12.047: D: bootutil_img_hash
    16:14:12.681: D: bootutil_tlv_iter_begin: type 65535, prot == 0
    16:14:12.690: D: bootutil_img_validate: TLV off 362368, end 362515
    16:14:12.694: D: bootutil_tlv_iter_next: searching for 65535 (65535 is any) starting at 362368 ending at 362515
    16:14:12.699: D: bootutil_tlv_iter_next: TLV 16 found at 362372 (size 32)
    16:14:12.704: D: bootutil_img_validate: EXPECTED_HASH_TLV == 16
    16:14:12.709: D: bootutil_tlv_iter_next: searching for 65535 (65535 is any) starting at 362404 ending at 362515
    16:14:12.713: D: bootutil_tlv_iter_next: TLV 1 found at 362408 (size 32)
    16:14:12.718: D: bootutil_img_validate: EXPECTED_KEY_TLV == 1
    16:14:12.723: D: bootutil_find_key
    16:14:12.727: D: bootutil_tlv_iter_next: searching for 65535 (65535 is any) starting at 362440 ending at 362515
    16:14:12.732: D: bootutil_tlv_iter_next: TLV 34 found at 362444 (size 71)
    16:14:12.737: D: bootutil_img_validate: EXPECTED_SIG_TLV == 34
    16:14:13.154: D: bootutil_tlv_iter_next: searching for 65535 (65535 is any) starting at 362515 ending at 362515
    16:14:13.159: D: bootutil_tlv_iter_next: TLV 65535 not found
    16:14:13.163: I: Line 476, Image index: 1, Swap type: test
    16:14:13.168: D: boot_validate_slot: slot 1, expected_swap_type 2
    16:14:13.173: D: bootutil_img_validate: flash area 0xffb4
    16:14:13.178: D: bootutil_img_hash
    16:14:13.183: D: bootutil_tlv_iter_begin: type 65535, prot == 0
    16:14:13.187: D: bootutil_img_validate: TLV off 36316, end 36461
    16:14:13.192: D: bootutil_tlv_iter_next: searching for 65535 (65535 is any) starting at 36316 ending at 36461
    16:14:13.197: D: bootutil_tlv_iter_next: TLV 16 found at 36320 (size 32)
    16:14:13.202: D: bootutil_img_validate: EXPECTED_HASH_TLV == 16
    16:14:13.206: D: bootutil_tlv_iter_next: searching for 65535 (65535 is any) starting at 36352 ending at 36461
    16:14:13.211: D: bootutil_tlv_iter_next: TLV 1 found at 36356 (size 32)
    16:14:13.216: D: bootutil_img_validate: EXPECTED_KEY_TLV == 1
    16:14:13.220: D: bootutil_find_key
    16:14:13.225: D: bootutil_tlv_iter_next: searching for 65535 (65535 is any) starting at 36388 ending at 36461
    16:14:13.230: D: bootutil_tlv_iter_next: TLV 34 found at 36392 (size 69)
    16:14:13.234: D: bootutil_img_validate: EXPECTED_SIG_TLV == 34
    16:14:21.378: D: bootutil_tlv_iter_next: searching for 65535 (65535 is any) starting at 36461 ending at 36461
    16:14:21.383: D: bootutil_tlv_iter_next: TLV 65535 not found
    16:14:21.388: D: boot_verify_slot_dependencies
    16:14:21.393: D: bootutil_tlv_iter_begin: type 64, prot == 1
    16:14:21.398: D: bootutil_tlv_iter_next: searching for 64 (65535 is any) starting at 362368 ending at 362515
    16:14:21.403: D: bootutil_tlv_iter_next: protected TLV 64 not found
    16:14:21.408: D: boot_verify_slot_dependencies
    16:14:21.414: D: bootutil_tlv_iter_begin: type 64, prot == 1
    16:14:21.419: D: bootutil_tlv_iter_next: searching for 64 (65535 is any) starting at 36316 ending at 36461
    16:14:21.425: D: bootutil_tlv_iter_next: protected TLV 64 not found
    16:14:21.431: I: Image 0 upgrade secondary slot -> primary slot
    16:14:21.437: I: Erasing the primary slot
    ///////////// D: [Lots of boot_erase_region s]
    16:14:22.511: I: Image 0 copying the secondary slot to the primary slot: 0x58814 bytes
    16:14:25.594: D: boot_write_magic: fa_id=6 off=0xc5ff0 (0xd9ff0)
    16:14:25.602: D: erasing secondary header
    16:14:25.607: D: boot_scramble_region: 0xffa4 0 4096 0
    16:14:25.612: D: boot_erase_region: flash_area 0xffa4, offset 0, size 4096, backwards == 0
    16:14:25.616: D: boot_erase_region: device with erase
    16:14:25.621: D: erasing secondary trailer
    16:14:25.626: D: boot_scramble_region: 0xffa4 806912 4096 0
    16:14:25.631: D: boot_erase_region: flash_area 0xffa4, offset 806912, size 4096, backwards == 0
    16:14:25.636: D: boot_erase_region: device with erase
    16:14:25.640: I: Image 1 upgrade secondary slot -> primary slot
    16:14:25.645: I: Erasing the primary slot
    ////////////: D: [A few boot_erase_region s]
    16:14:25.766: I: Image 1 copying the secondary slot to the primary slot: 0x8e70 bytes
    16:14:25.771: D: boot_write_magic: fa_id=1 off=0x3fff0 (0x3fff0)
    16:14:25.776: I: Turned on network core
    16:14:28.700: I: Turned off network core
    16:14:28.711: D: erasing secondary header
    16:14:28.716: D: boot_scramble_region: 0xffb4 0 4096 0
    16:14:28.721: D: boot_erase_region: flash_area 0xffb4, offset 0, size 4096, backwards == 0
    16:14:28.726: D: boot_erase_region: device with erase
    16:14:28.730: D: erasing secondary trailer
    16:14:28.735: D: boot_scramble_region: 0xffb4 258048 4096 0
    16:14:28.740: D: boot_erase_region: flash_area 0xffb4, offset 258048, size 4096, backwards == 0
    16:14:28.744: D: boot_erase_region: device with erase
    16:14:28.763: D: boot_validate_slot: slot 0, expected_swap_type 0
    16:14:28.770: D: bootutil_img_validate: flash area 0xfeb4
    16:14:28.774: D: bootutil_img_hash
    16:14:29.362: D: bootutil_tlv_iter_begin: type 65535, prot == 0
    16:14:29.374: D: bootutil_img_validate: TLV off 362368, end 362515
    16:14:29.382: D: bootutil_tlv_iter_next: searching for 65535 (65535 is any) starting at 362368 ending at 362515
    16:14:29.388: D: bootutil_tlv_iter_next: TLV 16 found at 362372 (size 32)
    16:14:29.393: D: bootutil_img_validate: EXPECTED_HASH_TLV == 16
    16:14:29.397: D: bootutil_tlv_iter_next: searching for 65535 (65535 is any) starting at 362404 ending at 362515
    16:14:29.404: D: bootutil_tlv_iter_next: TLV 1 found at 362408 (size 32)
    16:14:29.409: D: bootutil_img_validate: EXPECTED_KEY_TLV == 1
    16:14:29.413: D: bootutil_find_key
    16:14:29.419: D: bootutil_tlv_iter_next: searching for 65535 (65535 is any) starting at 362440 ending at 362515
    16:14:29.424: D: bootutil_tlv_iter_next: TLV 34 found at 362444 (size 71)
    16:14:29.429: D: bootutil_img_validate: EXPECTED_SIG_TLV == 34
    16:14:29.755: D: bootutil_tlv_iter_next: searching for 65535 (65535 is any) starting at 362515 ending at 362515
    16:14:29.770: D: bootutil_tlv_iter_next: TLV 65535 not found
    16:14:29.775: D: boot_validate_slot: slot 0, expected_swap_type 0
    16:14:29.780: D: Left boot_go with success == 1
    16:14:29.785: I: Bootloader chainload address offset: 0x14000
    16:14:29.795: I: Image version: v0.0.0
    16:14:29.805: I: Jumping to the first image slot
    16:14:29.809: W: watchdog at 0x50018000, CRV: 0xffffffff or 131071999 ms, TASKS_STOP: 0x0, TASKS_START: 0x0, RREN: 0x1, TSEN: 0x0, CONFIG: 0x41, EVENTS_STOPPED: 0x1, started: 0
    16:14:31.750: Serial error: [Errno 5] Input/output error
    16:14:38.798: Reopened serial port
    16:14:39.104: *** Delaying boot by 2000ms... ***
    16:14:40.468: *** Booting mcuboot v2.1.0-dev-2b69d93e75bc ***
    16:14:40.475: *** Using nRF Connect SDK v3.1.0-6c6e5b32496e ***
    16:14:40.481: *** Using Zephyr OS v4.1.99-1612683d4010 ***
    16:14:40.486: W: Reset reason: software, raw: 0x8
    16:14:40.491: W: watchdog at 0x50018000, CRV: 0xffffffff or 131071999 ms, TASKS_STOP: 0x0, TASKS_START: 0x0, RREN: 0x1, TSEN: 0x0, CONFIG: 0x1, EVENTS_STOPPED: 0x0, started: 0
    16:14:40.500: I: Starting bootloader
    16:14:40.505: D: context_boot_go
    16:14:40.510: I: Line 490, Image index: 0, Swap type: none
    16:14:40.515: I: Line 490, Image index: 1, Swap type: none
    16:14:40.530: D: boot_validate_slot: slot 0, expected_swap_type 0
    16:14:40.534: D: bootutil_img_validate: flash area 0xfeb4
    16:14:40.539: D: bootutil_img_hash
    16:14:41.128: D: bootutil_tlv_iter_begin: type 65535, prot == 0
    16:14:41.142: D: bootutil_img_validate: TLV off 362368, end 362515
    16:14:41.146: D: bootutil_tlv_iter_next: searching for 65535 (65535 is any) starting at 362368 ending at 362515
    16:14:41.151: D: bootutil_tlv_iter_next: TLV 16 found at 362372 (size 32)
    16:14:41.156: D: bootutil_img_validate: EXPECTED_HASH_TLV == 16
    16:14:41.160: D: bootutil_tlv_iter_next: searching for 65535 (65535 is any) starting at 362404 ending at 362515
    16:14:41.165: D: bootutil_tlv_iter_next: TLV 1 found at 362408 (size 32)
    16:14:41.170: D: bootutil_img_validate: EXPECTED_KEY_TLV == 1
    16:14:41.176: D: bootutil_find_key
    16:14:41.183: D: bootutil_tlv_iter_next: searching for 65535 (65535 is any) starting at 362440 ending at 362515
    16:14:41.188: D: bootutil_tlv_iter_next: TLV 34 found at 362444 (size 71)
    16:14:41.193: D: bootutil_img_validate: EXPECTED_SIG_TLV == 34
    16:14:41.513: D: bootutil_tlv_iter_next: searching for 65535 (65535 is any) starting at 362515 ending at 362515
    16:14:41.529: D: bootutil_tlv_iter_next: TLV 65535 not found
    16:14:41.542: D: boot_validate_slot: slot 0, expected_swap_type 0
    16:14:41.549: D: Left boot_go with success == 1
    16:14:41.553: I: Bootloader chainload address offset: 0x14000
    16:14:41.563: I: Image version: v0.0.0
    16:14:41.572: I: Jumping to the first image slot
    16:14:41.577: W: watchdog at 0x50018000, CRV: 0xffffffff or 131071999 ms, TASKS_STOP: 0x0, TASKS_START: 0x0, RREN: 0x1, TSEN: 0x0, CONFIG: 0x41, EVENTS_STOPPED: 0x1, started: 0
    16:14:43.506: Serial error: [Errno 5] Input/output error
    16:14:50.047: Reopened serial port
    16:14:50.278: *** Booting nRF Connect SDK v3.1.0-6c6e5b32496e ***
    16:14:50.283: *** Using Zephyr OS v4.1.99-1612683d4010 ***
    16:14:50.288: NRFX_WDT: Function: nrfx_wdt_channel_alloc, error code: NRFX_SUCCESS.
    16:14:50.298: task_wdt: hw_wdt timeout installed, wdt_config.window.max: 210
    16:14:50.511: main: App Version: 0.0.7-1
    16:14:50.523: main: Reset reason: power-on reset
    16:14:50.537: NRFX_WDT: Reconfigured watchdog at 0x50018000 with reload value of 210 ms, behavior 65, int prio 0
    16:14:50.542: NRFX_WDT: Enabled.
    16:16:21.810: main: watchdog at 0x50018000, CRV: 0x1ae1 or 209 ms, TASKS_STOP: 0x0, TASKS_START: 0x0, RREN: 0x1, started: 1
    

  • I tested with SDK v3.1.1 using a slightly modified version of the Zephyr SMP server sample (added starting of the WDT). I also changed the bootloader to print the WDT status and reset reason on boot.

    Bootloader changes:

    diff --git a/boot/zephyr/include/mcuboot_config/mcuboot_config.h b/boot/zephyr/include/mcuboot_config/mcuboot_config.h
    index 8ba03073..258ddc93 100644
    --- a/boot/zephyr/include/mcuboot_config/mcuboot_config.h
    +++ b/boot/zephyr/include/mcuboot_config/mcuboot_config.h
    @@ -421,6 +421,7 @@
     #if defined(CONFIG_NRFX_WDT0) && defined(CONFIG_NRFX_WDT1)
     #define MCUBOOT_WATCHDOG_FEED() \
         do {                        \
    +        BOOT_LOG_INF("Calling MCUBOOT_WATCHDOG_FEED"); \
             FEED_WDT_INST(0);       \
             FEED_WDT_INST(1);       \
         } while (0)
    diff --git a/boot/zephyr/main.c b/boot/zephyr/main.c
    index 53a39340..156f38d2 100644
    --- a/boot/zephyr/main.c
    +++ b/boot/zephyr/main.c
    @@ -46,6 +46,8 @@
     #include "bootutil/fault_injection_hardening.h"
     #include "bootutil/mcuboot_status.h"
     #include "flash_map_backend/flash_map_backend.h"
    +#include <helpers/nrfx_reset_reason.h>
    +#include <hal/nrf_wdt.h>
     
     /* Check if Espressif target is supported */
     #ifdef CONFIG_SOC_FAMILY_ESPRESSIF_ESP32
    @@ -476,10 +478,66 @@ static void boot_serial_enter()
     }
     #endif
     
    +static void reset_reason_str_get(char *str, uint32_t reason)
    +{
    +	size_t len;
    +
    +	*str = '\0';
    +
    +	if (reason & NRFX_RESET_REASON_RESETPIN_MASK) {
    +		(void)strcat(str, "PIN reset | ");
    +	}
    +	if (reason & NRFX_RESET_REASON_DOG_MASK) {
    +		(void)strcat(str, "watchdog | ");
    +	}
    +	if (reason & NRFX_RESET_REASON_OFF_MASK) {
    +		(void)strcat(str, "wakeup from power-off | ");
    +	}
    +	if (reason & NRFX_RESET_REASON_DIF_MASK) {
    +		(void)strcat(str, "debug interface wakeup | ");
    +	}
    +	if (reason & NRFX_RESET_REASON_SREQ_MASK) {
    +		(void)strcat(str, "software | ");
    +	}
    +	if (reason & NRFX_RESET_REASON_LOCKUP_MASK) {
    +		(void)strcat(str, "CPU lockup | ");
    +	}
    +	if (reason & NRFX_RESET_REASON_CTRLAP_MASK) {
    +		(void)strcat(str, "control access port | ");
    +	}
    +
    +	len = strlen(str);
    +	if (len == 0) {
    +		(void)strcpy(str, "power-on reset");
    +	} else {
    +		str[len - 3] = '\0';
    +	}
    +}
    +
    +static void print_reset_reason(void)
    +{
    +	uint32_t reset_reason;
    +	char reset_reason_str[128];
    +
    +	/* Read RESETREAS register value and clear current reset reason(s). */
    +	reset_reason = nrfx_reset_reason_get();
    +	nrfx_reset_reason_clear(reset_reason);
    +
    +	reset_reason_str_get(reset_reason_str, reset_reason);
    +
    +	BOOT_LOG_INF("Reset reason: %s", reset_reason_str);
    +}
    +
     int main(void)
     {
         struct boot_rsp rsp;
         int rc;
    +
    +    if(nrf_wdt_started_check(NRF_WDT0)) {
    +        BOOT_LOG_INF("WDT is active");
    +    } else {
    +        BOOT_LOG_INF("WDT is disabled");
    +    }
     #if defined(CONFIG_BOOT_USB_DFU_GPIO) || defined(CONFIG_BOOT_USB_DFU_WAIT)
         bool usb_dfu_requested = false;
     #endif
    @@ -493,6 +551,7 @@ int main(void)
     #else
         BOOT_LOG_INF("Starting Direct-XIP bootloader");
     #endif
    +    print_reset_reason();
     
     #ifdef CONFIG_MCUBOOT_INDICATION_LED
         /* LED init */
    

    app changes:

    diff --git a/prj_nrf5340_bt.conf b/prj_nrf5340_bt.conf
    index cb53d3e..36a3056 100644
    --- a/prj_nrf5340_bt.conf
    +++ b/prj_nrf5340_bt.conf
    @@ -86,3 +86,5 @@ CONFIG_CLOCK_CONTROL_NRF_SHELL=n
     CONFIG_DEVICE_SHELL=n
     CONFIG_DEVMEM_SHELL=n
     CONFIG_FLASH_SHELL=n
    +
    +CONFIG_WATCHDOG=y
    \ No newline at end of file
    diff --git a/src/main.c b/src/main.c
    index 8b0c0b4..1f27ad7 100644
    --- a/src/main.c
    +++ b/src/main.c
    @@ -8,6 +8,7 @@
     #include <zephyr/kernel.h>
     #include <zephyr/stats/stats.h>
     #include <zephyr/usb/usb_device.h>
    +#include <zephyr/drivers/watchdog.h>
     
     #ifdef CONFIG_MCUMGR_GRP_FS
     #include <zephyr/device.h>
    @@ -27,6 +28,8 @@ LOG_MODULE_REGISTER(smp_sample);
     #define STORAGE_PARTITION_LABEL	storage_partition
     #define STORAGE_PARTITION_ID	FIXED_PARTITION_ID(STORAGE_PARTITION_LABEL)
     
    +#define WDT_FEED_TRIES 5
    +
     /* Define an example stats group; approximates seconds since boot. */
     STATS_SECT_START(smp_svr_stats)
     STATS_SECT_ENTRY(ticks)
    @@ -52,7 +55,45 @@ static struct fs_mount_t littlefs_mnt = {
     
     int main(void)
     {
    -	int rc = STATS_INIT_AND_REG(smp_svr_stats, STATS_SIZE_32,
    +	int rc;
    +	int wdt_channel_id;
    +	const struct device *const wdt = DEVICE_DT_GET(DT_ALIAS(watchdog0));
    +
    +	printk("Watchdog sample application\n");
    +
    +	if (!device_is_ready(wdt)) {
    +		LOG_ERR("%s: device not ready.", wdt->name);
    +		return 0;
    +	}
    +
    +	struct wdt_timeout_cfg wdt_config = {
    +		/* Reset SoC when watchdog timer expires. */
    +		.flags = WDT_FLAG_RESET_SOC,
    +
    +		/* Expire watchdog after max window */
    +		.window.min = 0,
    +		.window.max = 2000,
    +	};
    +
    +	wdt_channel_id = wdt_install_timeout(wdt, &wdt_config);
    +	if (wdt_channel_id == -ENOTSUP) {
    +		/* IWDG driver for STM32 doesn't support callback */
    +		LOG_ERR("Callback support rejected, continuing anyway\n");
    +		wdt_config.callback = NULL;
    +		wdt_channel_id = wdt_install_timeout(wdt, &wdt_config);
    +	}
    +	if (wdt_channel_id < 0) {
    +		LOG_ERR("Watchdog install error");
    +		return 0;
    +	}
    +
    +	rc = wdt_setup(wdt, 0);
    +	if (rc < 0) {
    +		LOG_ERR("Watchdog setup error");
    +		return 0;
    +	}
    +
    +	rc = STATS_INIT_AND_REG(smp_svr_stats, STATS_SIZE_32,
     				    "smp_svr_stats");
     
     	if (rc < 0) {
    @@ -91,6 +132,7 @@ int main(void)
     	while (1) {
     		k_sleep(K_MSEC(1000));
     		STATS_INC(smp_svr_stats, ticks);
    +		wdt_feed(wdt, wdt_channel_id);
     	}
     	return 0;
     }
    

    Log (initial boot after programming + 1 FW update followed by reboot to activate new FW)

    *** Booting MCUboot v2.1.0-dev-9b4ae4cbc9e2 ***
    *** Using nRF Connect SDK v3.1.1-e2a97fe2578a ***
    *** Using Zephyr OS v4.1.99-ff8f0c579eeb ***
    I: WDT is disabled
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Starting bootloader
    I: Reset reason: PIN reset
    I: Image index: 0, Swap type: none
    I: Image index: 1, Swap type: none
    I: Bootloader chainload address offset: 0x10000
    I: Image version: v0.0.0
    �: Jumping to the first image slot
    *** Booting nRF Connect SDK v3.1.1-e2a97fe2578a ***
    *** Using Zephyr OS v4.1.99-ff8f0c579eeb ***
    Watchdog sample application
    [00:00:00.002,349] <inf> littlefs: LittleFS version 2.11, disk version 2.1
    [00:00:00.002,532] <inf> littlefs: FS at flash-controller@39000:0xf0000 is 16 0x1000-byte blocks with 512 cycle
    [00:00:00.002,563] <inf> littlefs: partition sizes: rd 16 ; pr 16 ; ca 64 ; la 32
    [00:00:00.002,655] <err> littlefs: WEST_TOPDIR/modules/fs/littlefs/lfs.c:1386: Corrupted dir pair at {0x0, 0x1}
    [00:00:00.002,655] <wrn> littlefs: can't mount (LFS -84); formatting
    [00:00:00.177,886] <inf> littlefs: /lfs1 mounted
    [00:00:00.203,552] <inf> smp_sample: build time: Jan  9 2026 08:25:40
    [00:00:00.209,014] <inf> bt_hci_core: HW Platform: Nordic Semiconductor (0x0002)
    [00:00:00.209,045] <inf> bt_hci_core: HW Variant: nRF53x (0x0003)
    [00:00:00.209,075] <inf> bt_hci_core: Firmware: Standard Bluetooth controller (0x00) Version 252.16862 Build 1121034987
    [00:00:00.211,029] <inf> bt_hci_core: HCI transport: IPC
    [00:00:00.211,090] <inf> bt_hci_core: Identity: ED:68:9A:DB:A1:6E (random)
    [00:00:00.211,120] <inf> bt_hci_core: HCI: version 6.1 (0x0f) revision 0x2069, manufacturer 0x0059
    [00:00:00.211,151] <inf> bt_hci_core: LMP: version 6.1 (0x0f) subver 0x2069
    [00:00:00.213,226] <inf> smp_bt_sample: Advertising successfully started
    [00:00:09.860,260] <inf> smp_bt_sample: Connected
    [00:00:10.371,612] <wrn> bt_l2cap: Ignoring data for unknown channel ID 0x003a
    [00:00:15.889,831] <inf> mcumgr_img_grp: Erased 0x2e000 bytes of image slot
    [00:00:15.970,764] <inf> mcumgr_img_grp: Erased 0x1000 bytes of image slot trailer
    [00:00:34.795,257] <err> mcumgr_img_grp: Failed to open flash area ID 1: -2
    [00:00:41.307,983] <err> mcumgr_img_grp: Failed to open flash area ID 1: -2
    uart:~$ *** Booting MCUboot v2.1.0-dev-9b4ae4cbc9e2 ***
    *** Using nRF Connect SDK v3.1.1-e2a97fe2578a ***
    *** Using Zephyr OS v4.1.99-ff8f0c579eeb ***
    I: WDT is active
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Starting bootloader
    I: Reset reason: software
    I: Image index: 0, Swap type: perm
    I: Image index: 1, Swap type: none
    I: Image 0 upgrade secondary slot -> primary slot
    I: Erasing the primary slot
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Image 0 copying the secondary slot to the primary slot: 0x2d970 bytes
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Calling MCUBOOT_WATCHDOG_FEED
    I: Bootloader chainload address offset: 0x10000
    I: Image version: v0.0.0
    �: Jumping to the first image slot
    *** Booting nRF Connect SDK v3.1.1-e2a97fe2578a ***
    *** Using Zephyr OS v4.1.99-ff8f0c579eeb ***
    Watchdog sample application
    [00:00:00.002,349] <inf> littlefs: LittleFS version 2.11, disk version 2.1
    [00:00:00.002,532] <inf> littlefs: FS at flash-controller@39000:0xf0000 is 16 0x1000-byte blocks with 512 cycle
    [00:00:00.002,563] <inf> littlefs: partition sizes: rd 16 ; pr 16 ; ca 64 ; la 32
    [00:00:00.028,442] <inf> smp_sample: build time: Jan  9 2026 08:21:23
    [00:00:00.033,905] <inf> bt_hci_core: HW Platform: Nordic Semiconductor (0x0002)
    [00:00:00.033,905] <inf> bt_hci_core: HW Variant: nRF53x (0x0003)
    [00:00:00.033,935] <inf> bt_hci_core: Firmware: Standard Bluetooth controller (0x00) Version 252.16862 Build 1121034987
    [00:00:00.035,888] <inf> bt_hci_core: HCI transport: IPC
    [00:00:00.035,980] <inf> bt_hci_core: Identity: ED:68:9A:DB:A1:6E (random)
    [00:00:00.035,980] <inf> bt_hci_core: HCI: version 6.1 (0x0f) revision 0x2069, manufacturer 0x0059
    [00:00:00.036,010] <inf> bt_hci_core: LMP: version 6.1 (0x0f) subver 0x2069
    [00:00:00.038,085] <inf> smp_bt_sample: Advertising successfully started
    uart:~$ 

  • Thanks a lot for the test. I also did some more digging into my application and found out that when `TASK_WDT_HW_FALLBACK_DELAY` and `TASK_WDT_MIN_TIMEOUT` were set too low (i.e. to 100), the watchdog kicked in almost right after the image upgrade was scheduled. I could then see that the reboot reason was "watchdog | software" instead of just "software", and that the value of the CRV register was reset to 0xFFFFFFFF.

    Leaving `TASK_WDT_HW_FALLBACK_DELAY` and `TASK_WDT_MIN_TIMEOUT` with their default values fixed that, and now I can see that the reset reason read out during mcuboot is now the same as in your log. So I'd say the watchdog behaves exactly as documented.

    I still haven't been able to figure out yet why my device reboots multiple times during DFU, but I believe it has something to do with my application and not nrf/zephyr.

  • Thank you for the update. Yes, if the WDT is configured with a too short timeout (I'm not sure what the exact min. is), the bootloader WD feed mechanism will not be able to reload the WDT in time. Thank you for reporting back what the problem was.

Related