From 1cb4bc223de7d81c2af0d21cece1d3d616de9b4c Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Thu, 16 Feb 2023 11:18:48 +1100 Subject: [PATCH] AP_HAL_ChibiOS: entirely remove check_limit_flash_1M if not needed taking up valuable space on non-F427 boards --- Tools/AP_Bootloader/AP_Bootloader.cpp | 2 ++ libraries/AP_HAL_ChibiOS/hwdef/common/stm32_util.c | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Tools/AP_Bootloader/AP_Bootloader.cpp b/Tools/AP_Bootloader/AP_Bootloader.cpp index bc8ec9ef8e..abe4c0c9cb 100644 --- a/Tools/AP_Bootloader/AP_Bootloader.cpp +++ b/Tools/AP_Bootloader/AP_Bootloader.cpp @@ -62,9 +62,11 @@ AP_FlashIface_JEDEC ext_flash; int main(void) { +#ifdef STM32F427xx if (BOARD_FLASH_SIZE > 1024 && check_limit_flash_1M()) { board_info.fw_size = (1024 - (FLASH_BOOTLOADER_LOAD_KB + APP_START_OFFSET_KB))*1024; } +#endif bool try_boot = false; uint32_t timeout = HAL_BOOTLOADER_TIMEOUT; diff --git a/libraries/AP_HAL_ChibiOS/hwdef/common/stm32_util.c b/libraries/AP_HAL_ChibiOS/hwdef/common/stm32_util.c index aa85c75d33..f99c3fd1e6 100644 --- a/libraries/AP_HAL_ChibiOS/hwdef/common/stm32_util.c +++ b/libraries/AP_HAL_ChibiOS/hwdef/common/stm32_util.c @@ -565,9 +565,9 @@ unsigned int stm32_rand_generate_nonblocking(unsigned char* output, unsigned int /* see if we should limit flash to 1M on devices with older revisions of STM32F427 */ +#ifdef STM32F427xx bool check_limit_flash_1M(void) { -#ifdef STM32F427xx const uint16_t revid = (*(uint32_t *)DBGMCU_BASE) >> 16; static const uint16_t badrevs[4] = { 0x1000, 0x1001, 0x1003, 0x1007 }; for (uint8_t i=0; i<4; i++) { @@ -575,6 +575,6 @@ bool check_limit_flash_1M(void) return true; } } -#endif return false; } +#endif