1 | /*
|
2 | *****************************************************************************
|
3 | **
|
4 | ** File : stm32_flash.ld
|
5 | **
|
6 | ** Abstract : Linker script for STM32F401VC Device with
|
7 | ** 256KByte FLASH, 64KByte RAM
|
8 | **
|
9 | ** Set heap size, stack size and stack location according
|
10 | ** to application requirements.
|
11 | **
|
12 | ** Set memory bank area and size if external memory is used.
|
13 | **
|
14 | ** Target : STMicroelectronics STM32
|
15 | **
|
16 | ** Environment : Atollic TrueSTUDIO(R)
|
17 | **
|
18 | ** Distribution: The file is distributed “as is,” without any warranty
|
19 | ** of any kind.
|
20 | **
|
21 | ** (c)Copyright Atollic AB.
|
22 | ** You may use this file as-is or modify it according to the needs of your
|
23 | ** project. This file may only be built (assembled or compiled and linked)
|
24 | ** using the Atollic TrueSTUDIO(R) product. The use of this file together
|
25 | ** with other tools than Atollic TrueSTUDIO(R) is not permitted.
|
26 | **
|
27 | *****************************************************************************
|
28 | */
|
29 |
|
30 | /* Entry Point */
|
31 | ENTRY(Reset_Handler)
|
32 |
|
33 | /* Highest address of the user mode stack */
|
34 | _estack = 0x2000FFFF; /* end of 64K RAM */
|
35 |
|
36 | /* Generate a link error if heap and stack don't fit into RAM */
|
37 | _Min_Heap_Size = 0; /* required amount of heap */
|
38 | _Min_Stack_Size = 0x400; /* required amount of stack */
|
39 |
|
40 | /* Specify the memory areas */
|
41 | MEMORY
|
42 | {
|
43 | FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 512K
|
44 | RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 96K
|
45 | MEMORY_B1 (rx) : ORIGIN = 0x60000000, LENGTH = 0K
|
46 | CCMRAM (rw) : ORIGIN = 0x10000000, LENGTH = 0K
|
47 | }
|
48 |
|
49 | /* Define output sections */
|
50 | SECTIONS
|
51 | {
|
52 | /* The startup code goes first into FLASH */
|
53 | .isr_vector :
|
54 | {
|
55 | . = ALIGN(4);
|
56 | KEEP(*(.isr_vector)) /* Startup code */
|
57 | . = ALIGN(4);
|
58 | } >FLASH
|
59 |
|
60 | /* The program code and other data goes into FLASH */
|
61 | .text :
|
62 | {
|
63 | . = ALIGN(4);
|
64 | *(.text) /* .text sections (code) */
|
65 | *(.text*) /* .text* sections (code) */
|
66 | *(.glue_7) /* glue arm to thumb code */
|
67 | *(.glue_7t) /* glue thumb to arm code */
|
68 | *(.eh_frame)
|
69 |
|
70 | KEEP (*(.init))
|
71 | KEEP (*(.fini))
|
72 |
|
73 | . = ALIGN(4);
|
74 | _etext = .; /* define a global symbols at end of code */
|
75 | } >FLASH
|
76 |
|
77 | /* Constant data goes into FLASH */
|
78 | .rodata :
|
79 | {
|
80 | . = ALIGN(4);
|
81 | *(.rodata) /* .rodata sections (constants, strings, etc.) */
|
82 | *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
|
83 | . = ALIGN(4);
|
84 | } >FLASH
|
85 |
|
86 | .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH
|
87 | .ARM : {
|
88 | __exidx_start = .;
|
89 | *(.ARM.exidx*)
|
90 | __exidx_end = .;
|
91 | } >FLASH
|
92 |
|
93 | .preinit_array :
|
94 | {
|
95 | PROVIDE_HIDDEN (__preinit_array_start = .);
|
96 | KEEP (*(.preinit_array*))
|
97 | PROVIDE_HIDDEN (__preinit_array_end = .);
|
98 | } >FLASH
|
99 | .init_array :
|
100 | {
|
101 | PROVIDE_HIDDEN (__init_array_start = .);
|
102 | KEEP (*(SORT(.init_array.*)))
|
103 | KEEP (*(.init_array*))
|
104 | PROVIDE_HIDDEN (__init_array_end = .);
|
105 | } >FLASH
|
106 | .fini_array :
|
107 | {
|
108 | PROVIDE_HIDDEN (__fini_array_start = .);
|
109 | KEEP (*(SORT(.fini_array.*)))
|
110 | KEEP (*(.fini_array*))
|
111 | PROVIDE_HIDDEN (__fini_array_end = .);
|
112 | } >FLASH
|
113 |
|
114 | /* used by the startup to initialize data */
|
115 | _sidata = LOADADDR(.data);
|
116 |
|
117 | /* Initialized data sections goes into RAM, load LMA copy after code */
|
118 | .data :
|
119 | {
|
120 | . = ALIGN(4);
|
121 | _sdata = .; /* create a global symbol at data start */
|
122 | *(.data) /* .data sections */
|
123 | *(.data*) /* .data* sections */
|
124 |
|
125 | . = ALIGN(4);
|
126 | _edata = .; /* define a global symbol at data end */
|
127 | } >RAM AT> FLASH
|
128 |
|
129 | _siccmram = LOADADDR(.ccmram);
|
130 |
|
131 | /* CCM-RAM section
|
132 | *
|
133 | * IMPORTANT NOTE!
|
134 | * If initialized variables will be placed in this section,
|
135 | * the startup code needs to be modified to copy the init-values.
|
136 | */
|
137 | .ccmram :
|
138 | {
|
139 | . = ALIGN(4);
|
140 | _sccmram = .; /* create a global symbol at ccmram start */
|
141 | *(.ccmram)
|
142 | *(.ccmram*)
|
143 |
|
144 | . = ALIGN(4);
|
145 | _eccmram = .; /* create a global symbol at ccmram end */
|
146 | } >CCMRAM AT> FLASH
|
147 |
|
148 | /* Uninitialized data section */
|
149 | . = ALIGN(4);
|
150 | .bss :
|
151 | {
|
152 | /* This is used by the startup in order to initialize the .bss secion */
|
153 | _sbss = .; /* define a global symbol at bss start */
|
154 | __bss_start__ = _sbss;
|
155 | *(.bss)
|
156 | *(.bss*)
|
157 | *(COMMON)
|
158 |
|
159 | . = ALIGN(4);
|
160 | _ebss = .; /* define a global symbol at bss end */
|
161 | __bss_end__ = _ebss;
|
162 | } >RAM
|
163 |
|
164 | /* User_heap_stack section, used to check that there is enough RAM left */
|
165 | ._user_heap_stack :
|
166 | {
|
167 | . = ALIGN(4);
|
168 | PROVIDE ( end = . );
|
169 | PROVIDE ( _end = . );
|
170 | . = . + _Min_Heap_Size;
|
171 | . = . + _Min_Stack_Size;
|
172 | . = ALIGN(4);
|
173 | } >RAM
|
174 |
|
175 | /* MEMORY_bank1 section, code must be located here explicitly */
|
176 | /* Example: extern int foo(void) __attribute__ ((section (".mb1text"))); */
|
177 | .memory_b1_text :
|
178 | {
|
179 | *(.mb1text) /* .mb1text sections (code) */
|
180 | *(.mb1text*) /* .mb1text* sections (code) */
|
181 | *(.mb1rodata) /* read-only data (constants) */
|
182 | *(.mb1rodata*)
|
183 | } >MEMORY_B1
|
184 |
|
185 | /* Remove information from the standard libraries */
|
186 | /DISCARD/ :
|
187 | {
|
188 | libc.a ( * )
|
189 | libm.a ( * )
|
190 | libgcc.a ( * )
|
191 | }
|
192 |
|
193 | .ARM.attributes 0 : { *(.ARM.attributes) }
|
194 | }
|