From a2707b48c58b63097c94f191afc7254a6f256bbb Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 24 Jan 2024 11:06:00 +1100 Subject: [PATCH] HAL_ChibiOS: enable clock management on G4 this allows for a different clock tree in the main fw from the bootloader --- libraries/AP_HAL_ChibiOS/CANFDIface.cpp | 2 ++ libraries/AP_HAL_ChibiOS/hwdef/common/stm32g4_mcuconf.h | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/libraries/AP_HAL_ChibiOS/CANFDIface.cpp b/libraries/AP_HAL_ChibiOS/CANFDIface.cpp index f0169a36646902..388db3f07651d4 100644 --- a/libraries/AP_HAL_ChibiOS/CANFDIface.cpp +++ b/libraries/AP_HAL_ChibiOS/CANFDIface.cpp @@ -89,7 +89,9 @@ extern const AP_HAL::HAL& hal; #define STR(x) #x #define XSTR(x) STR(x) +#if !defined(HAL_LLD_USE_CLOCK_MANAGEMENT) static_assert(STM32_FDCANCLK == 80U*1000U*1000U, "FDCAN clock must be 80MHz, got " XSTR(STM32_FDCANCLK)); +#endif using namespace ChibiOS; diff --git a/libraries/AP_HAL_ChibiOS/hwdef/common/stm32g4_mcuconf.h b/libraries/AP_HAL_ChibiOS/hwdef/common/stm32g4_mcuconf.h index ce7eb949070638..3c692db1d5b84b 100644 --- a/libraries/AP_HAL_ChibiOS/hwdef/common/stm32g4_mcuconf.h +++ b/libraries/AP_HAL_ChibiOS/hwdef/common/stm32g4_mcuconf.h @@ -25,6 +25,12 @@ #define STM32_LSEDRV (3U << 3U) #endif +/* + we need to use HAL_LLD_USE_CLOCK_MANAGEMENT in order to allow a + different clock tree in the main firmware from the bootloader. + */ +#define HAL_LLD_USE_CLOCK_MANAGEMENT 1 + /* * STM32G4xx drivers configuration. * The following settings override the default settings present in