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
36MEMORY
37{
38  FLASH (rx)  : ORIGIN = __ROM_BASE, LENGTH = __ROM_SIZE
39  RAM   (rwx) : ORIGIN = __RAM_BASE, LENGTH = __RAM_SIZE
40}
41
42/* Linker script to place sections and symbol values. Should be used together
43 * with other linker script that defines memory regions FLASH and RAM.
44 * It references following symbols, which must be defined in code:
45 *   Reset_Handler : Entry of reset handler
46 *
47 * It defines following symbols, which code can use without definition:
48 *   __exidx_start
49 *   __exidx_end
50 *   __copy_table_start__
51 *   __copy_table_end__
52 *   __zero_table_start__
53 *   __zero_table_end__
54 *   __etext          (deprecated)
55 *   __data_start__
56 *   __preinit_array_start
57 *   __preinit_array_end
58 *   __init_array_start
59 *   __init_array_end
60 *   __fini_array_start
61 *   __fini_array_end
62 *   __data_end__
63 *   __bss_start__
64 *   __bss_end__
65 *   __end__
66 *   end
67 *   __HeapLimit
68 *   __StackLimit
69 *   __StackTop
70 *   __stack
71 */
72ENTRY(Reset_Handler)
73
74SECTIONS
75{
76  .text :
77  {
78    KEEP(*(.vectors))
79    *(.text*)
80
81    KEEP(*(.init))
82    KEEP(*(.fini))
83
84    /* .ctors */
85    *crtbegin.o(.ctors)
86    *crtbegin?.o(.ctors)
87    *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
88    *(SORT(.ctors.*))
89    *(.ctors)
90
91    /* .dtors */
92    *crtbegin.o(.dtors)
93    *crtbegin?.o(.dtors)
94    *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
95    *(SORT(.dtors.*))
96    *(.dtors)
97
98    *(.rodata*)
99
100    KEEP(*(.eh_frame*))
101  } > FLASH
102
103  .ARM.extab :
104  {
105    *(.ARM.extab* .gnu.linkonce.armextab.*)
106  } > FLASH
107
108  __exidx_start = .;
109  .ARM.exidx :
110  {
111    *(.ARM.exidx* .gnu.linkonce.armexidx.*)
112  } > FLASH
113  __exidx_end = .;
114
115  .copy.table :
116  {
117    . = ALIGN(4);
118    __copy_table_start__ = .;
119
120    LONG (LOADADDR(.data))
121    LONG (ADDR(.data))
122    LONG (SIZEOF(.data) / 4)
123
124    /* Add each additional data section here */
125/*
126    LONG (LOADADDR(.data2))
127    LONG (ADDR(.data2))
128    LONG (SIZEOF(.data2) / 4)
129*/
130    __copy_table_end__ = .;
131  } > FLASH
132
133  .zero.table :
134  {
135    . = ALIGN(4);
136    __zero_table_start__ = .;
137
138/*  .bss initialization to zero is already done during C Run-Time Startup.
139    LONG (ADDR(.bss))
140    LONG (SIZEOF(.bss) / 4)
141*/
142
143    /* Add each additional bss section here */
144/*
145    LONG (ADDR(.bss2))
146    LONG (SIZEOF(.bss2) / 4)
147*/
148    __zero_table_end__ = .;
149  } > FLASH
150
151  /*
152   * This __etext variable is kept for backward compatibility with older,
153   * ASM based startup files.
154   */
155  PROVIDE(__etext = LOADADDR(.data));
156
157  .data : ALIGN(4)
158  {
159    __data_start__ = .;
160    *(vtable)
161    *(.data)
162    *(.data.*)
163
164    . = ALIGN(4);
165    /* preinit data */
166    PROVIDE_HIDDEN (__preinit_array_start = .);
167    KEEP(*(.preinit_array))
168    PROVIDE_HIDDEN (__preinit_array_end = .);
169
170    . = ALIGN(4);
171    /* init data */
172    PROVIDE_HIDDEN (__init_array_start = .);
173    KEEP(*(SORT(.init_array.*)))
174    KEEP(*(.init_array))
175    PROVIDE_HIDDEN (__init_array_end = .);
176
177    . = ALIGN(4);
178    /* finit data */
179    PROVIDE_HIDDEN (__fini_array_start = .);
180    KEEP(*(SORT(.fini_array.*)))
181    KEEP(*(.fini_array))
182    PROVIDE_HIDDEN (__fini_array_end = .);
183
184    KEEP(*(.jcr*))
185    . = ALIGN(4);
186    /* All data end */
187    __data_end__ = .;
188
189  } > RAM AT > FLASH
190
191  /*
192   * Secondary data section, optional
193   *
194   * Remember to add each additional data section
195   * to the .copy.table above to assure proper
196   * initialization during startup.
197   */
198/*
199  .data2 : ALIGN(4)
200  {
201    . = ALIGN(4);
202    __data2_start__ = .;
203    *(.data2)
204    *(.data2.*)
205    . = ALIGN(4);
206    __data2_end__ = .;
207
208  } > RAM2 AT > FLASH
209*/
210
211  .bss :
212  {
213    . = ALIGN(4);
214    __bss_start__ = .;
215    *(.bss)
216    *(.bss.*)
217    *(COMMON)
218    . = ALIGN(4);
219    __bss_end__ = .;
220  } > RAM AT > RAM
221
222  /*
223   * Secondary bss section, optional
224   *
225   * Remember to add each additional bss section
226   * to the .zero.table above to assure proper
227   * initialization during startup.
228   */
229/*
230  .bss2 :
231  {
232    . = ALIGN(4);
233    __bss2_start__ = .;
234    *(.bss2)
235    *(.bss2.*)
236    . = ALIGN(4);
237    __bss2_end__ = .;
238  } > RAM2 AT > RAM2
239*/
240
241  .heap (NOLOAD) :
242  {
243    . = ALIGN(8);
244    __end__ = .;
245    PROVIDE(end = .);
246    . = . + __HEAP_SIZE;
247    . = ALIGN(8);
248    __HeapLimit = .;
249  } > RAM
250
251  .stack (ORIGIN(RAM) + LENGTH(RAM) - __STACK_SIZE) (NOLOAD) :
252  {
253    . = ALIGN(8);
254    __StackLimit = .;
255    . = . + __STACK_SIZE;
256    . = ALIGN(8);
257    __StackTop = .;
258  } > RAM
259  PROVIDE(__stack = __StackTop);
260
261  /* Check if data + heap + stack exceeds RAM limit */
262  ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")
263}
264