• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2021-2023 HPMicro
3 * SPDX-License-Identifier: BSD-3-Clause
4 */
5
6ENTRY(_start)
7
8STACK_SIZE = DEFINED(_stack_size) ? _stack_size : 0x2000;
9HEAP_SIZE = DEFINED(_heap_size) ? _heap_size : 128K;
10
11MEMORY
12{
13    XPI0 (rx) : ORIGIN = 0x80000000, LENGTH = _flash_size
14    ILM (wx) : ORIGIN = 0x00000000, LENGTH = 128K
15    DLM (w) : ORIGIN = 0x00080000, LENGTH = 128K
16    AXI_SRAM (wx) : ORIGIN = 0x01080000, LENGTH = 256K    /* AXI SRAM0 */
17    AXI_SRAM_NONCACHEABLE (wx) : ORIGIN = 0x010C0000, LENGTH = 256K
18    AHB_SRAM (w) : ORIGIN = 0xF0300000, LENGTH = 32k
19}
20
21__nor_cfg_option_load_addr__ = ORIGIN(XPI0) + 0x400;
22__boot_header_load_addr__ = ORIGIN(XPI0) + 0x1000;
23__app_load_addr__ = ORIGIN(XPI0) + 0x3000;
24__boot_header_length__ = __boot_header_end__ - __boot_header_start__;
25__app_offset__ = __app_load_addr__ - __boot_header_load_addr__;
26
27
28SECTIONS
29{
30    .nor_cfg_option __nor_cfg_option_load_addr__ : {
31        KEEP(*(.nor_cfg_option))
32    } > XPI0
33
34    .boot_header __boot_header_load_addr__ : {
35        __boot_header_start__ = .;
36        KEEP(*(.boot_header))
37        KEEP(*(.fw_info_table))
38        KEEP(*(.dc_info))
39        __boot_header_end__ = .;
40    } > XPI0
41
42    .start __app_load_addr__ : {
43        . = ALIGN(8);
44        KEEP(*(.start))
45    } > XPI0
46
47    __vector_load_addr__ = ADDR(.start) + SIZEOF(.start);
48    .vectors ORIGIN(ILM) : AT(__vector_load_addr__) {
49        . = ALIGN(8);
50        __vector_ram_start__ = .;
51        /* For OHOS Start */
52        KEEP(*(.interrupt.HalTrapVector.text));
53        KEEP(*(.interrupt.text))
54        /* For OHOS End */
55
56        KEEP(*(.vector_table))
57        KEEP(*(.isr_vector))
58        . = ALIGN(8);
59        __vector_ram_end__ = .;
60    } > ILM
61
62    .text (__vector_load_addr__ + SIZEOF(.vectors)) : {
63        . = ALIGN(8);
64        *(EXCLUDE_FILE (nx*.o* *los_*.o *riscv_hal*.o *liteos_m?kal*.o *lwip*.o) .text) /* OHOS */
65        *(EXCLUDE_FILE (nx*.o* *los_*.o *riscv_hal*.o *liteos_m?kal*.o *lwip*.o) .text*)
66        *(EXCLUDE_FILE (nx*.o* *los_*.o *riscv_hal*.o *liteos_m?kal*.o *lwip*.o) .rodata)
67        *(EXCLUDE_FILE (nx*.o* *los_*.o *riscv_hal*.o *liteos_m?kal*.o *lwip*.o) .rodata*)
68        *(EXCLUDE_FILE (nx*.o*) .srodata)
69        *(EXCLUDE_FILE (nx*.o*) .srodata*)
70
71        *(.hash)
72        *(.dyn*)
73        *(.gnu*)
74        *(.pl*)
75
76        KEEP(*(.eh_frame))
77        *(.eh_frame*)
78
79        KEEP (*(.init))
80        KEEP (*(.fini))
81
82        /* section information for usbh class */
83        . = ALIGN(8);
84        __usbh_class_info_start__ = .;
85        KEEP(*(.usbh_class_info))
86        __usbh_class_info_end__ = .;
87
88        /* RT-Thread related sections - Start */
89        /* section information for finsh shell */
90        . = ALIGN(4);
91        __fsymtab_start = .;
92        KEEP(*(FSymTab))
93        __fsymtab_end = .;
94        . = ALIGN(4);
95        __vsymtab_start = .;
96        KEEP(*(VSymTab))
97        __vsymtab_end = .;
98        . = ALIGN(4);
99
100        . = ALIGN(4);
101        __rt_init_start = .;
102        KEEP(*(SORT(.rti_fn*)))
103        __rt_init_end = .;
104        . = ALIGN(4);
105
106        /* section information for modules */
107        . = ALIGN(4);
108        __rtmsymtab_start = .;
109        KEEP(*(RTMSymTab))
110        __rtmsymtab_end = .;
111
112        /* RT-Thread related sections - end */
113        . = ALIGN(8);
114
115        /* For OHOS Start */
116        _hdf_drivers_start = .;
117        KEEP(*(.hdf.driver))
118        _hdf_drivers_end = .; /* define a section for hdf driver */
119
120         __zinitcall_bsp_start = .;
121        KEEP (*(.zinitcall.bsp0.init))
122        KEEP (*(.zinitcall.bsp1.init))
123        KEEP (*(.zinitcall.bsp2.init))
124        KEEP (*(.zinitcall.bsp3.init))
125        KEEP (*(.zinitcall.bsp4.init))
126        __zinitcall_bsp_end = .;
127        . = ALIGN(4);
128        __zinitcall_device_start = .;
129        KEEP (*(.zinitcall.device0.init))
130        KEEP (*(.zinitcall.device1.init))
131        KEEP (*(.zinitcall.device2.init))
132        KEEP (*(.zinitcall.device3.init))
133        KEEP (*(.zinitcall.device4.init))
134        __zinitcall_device_end = .;
135        . = ALIGN(4);
136        __zinitcall_core_start = .;
137        KEEP (*(.zinitcall.core0.init))
138        KEEP (*(.zinitcall.core1.init))
139        KEEP (*(.zinitcall.core2.init))
140        KEEP (*(.zinitcall.core3.init))
141        KEEP (*(.zinitcall.core4.init))
142        __zinitcall_core_end = .;
143        . = ALIGN(4);
144        __zinitcall_sys_service_start = .;
145        KEEP (*(.zinitcall.sys.service0.init))
146        KEEP (*(.zinitcall.sys.service1.init))
147        KEEP (*(.zinitcall.sys.service2.init))
148        KEEP (*(.zinitcall.sys.service3.init))
149        KEEP (*(.zinitcall.sys.service4.init))
150        __zinitcall_sys_service_end = .;
151        . = ALIGN(4);
152        __zinitcall_sys_feature_start = .;
153        KEEP (*(.zinitcall.sys.feature0.init))
154        KEEP (*(.zinitcall.sys.feature1.init))
155        KEEP (*(.zinitcall.sys.feature2.init))
156        KEEP (*(.zinitcall.sys.feature3.init))
157        KEEP (*(.zinitcall.sys.feature4.init))
158        __zinitcall_sys_feature_end = .;
159        . = ALIGN(4);
160        __zinitcall_run_start = .;
161        KEEP (*(.zinitcall.run0.init))
162        KEEP (*(.zinitcall.run1.init))
163        KEEP (*(.zinitcall.run2.init))
164        KEEP (*(.zinitcall.run3.init))
165        KEEP (*(.zinitcall.run4.init))
166        __zinitcall_run_end = .;
167        . = ALIGN(4);
168        __zinitcall_app_service_start = .;
169        KEEP (*(.zinitcall.app.service0.init))
170        KEEP (*(.zinitcall.app.service1.init))
171        KEEP (*(.zinitcall.app.service2.init))
172        KEEP (*(.zinitcall.app.service3.init))
173        KEEP (*(.zinitcall.app.service4.init))
174        __zinitcall_app_service_end = .;
175        . = ALIGN(4);
176        __zinitcall_app_feature_start = .;
177        KEEP (*(.zinitcall.app.feature0.init))
178        KEEP (*(.zinitcall.app.feature1.init))
179        KEEP (*(.zinitcall.app.feature2.init))
180        KEEP (*(.zinitcall.app.feature3.init))
181        KEEP (*(.zinitcall.app.feature4.init))
182        __zinitcall_app_feature_end = .;
183        . = ALIGN(4);
184        __zinitcall_test_start = .;
185        KEEP (*(.zinitcall.test0.init))
186        KEEP (*(.zinitcall.test1.init))
187        KEEP (*(.zinitcall.test2.init))
188        KEEP (*(.zinitcall.test3.init))
189        KEEP (*(.zinitcall.test4.init))
190        __zinitcall_test_end = .;
191        . = ALIGN(4);
192        __zinitcall_exit_start = .;
193        KEEP (*(.zinitcall.exit0.init))
194        KEEP (*(.zinitcall.exit1.init))
195        KEEP (*(.zinitcall.exit2.init))
196        KEEP (*(.zinitcall.exit3.init))
197        KEEP (*(.zinitcall.exit4.init))
198        __zinitcall_exit_end = .;
199        *lwip*.o (.text* .rodata*)
200        . = ALIGN(4);
201        /* For OHOS End */
202    } > XPI0
203
204    .rel : {
205        KEEP(*(.rel*))
206    } > XPI0
207
208    PROVIDE (__etext = .);
209    PROVIDE (_etext = .);
210    PROVIDE (etext = .);
211
212    __data_load_addr__ = etext;
213    .data : AT(__data_load_addr__) {
214        . = ALIGN(8);
215        __data_start__ = .;
216        __global_pointer$ = . + 0x800;
217        *(.data)
218        *(.data*)
219        *(.sdata)
220        *(.sdata*)
221
222        KEEP(*(.jcr))
223        KEEP(*(.dynamic))
224        KEEP(*(.got*))
225        KEEP(*(.got))
226        KEEP(*(.gcc_except_table))
227        KEEP(*(.gcc_except_table.*))
228
229        . = ALIGN(8);
230        PROVIDE(__preinit_array_start = .);
231        KEEP(*(.preinit_array))
232        PROVIDE(__preinit_array_end = .);
233
234        . = ALIGN(8);
235        PROVIDE(__init_array_start = .);
236        KEEP(*(SORT_BY_INIT_PRIORITY(.init_array.*)))
237        KEEP(*(.init_array))
238        PROVIDE(__init_array_end = .);
239
240        . = ALIGN(8);
241        PROVIDE(__finit_array_start = .);
242        KEEP(*(SORT_BY_INIT_PRIORITY(.finit_array.*)))
243        KEEP(*(.finit_array))
244        PROVIDE(__finit_array_end = .);
245
246        . = ALIGN(8);
247        KEEP(*crtbegin*.o(.ctors))
248        KEEP(*(EXCLUDE_FILE (*crtend*.o) .ctors))
249        KEEP(*(SORT(.ctors.*)))
250        KEEP(*(.ctors))
251
252        . = ALIGN(8);
253        KEEP(*crtbegin*.o(.dtors))
254        KEEP(*(EXCLUDE_FILE (*crtend*.o) .dtors))
255        KEEP(*(SORT(.dtors.*)))
256        KEEP(*(.dtors))
257        . = ALIGN(8);
258        __data_end__ = .;
259        PROVIDE (__edata = .);
260        PROVIDE (_edata = .);
261        PROVIDE (edata = .);
262    } > ILM
263
264    __fast_load_addr__ = etext + SIZEOF(.data);
265    .fast : AT(__fast_load_addr__) {
266        . = ALIGN(8);
267        PROVIDE(__ramfunc_start__ = .);
268        *(.fast)
269        *(.fast.*)
270        nx*.o*(.text)
271        nx*.o*(.text*)
272        nx*.o*(.rodata)
273        nx*.o*(.rodata*)
274        nx*.o*(.srodata)
275        nx*.o*(.srodata*)
276        *riscv_hal*.o (.text* .rodata*)
277        *los_*.o (.text* .rodata*)
278        *liteos_m?kal*.o (.text* .rodata*)
279        . = ALIGN(8);
280        PROVIDE(__ramfunc_end__ = .);
281    } > ILM
282
283    .bss (NOLOAD) : {
284        . = ALIGN(8);
285        __bss_start__ = .;
286        *(.bss)
287        *(.bss*)
288        *(.sbss*)
289        *(.scommon)
290        *(.scommon*)
291        *(.dynsbss*)
292        *(COMMON)
293        . = ALIGN(8);
294        _end = .;
295        __bss_end__ = .;
296    } > AXI_SRAM
297
298    .tbss (NOLOAD) : {
299        . = ALIGN(8);
300        PROVIDE(__tbss_start__ = .);
301        __thread_pointer$ = .;
302        *(.tbss)
303        *(.tbss.*)
304        *(.gnu.linkonce.tb.*)
305        *(.tcommon)
306        . = ALIGN(8);
307        PROVIDE(__tbss_end__ = .);
308    } > AXI_SRAM
309
310    __tdata_load_addr__ = etext + SIZEOF(.data) + SIZEOF(.fast);
311    .tdata : AT(__tdata_load_addr__) {
312        . = ALIGN(8);
313        PROVIDE(__tdata_start__ = .);
314        *(.tdata)
315        *(.tdata.*)
316        *(.gnu.linkonce.td.*)
317        . = ALIGN(8);
318        PROVIDE(__tdata_end__ = .);
319    } > AXI_SRAM
320
321    .framebuffer (NOLOAD) : {
322        . = ALIGN(8);
323        KEEP(*(.framebuffer))
324        . = ALIGN(8);
325    } > AXI_SRAM
326
327    __noncacheable_init_load_addr__ = etext + SIZEOF(.data) + SIZEOF(.fast) + SIZEOF(.tdata);
328    .noncacheable.init : AT(__noncacheable_init_load_addr__) {
329        . = ALIGN(8);
330        __noncacheable_init_start__ = .;
331        KEEP(*(.noncacheable.init))
332        __noncacheable_init_end__ = .;
333        . = ALIGN(8);
334    } > AXI_SRAM_NONCACHEABLE
335
336    .noncacheable.bss (NOLOAD) : {
337        . = ALIGN(8);
338        KEEP(*(.noncacheable))
339        __noncacheable_bss_start__ = .;
340        KEEP(*(.noncacheable.bss))
341        __noncacheable_bss_end__ = .;
342        . = ALIGN(8);
343    } > AXI_SRAM_NONCACHEABLE
344
345    .ahb_sram (NOLOAD) : {
346        KEEP(*(.ahb_sram))
347    } > AHB_SRAM
348
349    .fast_ram (NOLOAD) : {
350        KEEP(*(.fast_ram))
351    } > ILM
352
353    .heap (NOLOAD) : {
354        . = ALIGN(8);
355        __heap_start = .; /* Only for OHOS Start*/
356        __heap_start__ = .;
357        . += HEAP_SIZE;
358        __heap_end__ = .;
359        __heap_end = .; /* Only for OHOS  End */
360    } > DLM
361
362    __heap_size = HEAP_SIZE;
363
364    .stack (NOLOAD) : {
365        . = ALIGN(8);
366        __stack_bootom = .; /* Only for OHOS  */
367        . += STACK_SIZE; /* Only for OHOS  */
368        __except_stack_top = .; /* Only for OHOS  */
369
370        __stack_base__ = .;
371        . += STACK_SIZE;
372        . = ALIGN(8);
373        PROVIDE (_stack = .);
374        PROVIDE (_stack_safe = .);
375        __start_and_irq_stack_top = .; /* Only for OHOS  */
376    } > AXI_SRAM
377
378    __noncacheable_start__ = ORIGIN(AXI_SRAM_NONCACHEABLE);
379    __noncacheable_end__ = ORIGIN(AXI_SRAM_NONCACHEABLE) + LENGTH(AXI_SRAM_NONCACHEABLE);
380
381    __fw_size__ = SIZEOF(.start) + SIZEOF(.vectors) + SIZEOF(.rel) + SIZEOF(.text) + SIZEOF(.data) + SIZEOF(.fast) + SIZEOF(.tdata) + SIZEOF(.noncacheable.init);
382    ASSERT(__fw_size__ <= LENGTH(XPI0), "******  FAILED! XPI0 has not enough space!  ******")
383}
384