38
|
1 /* ---------------------------------------------------------------------------- */
|
|
2 /* Em::Blocks embedded development Support */
|
|
3 /* ---------------------------------------------------------------------------- */
|
|
4 /* Copyright (c) 2014, EmBlocks */
|
|
5 /* */
|
|
6 /* All rights reserved. */
|
|
7 /* */
|
|
8 /* Redistribution and use in source and binary forms, with or without */
|
|
9 /* modification, are permitted provided that the following condition is met: */
|
|
10 /* */
|
|
11 /* - Redistributions of source code must retain the above copyright notice, */
|
|
12 /* this list of conditions and the disclaimer below. */
|
|
13 /* */
|
|
14 /* EmBlocks's name may not be used to endorse or promote products derived from */
|
|
15 /* this software without specific prior written permission. */
|
|
16 /* */
|
|
17 /* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY EBLOCKS "AS IS" AND ANY EXPRESS OR */
|
|
18 /* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF */
|
|
19 /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE */
|
|
20 /* DISCLAIMED. IN NO EVENT SHALL EMBLOCKS BE LIABLE FOR ANY DIRECT, INDIRECT, */
|
|
21 /* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
|
|
22 /* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, */
|
|
23 /* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF */
|
|
24 /* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING */
|
|
25 /* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, */
|
|
26 /* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
|
|
27 /* ---------------------------------------------------------------------------- */
|
|
28
|
|
29 /*------------------------------------------------------------------------------
|
|
30 * Linker script for running in internal FLASH on the STM32F401RE
|
|
31 *----------------------------------------------------------------------------*/
|
|
32
|
54
|
33 /* Entry Point */
|
|
34 ENTRY(Reset_Handler)
|
|
35
|
38
|
36 OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
|
|
37 OUTPUT_ARCH(arm)
|
|
38 SEARCH_DIR(.)
|
|
39
|
|
40 /* Memory Spaces Definitions */
|
|
41 MEMORY
|
|
42 {
|
|
43 ROM (rx) : ORIGIN = 0x08000000, LENGTH = 512K /* 80000 */
|
|
44 RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 96K
|
|
45 }
|
|
46 /* Linker script to place sections and symbol values. Should be used together
|
|
47 * with other linker script that defines memory regions FLASH and RAM.
|
|
48 * It references following symbols, which must be defined in code:
|
|
49 * Reset_Handler : Entry of reset handler
|
|
50 *
|
|
51 * It defines following symbols, which code can use without definition:
|
|
52 * __exidx_start
|
|
53 * __exidx_end
|
|
54 * __etext
|
|
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 */
|
|
72
|
|
73
|
|
74 SECTIONS
|
|
75 {
|
40
|
76 .isr_vector 0x08000000 :
|
|
77 {
|
|
78 . = ALIGN(4);
|
|
79 KEEP( *(.isr_vector) )
|
|
80 KEEP(*(.init))
|
|
81 KEEP(*(.fini))
|
|
82 } >ROM
|
|
83
|
38
|
84 /* Place FirmwareData at absolute address */
|
|
85 .firmware_data 0x08005000:
|
|
86 {
|
40
|
87 cpu2_FirmwareData = 0;
|
|
88 KEEP( *(.firmware_data) )
|
38
|
89 } > ROM
|
|
90
|
40
|
91 .text 0x08005100 :
|
|
92 {
|
|
93 . = ALIGN(4);
|
|
94 *(.text) /* .text sections (code) */
|
38
|
95 *(.text*)
|
40
|
96 *(.eh_frame*)
|
|
97 . = ALIGN(4);
|
|
98
|
38
|
99 } > ROM
|
|
100
|
40
|
101 /********************** Constant data into ROM memory *********************/
|
|
102 .rodata :
|
|
103 {
|
|
104 . = ALIGN(4);
|
|
105 *(.rodata) /* .rodata sections (constants, strings, etc.) */
|
|
106 *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
|
|
107 . = ALIGN(4);
|
|
108 } >ROM
|
|
109
|
38
|
110 .ARM.extab :
|
|
111 {
|
|
112 *(.ARM.extab* .gnu.linkonce.armextab.*)
|
|
113 } > ROM
|
|
114
|
|
115 __exidx_start = .;
|
|
116 .ARM.exidx :
|
|
117 {
|
|
118 *(.ARM.exidx* .gnu.linkonce.armexidx.*)
|
|
119 } > ROM
|
|
120 __exidx_end = .;
|
|
121
|
40
|
122 .preinit_array :
|
|
123 {
|
|
124 . = ALIGN(4);
|
|
125 PROVIDE_HIDDEN( __preinit_array_start = . );
|
|
126 KEEP( *(.preinit_array*) )
|
|
127 PROVIDE_HIDDEN( __preinit_array_end = . );
|
|
128 . = ALIGN(4);
|
|
129 } >ROM
|
|
130
|
|
131 .init_array :
|
|
132 {
|
|
133 . = ALIGN(4);
|
|
134 PROVIDE_HIDDEN( __init_array_start = . );
|
|
135 KEEP( *(SORT(.init_array.*)) )
|
|
136 KEEP( *(.init_array*) )
|
|
137 PROVIDE_HIDDEN( __init_array_end = . );
|
|
138 . = ALIGN(4);
|
|
139 } >ROM
|
|
140
|
|
141 .fini_array :
|
|
142 {
|
|
143 . = ALIGN(4);
|
|
144 PROVIDE_HIDDEN( __fini_array_start = . );
|
|
145 KEEP( *(SORT(.fini_array.*)) )
|
|
146 KEEP( *(.fini_array*) )
|
|
147 PROVIDE_HIDDEN( __fini_array_end = . );
|
|
148 . = ALIGN(4);
|
|
149
|
|
150 __etext = .; /* define a global symbols at end of code */
|
|
151 } >ROM
|
38
|
152
|
40
|
153 /* Used by the startup to initialize data */
|
|
154 _sidata = LOADADDR(.data);
|
|
155
|
|
156 .data :
|
38
|
157 {
|
|
158 . = ALIGN(4);
|
40
|
159 __data_start__ = .;
|
|
160 _sdata = .; /* create a global symbol at data start */
|
|
161 *(.data) /* .data sections */
|
|
162 *(.data*)
|
|
163 *(vtable)
|
38
|
164 . = ALIGN(4);
|
|
165 /* All data end */
|
|
166 __data_end__ = .;
|
40
|
167 } >RAM AT>ROM
|
38
|
168
|
40
|
169 .bss :
|
38
|
170 {
|
|
171 __bss_start__ = .;
|
|
172 *(.bss*)
|
|
173 *(COMMON)
|
|
174 __bss_end__ = .;
|
40
|
175 } >RAM
|
38
|
176
|
40
|
177 .heap :
|
38
|
178 {
|
|
179 __end__ = .;
|
|
180 end = __end__;
|
|
181 *(.heap*)
|
|
182 __HeapLimit = .;
|
|
183 } > RAM
|
433
|
184
|
|
185 /* .noinit section contains data which will not be change during startup */
|
|
186 .noinit :
|
|
187 {
|
|
188 . = ALIGN(4);
|
|
189 *(.noinit*)
|
|
190 _end = . ;
|
|
191 } > RAM
|
|
192
|
38
|
193 /* .stack_dummy section doesn't contains any symbols. It is only
|
|
194 * used for linker to calculate size of stack sections, and assign
|
|
195 * values to stack symbols later */
|
40
|
196 .stack_dummy :
|
38
|
197 {
|
|
198 *(.stack)
|
|
199 } > RAM
|
|
200
|
|
201 /* Set stack top to end of RAM, and stack limit move down by
|
|
202 * size of stack_dummy section */
|
|
203 __StackTop = ORIGIN(RAM) + LENGTH(RAM);
|
|
204 __StackLimit = __StackTop - SIZEOF(.stack_dummy);
|
|
205 PROVIDE(__stack = __StackTop);
|
|
206
|
|
207 /* Check if data + heap + stack exceeds RAM limit */
|
|
208 ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")
|
|
209 }
|