diff options
| author | robert-hh <robert@hammelrath.com> | 2023-01-27 16:02:05 +0100 |
|---|---|---|
| committer | Damien George <damien@micropython.org> | 2023-05-22 18:36:29 +1000 |
| commit | 315eb949da3bb3fe476050e164f03b613ca64afa (patch) | |
| tree | f38f3a25945c9739fa9570f64ef55adc14dee551 | |
| parent | 457d9ee68a1e603648eb195c50175c7862be7a7e (diff) | |
samd: Rearrange the MCU-specific loader files.
Such that they are easier to adapt. The maximum code size is set by:
MICROPY_HW_CODESIZE=xxxK
in mpconfigmcu.mk for the MCU family as default or in mpconfigboard.mk for
a specific board. Setting the maximum code size allows the loader to error
out if the code gets larger than the space dedicated for it.
Signed-off-by: robert-hh <robert@hammelrath.com>
| -rw-r--r-- | ports/samd/Makefile | 3 | ||||
| -rw-r--r-- | ports/samd/boards/samd21x18a.ld | 14 | ||||
| -rw-r--r-- | ports/samd/boards/samd51x19a.ld | 14 | ||||
| -rw-r--r-- | ports/samd/boards/samd51x20a.ld | 14 | ||||
| -rw-r--r-- | ports/samd/mcu/samd21/mpconfigmcu.mk | 2 | ||||
| -rw-r--r-- | ports/samd/mcu/samd51/mpconfigmcu.mk | 2 |
6 files changed, 40 insertions, 9 deletions
diff --git a/ports/samd/Makefile b/ports/samd/Makefile index 290453f50..6f7c8fbd8 100644 --- a/ports/samd/Makefile +++ b/ports/samd/Makefile @@ -65,7 +65,10 @@ CFLAGS += $(INC) -Wall -Werror -std=c99 -nostdlib -mthumb $(CFLAGS_MCU) -fsingle CFLAGS += -DMCU_$(MCU_SERIES) -D__$(CMSIS_MCU)__ CFLAGS += $(CFLAGS_EXTRA) +CFLAGS += -DMICROPY_HW_CODESIZE=$(MICROPY_HW_CODESIZE) + LDFLAGS += -nostdlib $(addprefix -T,$(LD_FILES)) -Map=$@.map --cref +LDFLAGS += --defsym=_codesize=$(MICROPY_HW_CODESIZE) LIBS += $(shell $(CC) $(CFLAGS) -print-libgcc-file-name) diff --git a/ports/samd/boards/samd21x18a.ld b/ports/samd/boards/samd21x18a.ld index 81a84a15d..3ab051569 100644 --- a/ports/samd/boards/samd21x18a.ld +++ b/ports/samd/boards/samd21x18a.ld @@ -2,10 +2,18 @@ GNU linker script for SAMD21 */ +/* +_codesize is defined in mpconfigmcu.mk or mpconfigboard.mk as +MICROPY_HW_CODESIZE and is set in Makefile +*/ + +_flashsize = 256K; /* The physical flash size */ +_bootloader = 8K; /* Must match the ORIGIN value of FLASH */ + /* Specify the memory areas */ MEMORY { - FLASH (rx) : ORIGIN = 0x00002000, LENGTH = 256K - 8K + FLASH (rx) : ORIGIN = 0x00002000, LENGTH = _codesize RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 32K } @@ -13,8 +21,8 @@ MEMORY _estack = ORIGIN(RAM) + LENGTH(RAM) - 8; _sstack = _estack - 8K; -_oflash_fs = ORIGIN(FLASH) + 192K - 8K; -_sflash_fs = LENGTH(FLASH) - 192K + 8K - 1; +_oflash_fs = ORIGIN(FLASH) + _codesize; +_sflash_fs = _flashsize - _codesize - _bootloader; _sheap = _ebss; _eheap = _sstack; diff --git a/ports/samd/boards/samd51x19a.ld b/ports/samd/boards/samd51x19a.ld index cd03320ba..30bc8e332 100644 --- a/ports/samd/boards/samd51x19a.ld +++ b/ports/samd/boards/samd51x19a.ld @@ -2,10 +2,18 @@ GNU linker script for SAMD51 */ +/* +_codesize is defined in mpconfigmcu.mk or mpconfigboard.mk as +MICROPY_HW_CODESIZE and is set in Makefile +*/ + +_flashsize = 512K; /* The physical flash size */ +_bootloader = 16K; /* Must match the ORIGIN value of FLASH */ + /* Specify the memory areas */ MEMORY { - FLASH (rx) : ORIGIN = 0x00004000, LENGTH = 512K - 16K + FLASH (rx) : ORIGIN = 0x00004000, LENGTH = _codesize RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 192K } @@ -13,8 +21,8 @@ MEMORY _estack = ORIGIN(RAM) + LENGTH(RAM) - 8; _sstack = _estack - 16K; -_oflash_fs = ORIGIN(FLASH) + 384K - 16K; -_sflash_fs = LENGTH(FLASH) - 384K + 16K - 1; +_oflash_fs = ORIGIN(FLASH) + _codesize; +_sflash_fs = _flashsize - _codesize - _bootloader; _sheap = _ebss; _eheap = _sstack; diff --git a/ports/samd/boards/samd51x20a.ld b/ports/samd/boards/samd51x20a.ld index f0d5e5c6a..472ab316c 100644 --- a/ports/samd/boards/samd51x20a.ld +++ b/ports/samd/boards/samd51x20a.ld @@ -2,10 +2,18 @@ GNU linker script for SAMD51x20 */ +/* +_codesize is defined in mpconfigmcu.mk or mpconfigboard.mk as +MICROPY_HW_CODESIZE and is set in Makefile +*/ + +_flashsize = 1024K; /* The physical flash size */ +_bootloader = 16K; /* Must match the ORIGIN value of FLASH */ + /* Specify the memory areas */ MEMORY { - FLASH (rx) : ORIGIN = 0x00004000, LENGTH = 1024K - 16K + FLASH (rx) : ORIGIN = 0x00004000, LENGTH = _codesize RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 256K } @@ -13,8 +21,8 @@ MEMORY _estack = ORIGIN(RAM) + LENGTH(RAM) - 8; _sstack = _estack - 16K; -_oflash_fs = ORIGIN(FLASH) + 384K - 16K; -_sflash_fs = LENGTH(FLASH) - 384K + 16K - 1; +_oflash_fs = ORIGIN(FLASH) + _codesize; +_sflash_fs = _flashsize - _codesize - _bootloader; _sheap = _ebss; _eheap = _sstack; diff --git a/ports/samd/mcu/samd21/mpconfigmcu.mk b/ports/samd/mcu/samd21/mpconfigmcu.mk index ddd3e8b41..2e16d12a2 100644 --- a/ports/samd/mcu/samd21/mpconfigmcu.mk +++ b/ports/samd/mcu/samd21/mpconfigmcu.mk @@ -2,6 +2,8 @@ CFLAGS_MCU += -mtune=cortex-m0plus -mcpu=cortex-m0plus -msoft-float MPY_CROSS_MCU_ARCH = armv6m +MICROPY_HW_CODESIZE ?= 184K + SRC_S += shared/runtime/gchelper_thumb1.s LIBM_SRC_C += $(addprefix lib/libm/,\ diff --git a/ports/samd/mcu/samd51/mpconfigmcu.mk b/ports/samd/mcu/samd51/mpconfigmcu.mk index 8596f5982..433404fd1 100644 --- a/ports/samd/mcu/samd51/mpconfigmcu.mk +++ b/ports/samd/mcu/samd51/mpconfigmcu.mk @@ -2,6 +2,8 @@ CFLAGS_MCU += -mtune=cortex-m4 -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=har MPY_CROSS_MCU_ARCH = armv7m +MICROPY_HW_CODESIZE ?= 368K + MICROPY_VFS_LFS2 ?= 1 MICROPY_VFS_FAT ?= 1 FROZEN_MANIFEST ?= mcu/$(MCU_SERIES_LOWER)/manifest.py |
