stm32/boards: Allow boards to have finer control over the linker script.

This patch allows a particular board to independently specify the linker
scripts for 1) the MCU memory layout; 2) how the different firmware
sections are arranged in memory.  Right now all boards follow the same
layout with two separate firmware section, one for the ISR and one for the
text and data.  This leaves room for storage (filesystem data) to live
between the firmware sections.

The idea with this patch is to accommodate boards that don't have internal
flash storage and only need to have one continuous firmware section.  Thus
the common.ld script is renamed to common_ifs.ld to make explicit that it
is used for cases where the board has internal flash storage.
pull/1/head
Damien George 2018-03-27 21:17:48 +11:00
parent a6009a9e35
commit 7aec06ca9a
39 changed files with 40 additions and 60 deletions

View File

@ -80,7 +80,7 @@ CFLAGS += -DMICROPY_FLOAT_IMPL=MICROPY_FLOAT_IMPL_FLOAT
CFLAGS += -fsingle-precision-constant -Wdouble-promotion
endif
LDFLAGS = -nostdlib -L $(LD_DIR) -T $(LD_FILE) -Map=$(@:.elf=.map) --cref
LDFLAGS = -nostdlib -L $(LD_DIR) $(addprefix -T,$(LD_FILES)) -Map=$(@:.elf=.map) --cref
LIBS = $(shell $(CC) $(CFLAGS) -print-libgcc-file-name)
# Remove uncalled code from the final image.

View File

@ -3,6 +3,6 @@ CMSIS_MCU = STM32L475xx
# The stm32l475 does not have a LDC controller which is
# the only diffrence to the stm32l476 - so reuse some files.
AF_FILE = boards/stm32l476_af.csv
LD_FILE = boards/stm32l476xg.ld
LD_FILES = boards/stm32l476xg.ld boards/common_ifs.ld
TEXT_ADDR = 0x08004000
OPENOCD_CONFIG = boards/openocd_stm32l4.cfg

View File

@ -1,4 +1,4 @@
MCU_SERIES = f4
CMSIS_MCU = STM32F405xx
AF_FILE = boards/stm32f405_af.csv
LD_FILE = boards/stm32f405.ld
LD_FILES = boards/stm32f405.ld boards/common_ifs.ld

View File

@ -1,7 +1,7 @@
MCU_SERIES = f4
CMSIS_MCU = STM32F401xE
AF_FILE = boards/stm32f401_af.csv
LD_FILE = boards/stm32f401xd.ld
LD_FILES = boards/stm32f401xd.ld boards/common_ifs.ld
# Don't include default frozen modules because MCU is tight on flash space
FROZEN_MPY_DIR ?=

View File

@ -1,4 +1,4 @@
MCU_SERIES = f4
CMSIS_MCU = STM32F405xx
AF_FILE = boards/stm32f405_af.csv
LD_FILE = boards/stm32f405.ld
LD_FILES = boards/stm32f405.ld boards/common_ifs.ld

View File

@ -1,5 +1,5 @@
MCU_SERIES = l4
CMSIS_MCU = STM32L476xx
AF_FILE = boards/stm32l476_af.csv
LD_FILE = boards/stm32l476xe.ld
LD_FILES = boards/stm32l476xe.ld boards/common_ifs.ld
TEXT_ADDR = 0x08004000

View File

@ -1,4 +1,4 @@
MCU_SERIES = f4
CMSIS_MCU = STM32F405xx
AF_FILE = boards/stm32f405_af.csv
LD_FILE = boards/stm32f405.ld
LD_FILES = boards/stm32f405.ld boards/common_ifs.ld

View File

@ -1,4 +1,4 @@
MCU_SERIES = f4
CMSIS_MCU = STM32F401xE
AF_FILE = boards/stm32f401_af.csv
LD_FILE = boards/stm32f401xe.ld
LD_FILES = boards/stm32f401xe.ld boards/common_ifs.ld

View File

@ -1,4 +1,4 @@
MCU_SERIES = f4
CMSIS_MCU = STM32F411xE
AF_FILE = boards/stm32f411_af.csv
LD_FILE = boards/stm32f411.ld
LD_FILES = boards/stm32f411.ld boards/common_ifs.ld

View File

@ -1,4 +1,4 @@
MCU_SERIES = f4
CMSIS_MCU = STM32F429xx
AF_FILE = boards/stm32f429_af.csv
LD_FILE = boards/stm32f429.ld
LD_FILES = boards/stm32f429.ld boards/common_ifs.ld

View File

@ -1,4 +1,4 @@
MCU_SERIES = f4
CMSIS_MCU = STM32F446xx
AF_FILE = boards/stm32f429_af.csv
LD_FILE = boards/stm32f411.ld
LD_FILES = boards/stm32f411.ld boards/common_ifs.ld

View File

