8000 stmhal: Put common definitions from linker files to common.ld. · sparkfun/circuitpython@9310dad · GitHub
[go: up one dir, main page]

Skip to content

Commit 9310dad

Browse files
Krzysztof Blazewiczdpgeorge
Krzysztof Blazewicz
authored andcommitted
stmhal: Put common definitions from linker files to common.ld.
1 parent c4a69c7 commit 9310dad

10 files changed

+124
-855
lines changed

stmhal/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ QSTR_DEFS = qstrdefsport.h $(BUILD)/pins_qstr.h $(BUILD)/modstm_qstr.h
1818
# include py core make definitions
1919
include ../py/py.mk
2020

21+
LD_DIR=boards
2122
CMSIS_DIR=cmsis
2223
HAL_DIR=hal/$(MCU_SERIES)
2324
USBDEV_DIR=usbdev
@@ -59,7 +60,7 @@ CFLAGS += $(COPT)
5960
CFLAGS += -Iboards/$(BOARD)
6061
CFLAGS += -DSTM32_HAL_H='<stm32$(MCU_SERIES)xx_hal.h>'
6162

62-
LDFLAGS = -nostdlib -T $(LD_FILE) -Map=$(@:.elf=.map) --cref
63+
LDFLAGS = -nostdlib -L $(LD_DIR) -T $(LD_FILE) -Map=$(@:.elf=.map) --cref
6364
LIBS =
6465

6566
# Remove uncalled code from the final image.

stmhal/boards/common.ld

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
ENTRY(Reset_Handler)
2+
3+
/* define output sections */
4+
SECTIONS
5+
{
6+
/* The startup code goes first into FLASH */
7+
.isr_vector :
8+
{
9+
. = ALIGN(4);
10+
KEEP(*(.isr_vector)) /* Startup code */
11+
12+
/* This first flash block is 16K annd the isr vectors only take up
13+
about 400 bytes. So we pull in a couple of object files to pad it
14+
out. */
15+
16+
. = ALIGN(4);
17+
*/ff.o(.text*)
18+
*/stm32f4xx_hal_sd.o(.text*)
19+
20+
. = ALIGN(4);
21+
} >FLASH_ISR
22+
23+
/* The program code and other data goes into FLASH */
24+
.text :
25+
{
26+
. = ALIGN(4);
27+
*(.text*) /* .text* sections (code) */
28+
*(.rodata*) /* .rodata* sections (constants, strings, etc.) */
29+
/* *(.glue_7) */ /* glue arm to thumb code */
30+
/* *(.glue_7t) */ /* glue thumb to arm code */
31+
32+
. = ALIGN(4);
33+
_etext = .; /* define a global symbol at end of code */
34+
} >FLASH_TEXT
35+
36+
/* used by the startup to initialize data */
37+
_sidata = LOADADDR(.data);
38+
39+
/* This is the initialized data section
40+
The program executes knowing that the data is in the RAM
41+
but the loader puts the initial values in the FLASH (inidata).
42+
It is one task of the startup to copy the initial values from FLASH to RAM. */
43+
.data :
44+
{
45+
. = ALIGN(4);
46+
_sdata = .; /* create a global symbol at data start; used by startup code in order to initialise the .data section in RAM */
47+
*(.data*) /* .data* sections */
48+
49+
. = ALIGN(4);
50+
_edata = .; /* define a global symbol at data end; used by startup code in order to initialise the .data section in RAM */
51+
} >RAM AT> FLASH_TEXT
52+
53+
/* Uninitialized data section */
54+
.bss :
55+
{
56+
. = ALIGN(4);
57+
_sbss = .; /* define a global symbol at bss start; used by startup code */
58+
*(.bss*)
59+
*(COMMON)
60+
61+
. = ALIGN(4);
62+
_ebss = .; /* define a global symbol at bss end; used by startup code and GC */
63+
} >RAM
64+
65+
/* this is to define the start of the heap, and make sure we have a minimum size */
66+
.heap :
67+
{
68+
. = ALIGN(4);
69+
. = . + _minimum_heap_size;
70+
. = ALIGN(4);
71+
} >RAM
72+
73+
/* this just checks there is enough RAM for the stack */
74+
.stack :
75+
{
76+
. = ALIGN(4);
77+
. = . + _minimum_stack_size;
78+
. = ALIGN(4);
79+
} >RAM
80+
81+
.ARM.attributes 0 : { *(.ARM.attributes) }
82+
}

stmhal/boards/stm32f401.ld

Lines changed: 5 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ MEMORY
1313
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 0x018000 /* 96 KiB */
1414
}
1515

