Make flash and bootloader sizes configurable

This patch makes allocating special pages automatic and flexible,
allowing flash size and application start offset specification with
linker command line arguments. It should allow easier porting to
different targets and experimentation without adding code complexity.

Many original STM32F103x8 chips have fully functional 128 kiB flash and
so this additional space might come useful for experimentation,
additional optional features etc. Tested on v2.51A board, including
writing and verifying 128 kiB of random data.

Make variables are added to control that, so to build for the full
undocumented flash size and dapboot configured to start the app from 8
kiB offset one can run:

make flash_size=128k bootldr_size=0x2000
This commit is contained in:
Paul Fertser
2020-06-15 14:48:51 +03:00
parent 76099406ef
commit 780f1f35ca
6 changed files with 40 additions and 35 deletions

View File

@@ -49,9 +49,11 @@ OUTPUT_DIR=Objects
# code optimisation ------------------------------------------------------------
OPTIM=-Os -flto -ffat-lto-objects -finline-small-functions -findirect-inlining -fdiagnostics-color -ffunction-sections -fdata-sections
flash_size=64k
bootldr_size=0x4000
# global defines ---------------------------------------------------------------
GLOBAL_DEFINES += -D STM32F103T8Ux -D STM32F1 -D STM32 -D USE_HAL_DRIVER -D STM32F103xB -D USE_RTOS_SYSTICK -D LANG_$(lang) -D LANG -D MODEL_$(model)
GLOBAL_DEFINES += -D STM32F103T8Ux -D STM32F1 -D STM32 -D USE_HAL_DRIVER -D STM32F103xB -D USE_RTOS_SYSTICK -D LANG_$(lang) -D LANG -D MODEL_$(model) -DVECT_TAB_OFFSET=$(bootldr_size)U
# Enable debug code generation
DEBUG=-g3
@@ -93,6 +95,8 @@ LINKER_FLAGS=-Wl,--gc-sections \
-mthumb \
-mfloat-abi=soft \
-lm -Os -flto -Wl,--undefined=vTaskSwitchContext \
-Wl,--defsym=__FLASH_SIZE__=$(flash_size) \
-Wl,--defsym=__BOOTLDR_SIZE__=$(bootldr_size) \
--specs=nano.specs
# compiler flags ---------------------------------------------------------------