cypress: Add support for watchdog timer update in boot image
Add watchdog timer to MCUBootApp plus BlinkyApp to implement additional way of boot/upgrade image operation confirmation.
Signed-off-by: Roman Okhrimenko <roman.okhrimenko@cypress.com>
diff --git a/boot/cypress/MCUBootApp/main.c b/boot/cypress/MCUBootApp/main.c
index 2211a28..6c28ba0 100644
--- a/boot/cypress/MCUBootApp/main.c
+++ b/boot/cypress/MCUBootApp/main.c
@@ -38,6 +38,11 @@
#include "bootutil/fault_injection_hardening.h"
+#include "watchdog.h"
+
+/* WDT time out for reset mode, in milliseconds. */
+#define WDT_TIME_OUT_MS 4000
+
/* Define pins for UART debug output */
#define CYBSP_UART_ENABLED 1U
#define CYBSP_UART_HW SCB5
@@ -121,6 +126,12 @@
if (fih_eq(fih_rc, FIH_SUCCESS))
{
BOOT_LOG_INF("User Application validated successfully");
+ /* initialize watchdog timer. it should be updated from user app
+ * to mark successful start up of this app. if the watchdog is not updated,
+ * reset will be initiated by watchdog timer and swap revert operation started
+ * to roll back to operable image.
+ */
+ cy_wdg_init(WDT_TIME_OUT_MS);
do_boot(&rsp);
boot_succeeded = true;
}