@ -1,4 +1,4 @@
MCU_SERIES = f7
CMSIS_MCU = STM32F746xx
AF_FILE = boards/stm32f746_af.csv
LD_FILE = boards/stm32f746.ld
LD_FILES = boards/stm32f746.ld boards/common_ifs.ld

View File

@ -2,4 +2,4 @@ MCU_SERIES = f7
CMSIS_MCU = STM32F767xx
MICROPY_FLOAT_IMPL = double
AF_FILE = boards/stm32f767_af.csv
LD_FILE = boards/stm32f767.ld
LD_FILES = boards/stm32f767.ld boards/common_ifs.ld

View File

@ -1,5 +1,5 @@
MCU_SERIES = l4
CMSIS_MCU = STM32L476xx
AF_FILE = boards/stm32l476_af.csv
LD_FILE = boards/stm32l476xg.ld
LD_FILES = boards/stm32l476xg.ld boards/common_ifs.ld
TEXT_ADDR = 0x08004000

View File

@ -1,4 +1,4 @@
MCU_SERIES = f4
CMSIS_MCU = STM32F407xx
AF_FILE = boards/stm32f405_af.csv
LD_FILE = boards/stm32f405.ld
LD_FILES = boards/stm32f405.ld boards/common_ifs.ld

View File

@ -1,4 +1,4 @@
MCU_SERIES = f4
CMSIS_MCU = STM32F411xE
AF_FILE = boards/stm32f411_af.csv
LD_FILE = boards/stm32f411.ld
LD_FILES = boards/stm32f411.ld boards/common_ifs.ld

View File

@ -1,4 +1,4 @@
MCU_SERIES = f4
CMSIS_MCU = STM32F405xx
AF_FILE = boards/stm32f405_af.csv
LD_FILE = boards/stm32f405.ld
LD_FILES = boards/stm32f405.ld boards/common_ifs.ld

View File

@ -1,4 +1,4 @@
MCU_SERIES = f4
CMSIS_MCU = STM32F405xx
AF_FILE = boards/stm32f405_af.csv
LD_FILE = boards/stm32f405.ld
LD_FILES = boards/stm32f405.ld boards/common_ifs.ld

View File

@ -1,4 +1,4 @@
MCU_SERIES = f4
CMSIS_MCU = STM32F405xx
AF_FILE = boards/stm32f405_af.csv
LD_FILE = boards/stm32f405.ld
LD_FILES = boards/stm32f405.ld boards/common_ifs.ld

View File

@ -1,4 +1,4 @@
MCU_SERIES = f4
CMSIS_MCU = STM32F405xx
AF_FILE = boards/stm32f405_af.csv
LD_FILE = boards/stm32f405.ld
LD_FILES = boards/stm32f405.ld boards/common_ifs.ld

View File

@ -1,4 +1,4 @@
MCU_SERIES = f4
CMSIS_MCU = STM32F411xE
AF_FILE = boards/stm32f411_af.csv
LD_FILE = boards/stm32f411.ld
LD_FILES = boards/stm32f411.ld boards/common_ifs.ld

View File

@ -1,4 +1,4 @@
MCU_SERIES = f4
CMSIS_MCU = STM32F429xx
AF_FILE = boards/stm32f429_af.csv
LD_FILE = boards/stm32f429.ld
LD_FILES = boards/stm32f429.ld boards/common_ifs.ld

View File

@ -1,4 +1,4 @@
MCU_SERIES = f4
CMSIS_MCU = STM32F439xx
AF_FILE = boards/stm32f439_af.csv
LD_FILE = boards/stm32f439.ld
LD_FILES = boards/stm32f439.ld boards/common_ifs.ld

View File

@ -1,4 +1,4 @@
MCU_SERIES = f4
CMSIS_MCU = STM32F407xx
AF_FILE = boards/stm32f405_af.csv
LD_FILE = boards/stm32f405.ld
LD_FILES = boards/stm32f405.ld boards/common_ifs.ld

View File

@ -2,4 +2,4 @@ MCU_SERIES = f7
CMSIS_MCU = STM32F769xx
MICROPY_FLOAT_IMPL = double
AF_FILE = boards/stm32f767_af.csv
LD_FILE = boards/stm32f769.ld
LD_FILES = boards/stm32f769.ld boards/common_ifs.ld

View File

@ -1,4 +1,4 @@
MCU_SERIES = f7
CMSIS_MCU = STM32F746xx
AF_FILE = boards/stm32f746_af.csv
LD_FILE = boards/stm32f746.ld
LD_FILES = boards/stm32f746.ld boards/common_ifs.ld

View File

@ -1,6 +1,6 @@
MCU_SERIES = l4
CMSIS_MCU = STM32L476xx
AF_FILE = boards/stm32l476_af.csv
LD_FILE = boards/stm32l476xg.ld
LD_FILES = boards/stm32l476xg.ld boards/common_ifs.ld
TEXT_ADDR = 0x08004000
OPENOCD_CONFIG = boards/openocd_stm32l4.cfg

