Skip to content

Commit e4b4e5a

Browse files
committed
stmhal: Add stm32f401.ld for linking F401 targets.
1 parent 0435e76 commit e4b4e5a

1 file changed

Lines changed: 136 additions & 0 deletions

File tree

stmhal/boards/stm32f401.ld

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
/*
2+
GNU linker script for STM32F401
3+
*/
4+
5+
/* Specify the memory areas */
6+
/* TODO verify these regions */
7+
MEMORY
8+
{
9+
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 0x080000 /* entire flash, 512 KiB */
10+
FLASH_ISR (rx) : ORIGIN = 0x08000000, LENGTH = 0x004000 /* sector 0, 16 KiB */
11+
FLASH_TEXT (rx) : ORIGIN = 0x08020000, LENGTH = 0x080000 /* sectors 5,6,7,8, 4*128KiB = 512 KiB */
12+
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 0x018000 /* 96 KiB */
13+
}
14+
15+
ENTRY(Reset_Handler)
16+
17+
/* produce a link error if there is not this amount of RAM for these sections */
18+
_minimum_stack_size = 2K;
19+
_minimum_heap_size = 16K;
20+
21+
/* Define tho top end of the stack. The stack is full descending so begins just
22+
above last byte of RAM. Note that EABI requires the stack to be 8-byte
23+
aligned for a call. */
24+
_estack = ORIGIN(RAM) + LENGTH(RAM);
25+
26+
/* RAM extents for the garbage collector */
27+
_ram_end = ORIGIN(RAM) + LENGTH(RAM);
28+
_heap_end = 0x20014000; /* 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)