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>
pull/11106/head
robert-hh 2023-01-27 16:02:05 +01:00 zatwierdzone przez Damien George
rodzic 457d9ee68a
commit 315eb949da
6 zmienionych plików z 40 dodań i 9 usunięć

Wyświetl plik

@ -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)

Wyświetl plik

@ -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;

Wyświetl plik

@ -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;

Wyświetl plik

@ -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;

Wyświetl plik

@ -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/,\

Wyświetl plik

@ -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