View File

@ -1,3 +1,16 @@
/* Memory layout for internal flash storage configuration:
FLASH_ISR .isr_vector
FLASH_TEXT .text
FLASH_TEXT .data
RAM .data
RAM .bss
RAM .heap
RAM .stack
*/
ENTRY(Reset_Handler)
/* define output sections */

View File

@ -21,9 +21,6 @@ _minimum_heap_size = 16K;
aligned for a call. */
_estack = ORIGIN(RAM) + LENGTH(RAM);
/* define common sections and symbols */
INCLUDE common.ld
/* RAM extents for the garbage collector */
_ram_start = ORIGIN(RAM);
_ram_end = ORIGIN(RAM) + LENGTH(RAM);

View File

@ -21,9 +21,6 @@ _minimum_heap_size = 16K;
aligned for a call. */
_estack = ORIGIN(RAM) + LENGTH(RAM);
/* define common sections and symbols */
INCLUDE common.ld
/* RAM extents for the garbage collector */
_ram_start = ORIGIN(RAM);
_ram_end = ORIGIN(RAM) + LENGTH(RAM);

View File

@ -22,9 +22,6 @@ _minimum_heap_size = 16K;
aligned for a call. */
_estack = ORIGIN(RAM) + LENGTH(RAM);
/* define common sections and symbols */
INCLUDE common.ld
/* RAM extents for the garbage collector */
_ram_start = ORIGIN(RAM);
_ram_end = ORIGIN(RAM) + LENGTH(RAM);

View File

@ -21,9 +21,6 @@ _minimum_heap_size = 16K;
aligned for a call. */
_estack = ORIGIN(RAM) + LENGTH(RAM);
/* define common sections and symbols */
INCLUDE common.ld
/* RAM extents for the garbage collector */
_ram_start = ORIGIN(RAM);
_ram_end = ORIGIN(RAM) + LENGTH(RAM);

View File

@ -22,9 +22,6 @@ _minimum_heap_size = 16K;
aligned for a call. */
_estack = ORIGIN(RAM) + LENGTH(RAM);
/* define common sections and symbols */
INCLUDE common.ld
/* RAM extents for the garbage collector */
_ram_start = ORIGIN(RAM);
_ram_end = ORIGIN(RAM) + LENGTH(RAM);

View File

@ -21,9 +21,6 @@ _minimum_heap_size = 16K;
/* top end of the stack */
_estack = ORIGIN(RAM) + LENGTH(RAM);
/* define common sections and symbols */
INCLUDE common.ld
/* RAM extents for the garbage collector */
_ram_start = ORIGIN(RAM);
_ram_end = ORIGIN(RAM) + LENGTH(RAM);

View File

@ -22,9 +22,6 @@ _minimum_heap_size = 16K;
aligned for a call. */
_estack = ORIGIN(RAM) + LENGTH(RAM);
/* define common sections and symbols */
INCLUDE common.ld
/* RAM extents for the garbage collector */
_ram_start = ORIGIN(RAM);
_ram_end = ORIGIN(RAM) + LENGTH(RAM);

View File

@ -22,9 +22,6 @@ _minimum_heap_size = 16K;
aligned for a call. */
_estack = ORIGIN(RAM) + LENGTH(RAM);
/* define common sections and symbols */
INCLUDE common.ld
/* RAM extents for the garbage collector */
_ram_start = ORIGIN(RAM);
_ram_end = ORIGIN(RAM) + LENGTH(RAM);

View File

@ -22,9 +22,6 @@ _minimum_heap_size = 16K;
aligned for a call. */
_estack = ORIGIN(RAM) + LENGTH(RAM);
/* define common sections and symbols */
INCLUDE common.ld
/* RAM extents for the garbage collector */
_ram_start = ORIGIN(RAM);
_ram_end = ORIGIN(RAM) + LENGTH(RAM);

View File

@ -22,9 +22,6 @@ _minimum_heap_size = 16K;
aligned for a call. */
_estack = ORIGIN(RAM) + LENGTH(RAM);
/* define common sections and symbols */
INCLUDE common.ld
/* RAM extents for the garbage collector */
_ram_start = ORIGIN(RAM);
_ram_end = ORIGIN(RAM) + LENGTH(RAM);

View File

@ -24,9 +24,6 @@ _minimum_heap_size = 16K;
aligned for a call. */
_estack = ORIGIN(RAM) + LENGTH(RAM);
/* define common sections and symbols */
INCLUDE common.ld
/* RAM extents for the garbage collector */
_ram_start = ORIGIN(RAM);
_ram_end = ORIGIN(RAM) + LENGTH(RAM);