|
1 /* Linker script to configure memory regions. */ |
|
2 |
|
3 #if !defined(MBED_BOOT_STACK_SIZE) |
|
4 #define MBED_BOOT_STACK_SIZE 0x400 |
|
5 #endif |
|
6 |
|
7 STACK_SIZE = MBED_BOOT_STACK_SIZE; |
|
8 |
|
9 /* 0x194 resevered for vectors; 8-byte aligned = 0x198 (0x194 + 0x4)*/ |
|
10 #ifndef MBED_APP_START |
|
11 #define MBED_APP_START 0x08000000 |
|
12 #endif |
|
13 |
|
14 #ifndef MBED_APP_SIZE |
|
15 #define MBED_APP_SIZE 512K |
|
16 #endif |
|
17 |
|
18 MEMORY |
|
19 { |
|
20 FLASH (rx) : ORIGIN = MBED_APP_START, LENGTH = MBED_APP_SIZE |
|
21 CCM (rwx) : ORIGIN = 0x10000000, LENGTH = 16K |
|
22 RAM (rwx) : ORIGIN = 0x20000198, LENGTH = 64K - (0x194+0x4) |
|
23 } |
|
24 |
|
25 /* Linker script to place sections and symbol values. Should be used together |
|
26 * with other linker script that defines memory regions FLASH and RAM. |
|
27 * It references following symbols, which must be defined in code: |
|
28 * Reset_Handler : Entry of reset handler |
|
29 * |
|
30 * It defines following symbols, which code can use without definition: |
|
31 * __exidx_start |
|
32 * __exidx_end |
|
33 * __etext |
|
34 * __data_start__ |
|
35 * __preinit_array_start |
|
36 * __preinit_array_end |
|
37 * __init_array_start |
|
38 * __init_array_end |
|
39 * __fini_array_start |
|
40 * __fini_array_end |
|
41 * __data_end__ |
|
42 * __bss_start__ |
|
43 * __bss_end__ |
|
44 * __end__ |
|
45 * end |
|
46 * __HeapLimit |
|
47 * __StackLimit |
|
48 * __StackTop |
|
49 * __stack |
|
50 * _estack |
|
51 */ |
|
52 ENTRY(Reset_Handler) |
|
53 |
|
54 SECTIONS |
|
55 { |
|
56 .text : |
|
57 { |
|
58 KEEP(*(.isr_vector)) |
|
59 *(.text*) |
|
60 KEEP(*(.init)) |
|
61 KEEP(*(.fini)) |
|
62 |
|
63 /* .ctors */ |
|
64 *crtbegin.o(.ctors) |
|
65 *crtbegin?.o(.ctors) |
|
66 *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors) |
|
67 *(SORT(.ctors.*)) |
|
68 *(.ctors) |
|
69 |
|
70 /* .dtors */ |
|
71 *crtbegin.o(.dtors) |
|
72 *crtbegin?.o(.dtors) |
|
73 *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors) |
|
74 *(SORT(.dtors.*)) |
|
75 *(.dtors) |
|
76 |
|
77 *(.rodata*) |
|
78 |
|
79 KEEP(*(.eh_frame*)) |
|
80 } > FLASH |
|
81 |
|
82 .ARM.extab : |
|
83 { |
|
84 *(.ARM.extab* .gnu.linkonce.armextab.*) |
|
85 } > FLASH |
|
86 |
|
87 __exidx_start = .; |
|
88 .ARM.exidx : |
|
89 { |
|
90 *(.ARM.exidx* .gnu.linkonce.armexidx.*) |
|
91 } > FLASH |
|
92 __exidx_end = .; |
|
93 |
|
94 __etext = .; |
|
95 _sidata = .; |
|
96 |
|
97 .data : AT (__etext) |
|
98 { |
|
99 __data_start__ = .; |
|
100 _sdata = .; |
|
101 *(vtable) |
|
102 *(.data*) |
|
103 |
|
104 . = ALIGN(8); |
|
105 /* preinit data */ |
|
106 PROVIDE_HIDDEN (__preinit_array_start = .); |
|
107 KEEP(*(.preinit_array)) |
|
108 PROVIDE_HIDDEN (__preinit_array_end = .); |
|
109 |
|
110 . = ALIGN(8); |
|
111 /* init data */ |
|
112 PROVIDE_HIDDEN (__init_array_start = .); |
|
113 KEEP(*(SORT(.init_array.*))) |
|
114 KEEP(*(.init_array)) |
|
115 PROVIDE_HIDDEN (__init_array_end = .); |
|
116 |
|
117 |
|
118 . = ALIGN(8); |
|
119 /* finit data */ |
|
120 PROVIDE_HIDDEN (__fini_array_start = .); |
|
121 KEEP(*(SORT(.fini_array.*))) |
|
122 KEEP(*(.fini_array)) |
|
123 PROVIDE_HIDDEN (__fini_array_end = .); |
|
124 |
|
125 KEEP(*(.jcr*)) |
|
126 . = ALIGN(8); |
|
127 /* All data end */ |
|
128 __data_end__ = .; |
|
129 _edata = .; |
|
130 |
|
131 } > RAM |
|
132 |
|
133 .bss : |
|
134 { |
|
135 . = ALIGN(8); |
|
136 __bss_start__ = .; |
|
137 _sbss = .; |
|
138 *(.bss*) |
|
139 *(COMMON) |
|
140 . = ALIGN(8); |
|
141 __bss_end__ = .; |
|
142 _ebss = .; |
|
143 } > RAM |
|
144 |
|
145 .heap (COPY): |
|
146 { |
|
147 __end__ = .; |
|
148 end = __end__; |
|
149 *(.heap*) |
|
150 . = ORIGIN(RAM) + LENGTH(RAM) - STACK_SIZE; |
|
151 __HeapLimit = .; |
|
152 } > RAM |
|
153 |
|
154 /* .stack_dummy section doesn't contains any symbols. It is only |
|
155 * used for linker to calculate size of stack sections, and assign |
|
156 * values to stack symbols later */ |
|
157 .stack_dummy (COPY): |
|
158 { |
|
159 *(.stack*) |
|
160 } > RAM |
|
161 |
|
162 /* Set stack top to end of RAM, and stack limit move down by |
|
163 * size of stack_dummy section */ |
|
164 __StackTop = ORIGIN(RAM) + LENGTH(RAM); |
|
165 _estack = __StackTop; |
|
166 __StackLimit = __StackTop - STACK_SIZE; |
|
167 PROVIDE(__stack = __StackTop); |
|
168 |
|
169 /* Check if data + heap + stack exceeds RAM limit */ |
|
170 ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack") |
|
171 |
|
172 .CCMRAM (NOLOAD): |
|
173 { |
|
174 Image$$RW_IRAM2$$Base = . ; |
|
175 *(CCMRAM) |
|
176 Image$$RW_IRAM2$$ZI$$Limit = .; |
|
177 } > CCM |
|
178 } |
|
179 |