diff --git a/boot/zephyr/Kconfig b/boot/zephyr/Kconfig index 197f44918..7fb291ff0 100644 --- a/boot/zephyr/Kconfig +++ b/boot/zephyr/Kconfig @@ -750,6 +750,14 @@ config BOOT_WATCHDOG_FEED_NRFX_WDT imply NRFX_WDT30 imply NRFX_WDT31 +config MCUBOOT_WATCHDOG_TIMEOUT + int "Watchdog timeout in milliseconds" + default 0 + depends on BOOT_WATCHDOG_FEED + help + Specify the watchdog timeout for devices that require a timeout + installed to setup the watchdog. + config BOOT_IMAGE_ACCESS_HOOKS bool "Enable hooks for overriding MCUboot's native routines" help diff --git a/boot/zephyr/include/mcuboot_config/mcuboot_config.h b/boot/zephyr/include/mcuboot_config/mcuboot_config.h index 8d479ced7..83ae2305c 100644 --- a/boot/zephyr/include/mcuboot_config/mcuboot_config.h +++ b/boot/zephyr/include/mcuboot_config/mcuboot_config.h @@ -371,11 +371,28 @@ #include #include +#if CONFIG_MCUBOOT_WATCHDOG_TIMEOUT +#define MCUBOOT_WATCHDOG_INSTALL_TIMEOUT() \ + do { \ + struct wdt_timeout_cfg wdtConfig = { \ + .flags = WDT_FLAG_RESET_SOC, \ + .window.min = 0, \ + .window.max = CONFIG_MCUBOOT_WATCHDOG_TIMEOUT \ + }; \ + wdt_install_timeout(wdt, &wdtConfig); \ + } while (0) +#else +#define MCUBOOT_WATCHDOG_INSTALL_TIMEOUT() \ + do { \ + } while (0) +#endif /* CONFIG_MCUBOOT_WATCHDOG_TIMEOUT */ + #define MCUBOOT_WATCHDOG_SETUP() \ do { \ const struct device* wdt = \ DEVICE_DT_GET(DT_ALIAS(watchdog0)); \ if (device_is_ready(wdt)) { \ + MCUBOOT_WATCHDOG_INSTALL_TIMEOUT(); \ wdt_setup(wdt, 0); \ } \ } while (0)