File tree Expand file tree Collapse file tree 6 files changed +44
-11
lines changed Expand file tree Collapse file tree 6 files changed +44
-11
lines changed Original file line number Diff line number Diff line change @@ -65,7 +65,10 @@ CFLAGS += $(INC) -Wall -Werror -std=c99 -nostdlib -mthumb $(CFLAGS_MCU) -fsingle
65
65
CFLAGS += -DMCU_$(MCU_SERIES ) -D__$(CMSIS_MCU ) __
66
66
CFLAGS += $(CFLAGS_EXTRA )
67
67
68
- LDFLAGS += -nostdlib $(addprefix -T,$(LD_FILES ) ) -Map=$@ .map --cref
68
+ LDDEFINES = \
69
+ -DMICROPY_HW_CODESIZE=$(MICROPY_HW_CODESIZE )
70
+
71
+ LDFLAGS += -nostdlib -Map=$@ .map --cref
69
72
70
73
LIBS += $(shell $(CC ) $(CFLAGS ) -print-libgcc-file-name)
71
74
@@ -178,8 +181,10 @@ endif
178
181
all : $(BUILD ) /firmware.uf2
179
182
180
183
$(BUILD ) /firmware.elf : $(OBJ )
184
+ $(ECHO ) " PREPROCESS LINK $@ "
185
+ $(Q )$(CC ) -E -x c $(LDDEFINES ) $(LD_FILES ) | grep -v ' ^#' > $(BUILD ) /link.ld
181
186
$(ECHO ) " LINK $@ "
182
- $(Q )$(LD ) $(LDFLAGS ) -o $@ $^ $(LIBS )
187
+ $(Q )$(LD ) -T $( BUILD ) /link.ld $(LDFLAGS ) -o $@ $^ $(LIBS )
183
188
$(Q )$(SIZE ) $@
184
189
185
190
$(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,11 @@ 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 must be give as plain integer. 0x2e000 == 184k
6
+ MICROPY_HW_CODESIZE ?= 0x2e000
7
+
8
+ CFLAGS += -DMICROPY_HW_CODESIZE=$(MICROPY_HW_CODESIZE )
9
+
5
10
SRC_S += shared/runtime/gchelper_thumb1.s
6
11
7
12
LIBM_SRC_C += $(addprefix lib/libm/,\
Original file line number Diff line number Diff line change @@ -2,6 +2,11 @@ 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 must be give as plain integer: 0x5c000 == 368k
6
+ MICROPY_HW_CODESIZE ?= 0x5c000
7
+
8
+ CFLAGS += -DMICROPY_HW_CODESIZE=$(MICROPY_HW_CODESIZE )
9
+
5
10
MICROPY_VFS_LFS2 ?= 1
6
11
MICROPY_VFS_FAT ?= 1
7
12
FROZEN_MANIFEST ?= mcu/$(MCU_SERIES_LOWER ) /manifest.py
You can’t perform that action at this time.
0 commit comments