1/*
2 *-------- <<< Use Configuration Wizard in Context Menu >>> -------------------
3 */
4
5/*---------------------- Flash Configuration ----------------------------------
6  <h> Flash Configuration
7    <o0> Flash Base Address <0x0-0xFFFFFFFF:8>
8    <o1> Flash Size (in Bytes) <0x0-0xFFFFFFFF:8>
9  </h>
10  -----------------------------------------------------------------------------*/
11__ROM_BASE = 0x00000000;
12__ROM_SIZE = 0x00040000;
13
14/*--------------------- Embedded RAM Configuration ----------------------------
15  <h> RAM Configuration
16    <o0> RAM Base Address    <0x0-0xFFFFFFFF:8>
17    <o1> RAM Size (in Bytes) <0x0-0xFFFFFFFF:8>
18  </h>
19 -----------------------------------------------------------------------------*/
20__RAM_BASE = 0x20000000;
21__RAM_SIZE = 0x00020000;
22
23/*--------------------- Stack / Heap Configuration ----------------------------
24  <h> Stack / Heap Configuration
25    <o0> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>
26    <o1> Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
27  </h>
28  -----------------------------------------------------------------------------*/
29__STACK_SIZE = 0x00000400;
30__HEAP_SIZE  = 0x00000C00;
31
32/*
33 *-------------------- <<< end of configuration section >>> -------------------
34 */
35
36/* ARMv8-M stack sealing:
37   to use ARMv8-M stack sealing set __STACKSEAL_SIZE to 8 otherwise keep 0
38 */
39__STACKSEAL_SIZE = 0;
40
41
42MEMORY
43{
44  FLASH (rx)  : ORIGIN = __ROM_BASE, LENGTH = __ROM_SIZE
45  RAM   (rwx) : ORIGIN = __RAM_BASE, LENGTH = __RAM_SIZE
46}
47
48/* Linker script to place sections and symbol values. Should be used together
49 * with other linker script that defines memory regions FLASH and RAM.
50 * It references following symbols, which must be defined in code:
51 *   Reset_Handler : Entry of reset handler
52 *
53 * It defines following symbols, which code can use without definition:
54 *   __exidx_start
55 *   __exidx_end
56 *   __copy_table_start__
57 *   __copy_table_end__
58 *   __zero_table_start__
59 *   __zero_table_end__
60 *   __etext          (deprecated)
61 *   __data_start__
62 *   __preinit_array_start
63 *   __preinit_array_end
64 *   __init_array_start
65 *   __init_array_end
66 *   __fini_array_start
67 *   __fini_array_end
68 *   __data_end__
69 *   __bss_start__
70 *   __bss_end__
71 *   __end__
72 *   end
73 *   __HeapLimit
74 *   __StackLimit
75 *   __StackTop
76 *   __stack
77 *   __StackSeal      (only if ARMv8-M stack sealing is used)
78 */
79ENTRY(Reset_Handler)
80
81SECTIONS
82{
83  .text :
84  {
85    KEEP(*(.vectors))
86    *(.text*)
87
88    KEEP(*(.init))
89    KEEP(*(.fini))
90
91    /* .ctors */
92    *crtbegin.o(.ctors)
93    *crtbegin?.o(.ctors)
94    *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
95    *(SORT(.ctors.*))
96    *(.ctors)
97
98    /* .dtors */
99    *crtbegin.o(.dtors)
100    *crtbegin?.o(.dtors)
101    *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
102    *(SORT(.dtors.*))
103    *(.dtors)
104
105    *(.rodata*)
106
107    KEEP(*(.eh_frame*))
108  } > FLASH
109
110  /*
111   * SG veneers:
112   * All SG veneers are placed in the special output section .gnu.sgstubs. Its start address
113   * must be set, either with the command line option '--section-start' or in a linker script,
114   * to indicate where to place these veneers in memory.
115   */
116/*
117  .gnu.sgstubs :
118  {
119    . = ALIGN(32);
120  } > FLASH
121*/
122  .ARM.extab :
123  {
124    *(.ARM.extab* .gnu.linkonce.armextab.*)
125  } > FLASH
126
127  __exidx_start = .;
128  .ARM.exidx :
129  {
130    *(.ARM.exidx* .gnu.linkonce.armexidx.*)
131  } > FLASH
132  __exidx_end = .;
133
134  .copy.table :
135  {
136    . = ALIGN(4);
137    __copy_table_start__ = .;
138
139    LONG (LOADADDR(.data))
140    LONG (ADDR(.data))
141    LONG (SIZEOF(.data) / 4)
142
143    /* Add each additional data section here */
144/*
145    LONG (LOADADDR(.data2))
146    LONG (ADDR(.data2))
147    LONG (SIZEOF(.data2) / 4)
148*/
149    __copy_table_end__ = .;
150  } > FLASH
151
152  .zero.table :
153  {
154    . = ALIGN(4);
155    __zero_table_start__ = .;
156
157/*  .bss initialization to zero is already done during C Run-Time Startup.
158    LONG (ADDR(.bss))
159    LONG (SIZEOF(.bss) / 4)
160*/
161
162    /* Add each additional bss section here */
163/*
164    LONG (ADDR(.bss2))
165    LONG (SIZEOF(.bss2) / 4)
166*/
167    __zero_table_end__ = .;
168  } > FLASH
169
170  /*
171   * This __etext variable is kept for backward compatibility with older,
172   * ASM based startup files.
173   */
174  PROVIDE(__etext = LOADADDR(.data));
175
176  .data : ALIGN(4)
177  {
178    __data_start__ = .;
179    *(vtable)
180    *(.data)
181    *(.data.*)
182
183    . = ALIGN(4);
184    /* preinit data */
185    PROVIDE_HIDDEN (__preinit_array_start = .);
186    KEEP(*(.preinit_array))
187    PROVIDE_HIDDEN (__preinit_array_end = .);
188
189    . = ALIGN(4);
190    /* init data */
191    PROVIDE_HIDDEN (__init_array_start = .);
192    KEEP(*(SORT(.init_array.*)))
193    KEEP(*(.init_array))
194    PROVIDE_HIDDEN (__init_array_end = .);
195
196    . = ALIGN(4);
197    /* finit data */
198    PROVIDE_HIDDEN (__fini_array_start = .);
199    KEEP(*(SORT(.fini_array.*)))
200    KEEP(*(.fini_array))
201    PROVIDE_HIDDEN (__fini_array_end = .);
202
203    KEEP(*(.jcr*))
204    . = ALIGN(4);
205    /* All data end */
206    __data_end__ = .;
207
208  } > RAM AT > FLASH
209
210  /*
211   * Secondary data section, optional
212   *
213   * Remember to add each additional data section
214   * to the .copy.table above to assure proper
215   * initialization during startup.
216   */
217/*
218  .data2 : ALIGN(4)
219  {
220    . = ALIGN(4);
221    __data2_start__ = .;
222    *(.data2)
223    *(.data2.*)
224    . = ALIGN(4);
225    __data2_end__ = .;
226
227  } > RAM2 AT > FLASH
228*/
229
230  .bss :
231  {
232    . = ALIGN(4);
233    __bss_start__ = .;
234    *(.bss)
235    *(.bss.*)
236    *(COMMON)
237    . = ALIGN(4);
238    __bss_end__ = .;
239  } > RAM AT > RAM
240
241  /*
242   * Secondary bss section, optional
243   *
244   * Remember to add each additional bss section
245   * to the .zero.table above to assure proper
246   * initialization during startup.
247   */
248/*
249  .bss2 :
250  {
251    . = ALIGN(4);
252    __bss2_start__ = .;
253    *(.bss2)
254    *(.bss2.*)
255    . = ALIGN(4);
256    __bss2_end__ = .;
257  } > RAM2 AT > RAM2
258*/
259
260  .heap (NOLOAD) :
261  {
262    . = ALIGN(8);
263    __end__ = .;
264    PROVIDE(end = .);
265    . = . + __HEAP_SIZE;
266    . = ALIGN(8);
267    __HeapLimit = .;
268  } > RAM
269
270  .stack (ORIGIN(RAM) + LENGTH(RAM) - __STACK_SIZE - __STACKSEAL_SIZE) (NOLOAD) :
271  {
272    . = ALIGN(8);
273    __StackLimit = .;
274    . = . + __STACK_SIZE;
275    . = ALIGN(8);
276    __StackTop = .;
277  } > RAM
278  PROVIDE(__stack = __StackTop);
279
280  /* ARMv8-M stack sealing:
281     to use ARMv8-M stack sealing uncomment '.stackseal' section
282   */
283/*
284  .stackseal (ORIGIN(RAM) + LENGTH(RAM) - __STACKSEAL_SIZE) (NOLOAD) :
285  {
286    . = ALIGN(8);
287    __StackSeal = .;
288    . = . + 8;
289    . = ALIGN(8);
290  } > RAM
291*/
292
293  /* Check if data + heap + stack exceeds RAM limit */
294  ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")
295}
296