|
1 |
| -/* Based on GCC ARM embedded samples. |
2 |
| - Defines the following symbols for use by code: |
3 |
| - __exidx_start |
4 |
| - __exidx_end |
5 |
| - __etext |
6 |
| - __data_start__ |
7 |
| - __preinit_array_start |
8 |
| - __preinit_array_end |
9 |
| - __init_array_start |
10 |
| - __init_array_end |
11 |
| - __fini_array_start |
12 |
| - __fini_array_end |
13 |
| - __data_end__ |
14 |
| - __bss_start__ |
15 |
| - __bss_end__ |
16 |
| - __end__ |
17 |
| - end |
18 |
| - __HeapLimit |
19 |
| - __StackLimit |
20 |
| - __StackTop |
21 |
| - __stack (== StackTop) |
22 |
| -*/ |
23 |
| - |
24 |
| -MEMORY |
25 |
| -{ |
26 |
| - FLASH_FIRMWARE (rx) : ORIGIN = 0x10000000, LENGTH = 1532k |
27 |
| - /* Followed by: 4kB of NVRAM and at least 512kB of CIRCUITPY */ |
28 |
| - RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 256k |
29 |
| - SCRATCH_X (rwx) : ORIGIN = 0x20040000, LENGTH = 4k |
30 |
| - SCRATCH_Y (rwx) : ORIGIN = 0x20041000, LENGTH = 4k |
31 |
| -} |
32 |
| - |
33 |
| -ENTRY(_entry_point) |
34 |
| - |
35 |
| -SECTIONS |
36 |
| -{ |
37 |
| - /* Second stage bootloader is prepended to the image. It must be 256 bytes big |
38 |
| - and checksummed. It is usually built by the boot_stage2 target |
39 |
| - in the Pico SDK |
40 |
| - */ |
41 |
| - |
42 |
| - .flash_begin : { |
43 |
| - __flash_binary_start = .; |
44 |
| - } > FLASH_FIRMWARE |
45 |
| - |
46 |
| - .boot2 : { |
47 |
| - __boot2_start__ = .; |
48 |
| - KEEP (*(.boot2)) |
49 |
| - __boot2_end__ = .; |
50 |
| - } > FLASH_FIRMWARE |
51 |
| - |
52 |
| - ASSERT(__boot2_end__ - __boot2_start__ == 256, |
53 |
| - "ERROR: Pico second stage bootloader must be 256 bytes in size") |
54 |
| - |
55 |
| - /* The second stage will always enter the image at the start of .text. |
56 |
| - The debugger will use the ELF entry point, which is the _entry_point |
57 |
| - symbol if present, otherwise defaults to start of .text. |
58 |
| - This can be used to transfer control back to the bootrom on debugger |
59 |
| - launches only, to perform proper flash setup. |
60 |
| - */ |
61 |
| - |
62 |
| - .text : { |
63 |
| - __logical_binary_start = .; |
64 |
| - KEEP (*(.vectors)) |
65 |
| - KEEP (*(.binary_info_header)) |
66 |
| - __binary_info_header_end = .; |
67 |
| - KEEP (*(.reset)) |
68 |
| - /* TODO revisit this now memset/memcpy/float in ROM */ |
69 |
| - /* bit of a hack right now to exclude all floating point and time critical (e.g. memset, memcpy) code from |
70 |
| - * FLASH ... we will include any thing excluded here in .data below by default */ |
71 |
| - *(.init) |
72 |
| - |
73 |
| - __property_getter_start = .; |
74 |
| - *(.property_getter) |
75 |
| - __property_getter_end = .; |
76 |
| - __property_getset_start = .; |
77 |
| - *(.property_getset) |
78 |
| - __property_getset_end = .; |
79 |
| - |
80 |
| - *(EXCLUDE_FILE(*libgcc.a: *libc.a:*lib_a-mem*.o *libm.a:) .text*) |
81 |
| - *(.fini) |
82 |
| - /* Pull all c'tors into .text */ |
83 |
| - *crtbegin.o(.ctors) |
84 |
| - *crtbegin?.o(.ctors) |
85 |
| - *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors) |
86 |
| - *(SORT(.ctors.*)) |
87 |
| - *(.ctors) |
88 |
| - /* Followed by destructors */ |
89 |
| - *crtbegin.o(.dtors) |
90 |
| - *crtbegin?.o(.dtors) |
91 |
| - *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors) |
92 |
| - *(SORT(.dtors.*)) |
93 |
| - *(.dtors) |
94 |
| - |
95 |
| - *(.eh_frame*) |
96 |
| - . = ALIGN(4); |
97 |
| - } > FLASH_FIRMWARE |
98 |
| - |
99 |
| - .rodata : { |
100 |
| - *(EXCLUDE_FILE(*libgcc.a: *libc.a:*lib_a-mem*.o *libm.a:) .rodata*) |
101 |
| - . = ALIGN(4); |
102 |
| - *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.flashdata*))) |
103 |
| - . = ALIGN(4); |
104 |
| - } > FLASH_FIRMWARE |
105 |
| - |
106 |
| - .ARM.extab : |
107 |
| - { |
108 |
| - *(.ARM.extab* .gnu.linkonce.armextab.*) |
109 |
| - } > FLASH_FIRMWARE |
110 |
| - |
111 |
| - __exidx_start = .; |
112 |
| - .ARM.exidx : |
113 |
| - { |
114 |
| - *(.ARM.exidx* .gnu.linkonce.armexidx.*) |
115 |
| - } > FLASH_FIRMWARE |
116 |
| - __exidx_end = .; |
117 |
| - |
118 |
| - /* Machine inspectable binary information */ |
119 |
| - . = ALIGN(4); |
120 |
| - __binary_info_start = .; |
121 |
| - .binary_info : |
122 |
| - { |
123 |
| - KEEP(*(.binary_info.keep.*)) |
124 |
| - *(.binary_info.*) |
125 |
| - } > FLASH_FIRMWARE |
126 |
| - __binary_info_end = .; |
127 |
| - . = ALIGN(4); |
128 |
| - |
129 |
| - /* End of .text-like segments */ |
130 |
| - __etext = .; |
131 |
| - |
132 |
| - .ram_vector_table (COPY): { |
133 |
| - *(.ram_vector_table) |
134 |
| - } > RAM |
135 |
| - |
136 |
| - .data : { |
137 |
| - __data_start__ = .; |
138 |
| - *(vtable) |
139 |
| - |
140 |
| - *(.time_critical*) |
141 |
| - |
142 |
| - /* remaining .text and .rodata; i.e. stuff we exclude above because we want it in RAM */ |
143 |
| - *(.text*) |
144 |
| - . = ALIGN(4); |
145 |
| - *(.rodata*) |
146 |
| - . = ALIGN(4); |
147 |
| - |
148 |
| - *(.data*) |
149 |
| - |
150 |
| - . = ALIGN(4); |
151 |
| - *(.after_data.*) |
152 |
| - . = ALIGN(4); |
153 |
| - /* preinit data */ |
154 |
| - PROVIDE_HIDDEN (__mutex_array_start = .); |
155 |
| - KEEP(*(SORT(.mutex_array.*))) |
156 |
| - KEEP(*(.mutex_array)) |
157 |
| - PROVIDE_HIDDEN (__mutex_array_end = .); |
158 |
| - |
159 |
| - . = ALIGN(4); |
160 |
| - /* preinit data */ |
161 |
| - PROVIDE_HIDDEN (__preinit_array_start = .); |
162 |
| - KEEP(*(SORT(.preinit_array.*))) |
163 |
| - KEEP(*(.preinit_array)) |
164 |
| - PROVIDE_HIDDEN (__preinit_array_end = .); |
165 |
| - |
166 |
| - . = ALIGN(4); |
167 |
| - /* init data */ |
168 |
| - PROVIDE_HIDDEN (__init_array_start = .); |
169 |
| - KEEP(*(SORT(.init_array.*))) |
170 |
| - KEEP(*(.init_array)) |
171 |
| - PROVIDE_HIDDEN (__init_array_end = .); |
172 |
| - |
173 |
| - . = ALIGN(4); |
174 |
| - /* finit data */ |
175 |
| - PROVIDE_HIDDEN (__fini_array_start = .); |
176 |
| - *(SORT(.fini_array.*)) |
177 |
| - *(.fini_array) |
178 |
| - PROVIDE_HIDDEN (__fini_array_end = .); |
179 |
| - |
180 |
| - *(.jcr) |
181 |
| - . = ALIGN(4); |
182 |
| - /* All data end */ |
183 |
| - __data_end__ = .; |
184 |
| - } > RAM AT> FLASH_FIRMWARE |
185 |
| - |
186 |
| - .itcm : |
187 |
| - { |
188 |
| - . = ALIGN(4); |
189 |
| - *(.itcm.*) |
190 |
| - |
191 |
| - . = ALIGN(4); |
192 |
| - } > RAM AT> FLASH_FIRMWARE |
193 |
| - _ld_itcm_destination = ADDR(.itcm); |
194 |
| - _ld_itcm_flash_copy = LOADADDR(.itcm); |
195 |
| - _ld_itcm_size = SIZEOF(.itcm); |
196 |
| - |
197 |
| - .dtcm_data : |
198 |
| - { |
199 |
| - . = ALIGN(4); |
200 |
| - |
201 |
| - *(.dtcm_data.*) |
202 |
| - |
203 |
| - . = ALIGN(4); |
204 |
| - } > RAM AT> FLASH_FIRMWARE |
205 |
| - _ld_dtcm_data_destination = ADDR(.dtcm_data); |
206 |
| - _ld_dtcm_data_flash_copy = LOADADDR(.dtcm_data); |
207 |
| - _ld_dtcm_data_size = SIZEOF(.dtcm_data); |
208 |
| - |
209 |
| - .dtcm_bss : |
210 |
| - { |
211 |
| - . = ALIGN(4); |
212 |
| - |
213 |
| - *(.dtcm_bss.*) |
214 |
| - |
215 |
| - . = ALIGN(4); |
216 |
| - } > RAM AT> RAM |
217 |
| - _ld_dtcm_bss_start = ADDR(.dtcm_bss); |
218 |
| - _ld_dtcm_bss_size = SIZEOF(.dtcm_bss); |
219 |
| - |
220 |
| - .uninitialized_data (COPY): { |
221 |
| - . = ALIGN(4); |
222 |
| - *(.uninitialized_data*) |
223 |
| - } > RAM |
224 |
| - |
225 |
| - /* Start and end symbols must be word-aligned */ |
226 |
| - .scratch_x : { |
227 |
| - __scratch_x_start__ = .; |
228 |
| - *(.scratch_x.*) |
229 |
| - . = ALIGN(4); |
230 |
| - __scratch_x_end__ = .; |
231 |
| - } > SCRATCH_X AT > FLASH_FIRMWARE |
232 |
| - __scratch_x_source__ = LOADADDR(.scratch_x); |
233 |
| - |
234 |
| - .scratch_y : { |
235 |
| - __scratch_y_start__ = .; |
236 |
| - *(.scratch_y.*) |
237 |
| - . = ALIGN(4); |
238 |
| - __scratch_y_end__ = .; |
239 |
| - } > SCRATCH_Y AT > FLASH_FIRMWARE |
240 |
| - __scratch_y_source__ = LOADADDR(.scratch_y); |
241 |
| - |
242 |
| - .bss : { |
243 |
| - . = ALIGN(4); |
244 |
| - __bss_start__ = .; |
245 |
| - *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.bss*))) |
246 |
| - *(COMMON) |
247 |
| - . = ALIGN(4); |
248 |
| - __bss_end__ = .; |
249 |
| - } > RAM |
250 |
| - |
251 |
| - .heap (COPY): |
252 |
| - { |
253 |
| - __end__ = .; |
254 |
| - end = __end__; |
255 |
| - *(.heap*) |
256 |
| - __HeapLimit = .; |
257 |
| - } > RAM |
258 |
| - |
259 |
| - /* .stack*_dummy section doesn't contains any symbols. It is only |
260 |
| - * used for linker to calculate size of stack sections, and assign |
261 |
| - * values to stack symbols later |
262 |
| - * |
263 |
| - * stack1 section may be empty/missing if platform_launch_core1 is not used */ |
264 |
| - |
265 |
| - /* by default we put core 0 stack at the end of scratch Y, so that if core 1 |
266 |
| - * stack is not used then all of SCRATCH_X is free. |
267 |
| - */ |
268 |
| - .stack1_dummy (COPY): |
269 |
| - { |
270 |
| - *(.stack1*) |
271 |
| - } > SCRATCH_X |
272 |
| - .stack_dummy (COPY): |
273 |
| - { |
274 |
| - *(.stack*) |
275 |
| - } > SCRATCH_Y |
276 |
| - |
277 |
| - .flash_end : { |
278 |
| - __flash_binary_end = .; |
279 |
| - } > FLASH_FIRMWARE |
280 |
| - |
281 |
| - /* stack limit is poorly named, but historically is maximum heap ptr */ |
282 |
| - __StackLimit = ORIGIN(RAM) + LENGTH(RAM); |
283 |
| - __StackOneTop = ORIGIN(SCRATCH_X) + LENGTH(SCRATCH_X); |
284 |
| - __StackTop = ORIGIN(SCRATCH_Y) + LENGTH(SCRATCH_Y); |
285 |
| - __StackOneBottom = __StackOneTop - SIZEOF(.stack1_dummy); |
286 |
| - __StackBottom = __StackTop - SIZEOF(.stack_dummy); |
287 |
| - PROVIDE(__stack = __StackTop); |
288 |
| - |
289 |
| - /* Check if data + heap + stack exceeds RAM limit */ |
290 |
| - ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed") |
291 |
| - |
292 |
| - ASSERT( __binary_info_header_end - __logical_binary_start <= 256, "Binary info must be in first 256 bytes of the binary") |
293 |
| - /* todo assert on extra code */ |
294 |
| -} |
| 1 | +firmware_size = 1532k; |
0 commit comments