Skip to content

Commit 442f5a4

Browse files
committed
boot: Allow watchdog timeout to be configured
This change adds a new Kconfig option MCUBOOT_WATCHDOG_TIMEOUT to specify the watchdog timeout value. Several devices (NXP among others) require a timeout to be installed in order to enable the watchdog. Signed-off-by: Karl Kristian Dyrholm Torp <[email protected]>
1 parent f74b77c commit 442f5a4

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

boot/zephyr/Kconfig

+8
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,14 @@ config BOOT_WATCHDOG_FEED_NRFX_WDT
750750
imply NRFX_WDT30
751751
imply NRFX_WDT31
752752

753+
config MCUBOOT_WATCHDOG_TIMEOUT
754+
int "Watchdog timeout in milliseconds"
755+
default 0
756+
depends on BOOT_WATCHDOG_FEED
757+
help
758+
Specify the watchdog timeout for devices that require a timeout
759+
installed to setup the watchdog.
760+
753761
config BOOT_IMAGE_ACCESS_HOOKS
754762
bool "Enable hooks for overriding MCUboot's native routines"
755763
help

boot/zephyr/include/mcuboot_config/mcuboot_config.h

+17
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,22 @@
371371
#include <zephyr/device.h>
372372
#include <zephyr/drivers/watchdog.h>
373373

374+
#if CONFIG_MCUBOOT_WATCHDOG_TIMEOUT
375+
#define MCUBOOT_WATCHDOG_INSTALL_TIMEOUT() \
376+
do { \
377+
struct wdt_timeout_cfg wdtConfig = { \
378+
.flags = WDT_FLAG_RESET_SOC, \
379+
.window.min = 0, \
380+
.window.max = CONFIG_MCUBOOT_WATCHDOG_TIMEOUT \
381+
}; \
382+
wdt_install_timeout(wdt, &wdtConfig); \
383+
} while (0)
384+
#else
385+
#define MCUBOOT_WATCHDOG_INSTALL_TIMEOUT() \
386+
do { \
387+
} while (0)
388+
#endif /* CONFIG_MCUBOOT_WATCHDOG_TIMEOUT */
389+
374390
#define MCUBOOT_WATCHDOG_SETUP() \
375391
do { \
376392
const struct device* wdt = \
@@ -385,6 +401,7 @@
385401
const struct device* wdt = \
386402
DEVICE_DT_GET(DT_ALIAS(watchdog0)); \
387403
if (device_is_ready(wdt)) { \
404+
MCUBOOT_WATCHDOG_INSTALL_TIMEOUT(); \
388405
wdt_feed(wdt, 0); \
389406
} \
390407
} while (0)

0 commit comments

Comments
 (0)