From bea8b25c5d3cb68c5e6a3b5a000de441f9f97569 Mon Sep 17 00:00:00 2001 From: bugobliterator Date: Wed, 15 Nov 2023 15:41:27 +1100 Subject: [PATCH] AP_HAL_ChibiOS: add support for early initialisation of WATCHDOG This is needed for Ardupilot Vehicle builds running on AP_Periph bootloaders --- libraries/AP_HAL_ChibiOS/HAL_ChibiOS_Class.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libraries/AP_HAL_ChibiOS/HAL_ChibiOS_Class.cpp b/libraries/AP_HAL_ChibiOS/HAL_ChibiOS_Class.cpp index 2355fe4be5..e362804b91 100644 --- a/libraries/AP_HAL_ChibiOS/HAL_ChibiOS_Class.cpp +++ b/libraries/AP_HAL_ChibiOS/HAL_ChibiOS_Class.cpp @@ -268,10 +268,12 @@ static void main_loop() #ifdef IOMCU_FW stm32_watchdog_init(); #elif !defined(HAL_BOOTLOADER_BUILD) +#if !defined(HAL_EARLY_WATCHDOG_INIT) // setup watchdog to reset if main loop stops if (AP_BoardConfig::watchdog_enabled()) { stm32_watchdog_init(); } +#endif if (hal.util->was_watchdog_reset()) { INTERNAL_ERROR(AP_InternalError::error_t::watchdog_reset); @@ -314,6 +316,10 @@ static void main_loop() void HAL_ChibiOS::run(int argc, char * const argv[], Callbacks* callbacks) const { +#if defined(HAL_EARLY_WATCHDOG_INIT) && !defined(DISABLE_WATCHDOG) + stm32_watchdog_init(); + stm32_watchdog_pat(); +#endif /* * System initializations. * - ChibiOS HAL initialization, this also initializes the configured device drivers