summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien George <damien@micropython.org>2021-04-28 16:26:20 +1000
committerDamien George <damien@micropython.org>2021-04-30 00:42:59 +1000
commit58be5a5aa328e687a3560d4a85fb069400b0b8ca (patch)
tree7a83a5affe3d432dfaa9391bbc02d2d20d3761c3
parent97f09fda3e00b4da11bed3d7fb3d83d89deeeafb (diff)
stm32/mboot: Allow a board to customise the linker scripts.
A board can now define MBOOT_LD_FILES (at the Makefile-level) to specify custom linker scripts. And stm32_generic.ld has been split into 2 pieces so one or the other can be reused (usually stm32_sections.ld wolud be reused by a board, and stm32_memory.ld redefined). Signed-off-by: Damien George <damien@micropython.org>
-rwxr-xr-xports/stm32/mboot/Makefile3
-rw-r--r--ports/stm32/mboot/stm32_memory.ld10
-rw-r--r--ports/stm32/mboot/stm32_sections.ld (renamed from ports/stm32/mboot/stm32_generic.ld)10
3 files changed, 14 insertions, 9 deletions
diff --git a/ports/stm32/mboot/Makefile b/ports/stm32/mboot/Makefile
index d57b9368e..de090da1c 100755
--- a/ports/stm32/mboot/Makefile
+++ b/ports/stm32/mboot/Makefile
@@ -85,7 +85,8 @@ CFLAGS += -DBUILDING_MBOOT=$(BUILDING_MBOOT)
CFLAGS += -DMICROPY_HW_STM32WB_FLASH_SYNCRONISATION=0
CFLAGS += -DBOOTLOADER_DFU_USB_VID=$(BOOTLOADER_DFU_USB_VID) -DBOOTLOADER_DFU_USB_PID=$(BOOTLOADER_DFU_USB_PID)
-LDFLAGS = -nostdlib -L . -T stm32_generic.ld -Map=$(@:.elf=.map) --cref
+MBOOT_LD_FILES ?= stm32_memory.ld stm32_sections.ld
+LDFLAGS = -nostdlib -L . $(addprefix -T,$(MBOOT_LD_FILES)) -Map=$(@:.elf=.map) --cref
LIBS = $(shell $(CC) $(CFLAGS) -print-libgcc-file-name)
# Remove uncalled code from the final image.
diff --git a/ports/stm32/mboot/stm32_memory.ld b/ports/stm32/mboot/stm32_memory.ld
new file mode 100644
index 000000000..cfcac4096
--- /dev/null
+++ b/ports/stm32/mboot/stm32_memory.ld
@@ -0,0 +1,10 @@
+/*
+ Linker script fragment for mboot on an STM32xxx MCU.
+ This defines the memory sections for the bootloader to use.
+*/
+
+MEMORY
+{
+ FLASH_BL (rx) : ORIGIN = 0x08000000, LENGTH = 32K
+ RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 120K
+}
diff --git a/ports/stm32/mboot/stm32_generic.ld b/ports/stm32/mboot/stm32_sections.ld
index ade434967..3302c5f97 100644
--- a/ports/stm32/mboot/stm32_generic.ld
+++ b/ports/stm32/mboot/stm32_sections.ld
@@ -1,14 +1,8 @@
/*
- GNU linker script for generic STM32xxx MCU
+ Linker script fragment for mboot on an STM32xxx MCU.
+ This needs the following MEMORY sections to be defined: FLASH_BL, RAM.
*/
-/* Specify the memory areas */
-MEMORY
-{
- FLASH_BL (rx) : ORIGIN = 0x08000000, LENGTH = 32K /* sector 0 (can be 32K) */
- RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 120K
-}
-
/* produce a link error if there is not this amount of RAM for these sections */
_minimum_stack_size = 8K;