Commit 4420bb66 authored by Jeppe Odgaard's avatar Jeppe Odgaard Committed by Dominik Ermel
Browse files

boot: zephyr: setup watchdog

The Zephyr watchdog API defines a setup function. This function needs to
be executed before the watchdog is functional in some cases. This commit
adds MCUBOOT_WATCHDOG_SETUP when using the generic watchdog0 alias
otherwise it is an empty define.

Fixes https://github.com/mcu-tools/mcuboot/issues/1659



Signed-off-by: default avatarJeppe Odgaard <jeppe.odgaard@prevas.dk>
parent 7a8a8f67
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -308,6 +308,15 @@
#include <zephyr/device.h>
#include <zephyr/drivers/watchdog.h>

#define MCUBOOT_WATCHDOG_SETUP()                              \
    do {                                                      \
        const struct device* wdt =                            \
            DEVICE_DT_GET(DT_ALIAS(watchdog0));               \
        if (device_is_ready(wdt)) {                           \
            wdt_setup(wdt, 0);                                \
        }                                                     \
    } while (0)

#define MCUBOOT_WATCHDOG_FEED()                               \
    do {                                                      \
        const struct device* wdt =                            \
@@ -330,6 +339,10 @@

#endif /* CONFIG_BOOT_WATCHDOG_FEED */

#ifndef MCUBOOT_WATCHDOG_SETUP
#define MCUBOOT_WATCHDOG_SETUP()
#endif

#define MCUBOOT_CPU_IDLE() \
  if (!IS_ENABLED(CONFIG_MULTITHREADING)) { \
    k_cpu_idle(); \
+1 −0
Original line number Diff line number Diff line
@@ -509,6 +509,7 @@ void main(void)
    uint32_t reset_cause;
#endif

    MCUBOOT_WATCHDOG_SETUP();
    MCUBOOT_WATCHDOG_FEED();

#if !defined(MCUBOOT_DIRECT_XIP)