16-
ENTRY(Reset_Handler)
17-
1816
/* produce a link error if there is not this amount of RAM for these sections */
1917
_minimum_stack_size = 2K;
2018
_minimum_heap_size = 16K;
@@ -24,114 +22,11 @@ _minimum_heap_size = 16K;
2422
aligned for a call. */
2523
_estack = ORIGIN(RAM) + LENGTH(RAM);
2624

25+
/* define common sections and symbols */
26+
INCLUDE common.ld
27+
2728
/* RAM extents for the garbage collector */
29+
_ram_start = ORIGIN(RAM);
2830
_ram_end = ORIGIN(RAM) + LENGTH(RAM);
31+
_heap_start = _ebss; /* heap starts just after statically allocated memory */
2932
_heap_end = 0x20014000; /* tunable */
30-
31-
/* define output sections */
32-
SECTIONS
33-
{
34-
/* The startup code goes first into FLASH */
35-
.isr_vector :
36-
{
37-
. = ALIGN(4);
38-
KEEP(*(.isr_vector)) /* Startup code */
39-
40-
/* This first flash block is 16K annd the isr vectors only take up
41-
about 400 bytes. So we pull in a couple of object files to pad it
42-
out. */
43-
44-
. = ALIGN(4);
45-
*/ff.o(.text*)
46-
*/stm32f4xx_hal_sd.o(.text*)
47-
48-
. = ALIGN(4);
49-
} >FLASH_ISR
50-
51-
/* The program code and other data goes into FLASH */
52-
.text :
53-
{
54-
. = ALIGN(4);
55-
*(.text*) /* .text* sections (code) */
56-
*(.rodata*) /* .rodata* sections (constants, strings, etc.) */
57-
/* *(.glue_7) */ /* glue arm to thumb code */
58-
/* *(.glue_7t) */ /* glue thumb to arm code */
59-
60-
. = ALIGN(4);
61-
_etext = .; /* define a global symbol at end of code */
62-
} >FLASH_TEXT
63-
64-
/*
65-
.ARM.extab :
66-
{
67-
*(.ARM.extab* .gnu.linkonce.armextab.*)
68-
} >FLASH
69-
70-
.ARM :
71-
{
72-
__exidx_start = .;
73-
*(.ARM.exidx*)
74-
__exidx_end = .;
75-
} >FLASH
76-
*/
77-
78-
/* used by the startup to initialize data */
79-
_sidata = LOADADDR(.data);
80-
81-
/* This is the initialized data section
82-
The program executes knowing that the data is in the RAM
83-
but the loader puts the initial values in the FLASH (inidata).
84-
It is one task of the startup to copy the initial values from FLASH to RAM. */
85-
.data :
86-
{
87-
. = ALIGN(4);
88-
_sdata = .; /* create a global symbol at data start; used by startup code in order to initialise the .data section in RAM */
89-
_ram_start = .; /* create a global symbol at ram start for garbage collector */
90-
*(.data*) /* .data* sections */
91-
92-
. = ALIGN(4);
93-
_edata = .; /* define a global symbol at data end; used by startup code in order to initialise the .data section in RAM */
94-
} >RAM AT> FLASH_TEXT
95-
96-
/* Uninitialized data section */
97-
.bss :
98-
{
99-
. = ALIGN(4);
100-
_sbss = .; /* define a global symbol at bss start; used by startup code */
101-
*(.bss*)
102-
*(COMMON)
103-
104-
. = ALIGN(4);
105-
_ebss = .; /* define a global symbol at bss end; used by startup code and GC */
106-
} >RAM
107-
108-
/* this is to define the start of the heap, and make sure we have a minimum size */
109-
.heap :
110-
{
111-
. = ALIGN(4);
112-
PROVIDE ( end = . );
113-
PROVIDE ( _end = . );
114-
_heap_start = .; /* define a global symbol at heap start */
115-
. = . + _minimum_heap_size;
116-
} >RAM
117-
118-
/* this just checks there is enough RAM for the stack */
119-
.stack :
120-
{
121-
. = ALIGN(4);
122-
. = . + _minimum_stack_size;
123-
. = ALIGN(4);
124-
} >RAM
125-
126-
/* Remove information from the standard libraries */
127-
/*
128-
/DISCARD/ :
129-
{
130-
libc.a ( * )
131-
libm.a ( * )
132-
libgcc.a ( * )
133-
}
134-
*/
135-
136-
.ARM.attributes 0 : { *(.ARM.attributes) }
137-
}

stmhal/boards/stm32f405.ld

