File tree Expand file tree Collapse file tree 6 files changed +38
-11
lines changed Expand file tree Collapse file tree 6 files changed +38
-11
lines changed Original file line number Diff line number Diff line change @@ -56,7 +56,10 @@ CFLAGS += $(INC) -Wall -Werror -std=c99 -nostdlib -mthumb $(CFLAGS_MCU) -fsingle
56
56
CFLAGS += -DMCU_$(MCU_SERIES ) -D__$(CMSIS_MCU ) __
57
57
CFLAGS += $(CFLAGS_EXTRA )
58
58
59
- LDFLAGS += -nostdlib $(addprefix -T,$(LD_FILES ) ) -Map=$@ .map --cref
59
+ LDDEFINES = \
60
+ -DMICROPY_HW_CODESIZE=$(MICROPY_HW_CODESIZE )
61
+
62
+ LDFLAGS += -nostdlib -Map=$@ .map --cref
60
63
61
64
LIBS += $(shell $(CC ) $(CFLAGS ) -print-libgcc-file-name)
62
65
@@ -169,8 +172,10 @@ endif
169
172
all : $(BUILD ) /firmware.uf2
170
173
171
174
$(BUILD ) /firmware.elf : $(OBJ )
175
+ $(ECHO ) " PREPROCESS LINK $@ "
176
+ $(Q )$(CC ) -E -x c $(LDDEFINES ) $(LD_FILES ) | grep -v ' ^#' > $(BUILD ) /link.ld
172
177
$(ECHO ) " LINK $@ "
173
- $(Q )$(LD ) $(LDFLAGS ) -o $@ $^ $(LIBS )
178
+ $(Q )$(LD ) -T $( BUILD ) /link.ld $(LDFLAGS ) -o $@ $^ $(LIBS )
174
179
$(Q )$(SIZE ) $@
175
180
176
181
$(BUILD ) /firmware.bin : $(BUILD ) /firmware.elf
Original file line number Diff line number Diff line change 2
2
GNU linker script for SAMD21
3
3
*/
4
4
5
+ /* MICROPY_HW_CODESIZE is defined in mpconfigmcu.mk or mpconfigboard.mk */
6
+
7
+ _flashsize = 256K; /* The physical flash size */
8
+ _bootloader = 8K; /* Must match the ORIGIN value of FLASH */
9
+ _codesize = MICROPY_HW_CODESIZE; /* the space dedicated to code */
10
+
5
11
/* Specify the memory areas */
6
12
MEMORY
7
13
{
8
- FLASH (rx) : ORIGIN = 0x00002000, LENGTH = 256K - 8K
14
+ FLASH (rx) : ORIGIN = 0x00002000, LENGTH = _codesize
9
15
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 32K
10
16
}
11
17
12
18
/* Top end of the stack, with room for double-tap variable */
13
19
_estack = ORIGIN (RAM) + LENGTH (RAM) - 8;
14
20
_sstack = _estack - 8K;
15
21
16
- _oflash_fs = ORIGIN (FLASH) + 192K - 8K ;
17
- _sflash_fs = LENGTH (FLASH) - 192K + 8K - 1 ;
22
+ _oflash_fs = ORIGIN (FLASH) + _codesize ;
23
+ _sflash_fs = _flashsize - _codesize - _bootloader ;
18
24
19
25
_sheap = _ebss;
20
26
_eheap = _sstack;
Original file line number Diff line number Diff line change 2
2
GNU linker script for SAMD51
3
3
*/
4
4
5
+ /* MICROPY_HW_CODESIZE is defined in mpconfigmcu.mk or mpconfigboard.mk */
6
+
7
+ _flashsize = 512K; /* The physical flash size */
8
+ _bootloader = 16K; /* Must match the ORIGIN value of FLASH */
9
+ _codesize = MICROPY_HW_CODESIZE; /* the space dedicated to code */
10
+
5
11
/* Specify the memory areas */
6
12
MEMORY
7
13
{
8
- FLASH (rx) : ORIGIN = 0x00004000, LENGTH = 512K - 16K
14
+ FLASH (rx) : ORIGIN = 0x00004000, LENGTH = _codesize
9
15
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 192K
10
16
}
11
17
12
18
/* Top end of the stack, with room for double-tap variable */
13
19
_estack = ORIGIN (RAM) + LENGTH (RAM) - 8;
14
20
_sstack = _estack - 16K;
15
21
16
- _oflash_fs = ORIGIN (FLASH) + 384K - 16K ;
17
- _sflash_fs = LENGTH (FLASH) - 384K + 16K - 1 ;
22
+ _oflash_fs = ORIGIN (FLASH) + _codesize ;
23
+ _sflash_fs = _flashsize - _codesize - _bootloader ;
18
24
19
25
_sheap = _ebss;
20
26
_eheap = _sstack;
Original file line number Diff line number Diff line change 2
2
GNU linker script for SAMD51x20
3
3
*/
4
4
5
+ /* MICROPY_HW_CODESIZE is defined in mpconfigmcu.mk or mpconfigboard.mk */
6
+
7
+ _flashsize = 1024K; /* The physical flash size */
8
+ _bootloader = 16K; /* Must match the ORIGIN value of FLASH */
9
+ _codesize = MICROPY_HW_CODESIZE; /* the space dedicated to code */
10
+
5
11
/* Specify the memory areas */
6
12
MEMORY
7
13
{
8
- FLASH (rx) : ORIGIN = 0x00004000, LENGTH = 1024K - 16K
14
+ FLASH (rx) : ORIGIN = 0x00004000, LENGTH = _codesize
9
15
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 256K
10
16
}
11
17
12
18
/* Top end of the stack, with room for double-tap variable */
13
19
_estack = ORIGIN (RAM) + LENGTH (RAM) - 8;
14
20
_sstack = _estack - 16K;
15
21
16
- _oflash_fs = ORIGIN (FLASH) + 384K - 16K ;
17
- _sflash_fs = LENGTH (FLASH) - 384K + 16K - 1 ;
22
+ _oflash_fs = ORIGIN (FLASH) + _codesize ;
23
+ _sflash_fs = _flashsize - _codesize - _bootloader ;
18
24
19
25
_sheap = _ebss;
20
26
_eheap = _sstack;
Original file line number Diff line number Diff line change @@ -2,6 +2,8 @@ CFLAGS_MCU += -mtune=cortex-m0plus -mcpu=cortex-m0plus -msoft-float
2
2
3
3
MPY_CROSS_MCU_ARCH = armv6m
4
4
5
+ MICROPY_HW_CODESIZE ?= 184K
6
+
5
7
SRC_S += shared/runtime/gchelper_thumb1.s
6
8
7
9
LIBM_SRC_C += $(addprefix lib/libm/,\
Original file line number Diff line number Diff line change @@ -2,6 +2,8 @@ CFLAGS_MCU += -mtune=cortex-m4 -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=har
2
2
3
3
MPY_CROSS_MCU_ARCH = armv7m
4
4
5
+ MICROPY_HW_CODESIZE ?= 368K
6
+
5
7
MICROPY_VFS_LFS2 ?= 1
6
8
MICROPY_VFS_FAT ?= 1
7
9
FROZEN_MANIFEST ?= mcu/$(MCU_SERIES_LOWER ) /manifest.py
You can’t perform that action at this time.
0 commit comments