Skip to content

Commit ab03b91

Browse files
eHammarstromnvlsianpu
authored andcommitted
boot/zephyr: add nrfx watchdog kick during boot region copy
This fixes soft-bricks that we have seen as a result of the bootloader being interrupted by the watchdog. Signed-off-by: Emil Hammarstrom <[email protected]> Signed-off-by: Andrzej Puzdrowski <[email protected]>
1 parent 05722f4 commit ab03b91

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

boot/zephyr/include/mcuboot_config/mcuboot_config.h

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,38 @@
154154

155155
#endif /* !__BOOTSIM__ */
156156

157+
#if CONFIG_NRFX_WDT
158+
#include <nrfx_wdt.h>
159+
160+
#define FEED_WDT_INST(id) \
161+
do { \
162+
nrfx_wdt_t wdt_inst_##id = NRFX_WDT_INSTANCE(id); \
163+
for (uint8_t i = 0; i < NRF_WDT_CHANNEL_NUMBER; i++) \
164+
{ \
165+
nrf_wdt_reload_request_set(wdt_inst_##id.p_reg, \
166+
(nrf_wdt_rr_register_t)(NRF_WDT_RR0 + i)); \
167+
} \
168+
} while (0)
169+
#if defined(CONFIG_NRFX_WDT0) && defined(CONFIG_NRFX_WDT1)
170+
#define MCUBOOT_WATCHDOG_FEED() \
171+
do { \
172+
FEED_WDT_INST(0); \
173+
FEED_WDT_INST(1); \
174+
} while (0)
175+
#elif defined(CONFIG_NRFX_WDT0)
176+
#define MCUBOOT_WATCHDOG_FEED() \
177+
FEED_WDT_INST(0);
178+
#else /* defined(CONFIG_NRFX_WDT0) && defined(CONFIG_NRFX_WDT1) */
179+
#error "No NRFX WDT instances enabled"
180+
#endif /* defined(CONFIG_NRFX_WDT0) && defined(CONFIG_NRFX_WDT1) */
181+
182+
#else /* CONFIG_NRFX_WDT */
183+
157184
#define MCUBOOT_WATCHDOG_FEED() \
158185
do { \
159186
/* TODO: to be implemented */ \
160187
} while (0)
161188

189+
#endif /* CONFIG_NRFX_WDT */
190+
162191
#endif /* __MCUBOOT_CONFIG_H__ */

0 commit comments

Comments
 (0)