From ceea189fa385fb13419729dc8ab23b0e957b0c85 Mon Sep 17 00:00:00 2001 From: bugobliterator Date: Fri, 5 Jul 2024 12:20:35 +1000 Subject: [PATCH] AP_HAL_ChibiOS: enable heap allocation if flash space for bootloader is > 128K --- libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py b/libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py index 7435c42600..e01e4283a4 100644 --- a/libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py +++ b/libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py @@ -1260,7 +1260,12 @@ class ChibiOSHWDef(object): #endif #define STM32_FLASH_DISABLE_ISR 0 ''') - if not self.env_vars['EXT_FLASH_SIZE_MB'] and not args.signed_fw: + # get bootloader flash space, if larger than 128k we can enable Heap + flash_size = self.get_config('FLASH_USE_MAX_KB', type=int, default=0) + if flash_size == 0: + flash_size = self.get_config('FLASH_SIZE_KB', type=int) + flash_length = min(flash_size, self.get_config('FLASH_BOOTLOADER_LOAD_KB', type=int)) + if not self.env_vars['EXT_FLASH_SIZE_MB'] and not args.signed_fw and flash_length < 128: f.write(''' #ifndef CH_CFG_USE_MEMCORE #define CH_CFG_USE_MEMCORE FALSE