Lines changed: 5 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ MEMORY
1212
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 0x020000 /* 128 KiB */
1313
}
1414

15-
ENTRY(Reset_Handler)
16-
1715
/* produce a link error if there is not this amount of RAM for these sections */
1816
_minimum_stack_size = 2K;
1917
_minimum_heap_size = 16K;
@@ -23,114 +21,11 @@ _minimum_heap_size = 16K;
2321
aligned for a call. */
2422
_estack = ORIGIN(RAM) + LENGTH(RAM);
2523

24+
/* define common sections and symbols */
25+
INCLUDE common.ld
26+
2627
/* RAM extents for the garbage collector */
28+
_ram_start = ORIGIN(RAM);
2729
_ram_end = ORIGIN(RAM) + LENGTH(RAM);
30+
_heap_start = _ebss; /* heap starts just after statically allocated memory */
2831
_heap_end = 0x2001c000; /* tunable */
29-
30-
/* define output sections */
31-
SECTIONS
32-
{
33-
/* The startup code goes first into FLASH */
34-
.isr_vector :
35-
{
36-
. = ALIGN(4);
37-
KEEP(*(.isr_vector)) /* Startup code */
38-
39-
/* This first flash block is 16K annd the isr vectors only take up
40-
about 400 bytes. So we pull in a couple of object files to pad it
41-
out. */
42-
43-
. = ALIGN(4);
44-
*/ff.o(.text*)
45-
*/stm32f4xx_hal_sd.o(.text*)
46-
47-
. = ALIGN(4);
48-
} >FLASH_ISR
49-
50-
/* The program code and other data goes into FLASH */
51-
.text :
52-
{
53-
. = ALIGN(4);
54-
*(.text*) /* .text* sections (code) */
55-
*(.rodata*) /* .rodata* sections (constants, strings, etc.) */
56-
/* *(.glue_7) */ /* glue arm to thumb code */
57-
/* *(.glue_7t) */ /* glue thumb to arm code */
58-
59-
. = ALIGN(4);
60-
_etext = .; /* define a global symbol at end of code */
61-
} >FLASH_TEXT
62-
63-
/*
64-
.ARM.extab :
65-
{
66-
*(.ARM.extab* .gnu.linkonce.armextab.*)
67-
} >FLASH
68-
69-
.ARM :
70-
{
71-
__exidx_start = .;
72-
*(.ARM.exidx*)
73-
__exidx_end = .;
74-
} >FLASH
75-
*/
76-
77-
/* used by the startup to initialize data */
78-
_sidata = LOADADDR(.data);
79-
80-
/* This is the initialized data section
81-
The program executes knowing that the data is in the RAM
82-
but the loader puts the initial values in the FLASH (inidata).
83-
It is one task of the startup to copy the initial values from FLASH to RAM. */
84-
.data :
85-
{
86-
. = ALIGN(4);
87-
_sdata = .; /* create a global symbol at data start; used by startup code in order to initialise the .data section in RAM */
88-
_ram_start = .; /* create a global symbol at ram start for garbage collector */
89-
*(.data*) /* .data* sections */
90-
91-
. = ALIGN(4);
92-
_edata = .; /* define a global symbol at data end; used by startup code in order to initialise the .data section in RAM */
93-
} >RAM AT> FLASH_TEXT
94-
95-
/* Uninitialized data section */
96-
.bss :
97-
{
98-
. = ALIGN(4);
99-
_sbss = .; /* define a global symbol at bss start; used by startup code */
100-
*(.bss*)
101-
*(COMMON)
102-
103-
. = ALIGN(4);
104-
_ebss = .; /* define a global symbol at bss end; used by startup code and GC */
105-
} >RAM
106-
107-
/* this is to define the start of the heap, and make sure we have a minimum size */
108-
.heap :
109-
{
110-
. = ALIGN(4);
111-
PROVIDE ( end = . );
112-
PROVIDE ( _end = . );
113-
_heap_start = .; /* define a global symbol at heap start */
114-
. = . + _minimum_heap_size;
115-
} >RAM
116-
117-
/* this just checks there is enough RAM for the stack */
118-
.stack :
119-
{
120-
. = ALIGN(4);
121-
. = . + _minimum_stack_size;
122-
. = ALIGN(4);
123-
} >RAM
124-
125-
/* Remove information from the standard libraries */
126-
/*
127-
/DISCARD/ :
128-
{
129-
libc.a ( * )
130-
libm.a ( * )
131-
libgcc.a ( * )
132-
}
133-
*/
134-
135-
.ARM.attributes 0 : { *(.ARM.attributes) }
136-
}

0 commit comments

Comments
 (0)
0