From 1c807e0078097956bfa01ed65bbd245313779f89 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 23 Jun 2018 12:10:05 +1000 Subject: [PATCH] HAL_ChibiOS: added option to limit size of bootloader this will ensure our F4 bootloaders stay under 16k --- libraries/AP_HAL_ChibiOS/hwdef/revo-mini/hwdef-bl.dat | 3 +++ libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/libraries/AP_HAL_ChibiOS/hwdef/revo-mini/hwdef-bl.dat b/libraries/AP_HAL_ChibiOS/hwdef/revo-mini/hwdef-bl.dat index 7b89cc7954..b8e455a834 100644 --- a/libraries/AP_HAL_ChibiOS/hwdef/revo-mini/hwdef-bl.dat +++ b/libraries/AP_HAL_ChibiOS/hwdef/revo-mini/hwdef-bl.dat @@ -13,6 +13,9 @@ STM32_PLLM_VALUE 8 FLASH_SIZE_KB 1024 +# don't allow bootloader to use more than 16k +FLASH_USE_MAX_KB 16 + USB_STRING_PRODUCT "ArduPilot-revo-BL" # bootloader is installed at zero offset diff --git a/libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py b/libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py index dbdfec8369..9b44a112a9 100644 --- a/libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py +++ b/libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py @@ -447,7 +447,9 @@ def write_mcu_config(f): def write_ldscript(fname): '''write ldscript.ld for this board''' - flash_size = get_config('FLASH_SIZE_KB', type=int) + flash_size = get_config('FLASH_USE_MAX_KB', type=int, default=0) + if flash_size == 0: + flash_size = get_config('FLASH_SIZE_KB', type=int) # space to reserve for bootloader and storage at start of flash flash_reserve_start = get_config(