• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2023 HPMicro
3 * SPDX-License-Identifier: BSD-3-Clause
4 */
5
6ENTRY(_start)
7
8STACK_SIZE = _stack_size;
9HEAP_SIZE = _heap_size;
10
11MEMORY
12{
13    XPI0 (rx) : ORIGIN = 0x80003000, LENGTH = _flash_size - 0x3000
14    ILM (wx) : ORIGIN = 0x00000000, LENGTH = 256K
15    DLM (w) : ORIGIN = 0x00080000, LENGTH = 256K
16    AXI_SRAM (wx) : ORIGIN = 0x0120000, LENGTH = 256K
17    AXI_SRAM_NONCACHEABLE (wx) : ORIGIN = 0x01240000, LENGTH = 256K
18    AHB_SRAM (w) : ORIGIN = 0xF0400000, LENGTH = 32k
19    APB_SRAM (w): ORIGIN = 0xF4130000, LENGTH = 16k
20}
21
22SECTIONS
23{
24    .start : {
25        . = ALIGN(8);
26        KEEP(*(.start))
27    } > XPI0
28
29    __vector_load_addr__ = ADDR(.start) + SIZEOF(.start);
30    .vectors ORIGIN(ILM) : AT(__vector_load_addr__) {
31        . = ALIGN(8);
32        __vector_ram_start__ = .;
33        KEEP(*(.vector_table))
34        KEEP(*(.isr_vector))
35        . = ALIGN(8);
36        __vector_ram_end__ = .;
37    } > ILM
38
39    .text (__vector_load_addr__ + SIZEOF(.vectors)) : {
40        . = ALIGN(8);
41        *(.text)
42        *(.text*)
43        *(.rodata)
44        *(.rodata*)
45        *(.srodata)
46        *(.srodata*)
47
48        *(.hash)
49        *(.dyn*)
50        *(.gnu*)
51        *(.pl*)
52
53        KEEP(*(.eh_frame))
54        *(.eh_frame*)
55
56        KEEP (*(.init))
57        KEEP (*(.fini))
58
59    /* section information for usbh class */
60        . = ALIGN(8);
61        __usbh_class_info_start__ = .;
62        KEEP(*(.usbh_class_info))
63        __usbh_class_info_end__ = .;
64
65        /* RT-Thread related sections - Start */
66        /* section information for finsh shell */
67        . = ALIGN(4);
68        __fsymtab_start = .;
69        KEEP(*(FSymTab))
70        __fsymtab_end = .;
71        . = ALIGN(4);
72        __vsymtab_start = .;
73        KEEP(*(VSymTab))
74        __vsymtab_end = .;
75        . = ALIGN(4);
76
77        . = ALIGN(4);
78        __rt_init_start = .;
79        KEEP(*(SORT(.rti_fn*)))
80        __rt_init_end = .;
81        . = ALIGN(4);
82
83        /* section information for modules */
84        . = ALIGN(4);
85        __rtmsymtab_start = .;
86        KEEP(*(RTMSymTab))
87        __rtmsymtab_end = .;
88
89        /* RT-Thread related sections - end */
90        . = ALIGN(8);
91    } > XPI0
92
93    .rel : {
94        KEEP(*(.rel*))
95    } > XPI0
96
97    PROVIDE (__etext = .);
98    PROVIDE (_etext = .);
99    PROVIDE (etext = .);
100
101    __data_load_addr__ = etext;
102    .data : AT(__data_load_addr__) {
103        . = ALIGN(8);
104        __data_start__ = .;
105        __global_pointer$ = . + 0x800;
106        *(.data)
107        *(.data*)
108        *(.sdata)
109        *(.sdata*)
110
111        KEEP(*(.jcr))
112        KEEP(*(.dynamic))
113        KEEP(*(.got*))
114        KEEP(*(.got))
115        KEEP(*(.gcc_except_table))
116        KEEP(*(.gcc_except_table.*))
117
118        . = ALIGN(8);
119        PROVIDE(__preinit_array_start = .);
120        KEEP(*(.preinit_array))
121        PROVIDE(__preinit_array_end = .);
122
123        . = ALIGN(8);
124        PROVIDE(__init_array_start = .);
125        KEEP(*(SORT_BY_INIT_PRIORITY(.init_array.*)))
126        KEEP(*(.init_array))
127        PROVIDE(__init_array_end = .);
128
129        . = ALIGN(8);
130        PROVIDE(__finit_array_start = .);
131        KEEP(*(SORT_BY_INIT_PRIORITY(.finit_array.*)))
132        KEEP(*(.finit_array))
133        PROVIDE(__finit_array_end = .);
134
135        . = ALIGN(8);
136        KEEP(*crtbegin*.o(.ctors))
137        KEEP(*(EXCLUDE_FILE (*crtend*.o) .ctors))
138        KEEP(*(SORT(.ctors.*)))
139        KEEP(*(.ctors))
140
141        . = ALIGN(8);
142        KEEP(*crtbegin*.o(.dtors))
143        KEEP(*(EXCLUDE_FILE (*crtend*.o) .dtors))
144        KEEP(*(SORT(.dtors.*)))
145        KEEP(*(.dtors))
146        . = ALIGN(8);
147        __data_end__ = .;
148        PROVIDE (__edata = .);
149        PROVIDE (_edata = .);
150        PROVIDE (edata = .);
151    } > AXI_SRAM
152
153    __fast_load_addr__ = etext + SIZEOF(.data);
154    .fast : AT(__fast_load_addr__) {
155        . = ALIGN(8);
156        PROVIDE(__ramfunc_start__ = .);
157        *(.fast)
158        *(.fast.*)
159        . = ALIGN(8);
160        PROVIDE(__ramfunc_end__ = .);
161    } > ILM
162
163    .bss (NOLOAD) : {
164        . = ALIGN(8);
165        __bss_start__ = .;
166        *(.bss)
167        *(.bss*)
168        *(.sbss*)
169        *(.scommon)
170        *(.scommon*)
171        *(.dynsbss*)
172        *(COMMON)
173        . = ALIGN(8);
174        _end = .;
175        __bss_end__ = .;
176    } > AXI_SRAM
177
178    .tbss (NOLOAD) : {
179        . = ALIGN(8);
180        PROVIDE(__tbss_start__ = .);
181        __thread_pointer$ = .;
182        *(.tbss)
183        *(.tbss.*)
184        *(.gnu.linkonce.tb.*)
185        *(.tcommon)
186        . = ALIGN(8);
187        PROVIDE(__tbss_end__ = .);
188    } > AXI_SRAM
189
190    __tdata_load_addr__ = etext + SIZEOF(.data) + SIZEOF(.fast);
191    .tdata : AT(__tdata_load_addr__) {
192        . = ALIGN(8);
193        PROVIDE(__tdata_start__ = .);
194        *(.tdata)
195        *(.tdata.*)
196        *(.gnu.linkonce.td.*)
197        . = ALIGN(8);
198        PROVIDE(__tdata_end__ = .);
199    } > AXI_SRAM
200
201    .framebuffer (NOLOAD) : {
202        . = ALIGN(8);
203        KEEP(*(.framebuffer))
204        . = ALIGN(8);
205    } > AXI_SRAM
206
207    __noncacheable_init_load_addr__ = etext + SIZEOF(.data) + SIZEOF(.fast) + SIZEOF(.tdata);
208    .noncacheable.init : AT(__noncacheable_init_load_addr__) {
209        . = ALIGN(8);
210        __noncacheable_init_start__ = .;
211        KEEP(*(.noncacheable.init))
212        __noncacheable_init_end__ = .;
213        . = ALIGN(8);
214    } > AXI_SRAM_NONCACHEABLE
215
216    .noncacheable.bss (NOLOAD) : {
217        . = ALIGN(8);
218        KEEP(*(.noncacheable))
219        __noncacheable_bss_start__ = .;
220        KEEP(*(.noncacheable.bss))
221        __noncacheable_bss_end__ = .;
222        . = ALIGN(8);
223    } > AXI_SRAM_NONCACHEABLE
224
225    .ahb_sram (NOLOAD) : {
226        KEEP(*(.ahb_sram))
227    } > AHB_SRAM
228
229    .apb_sram (NOLOAD) : {
230        KEEP(*(.backup_sram))
231    } > APB_SRAM
232
233    .fast_ram (NOLOAD) : {
234        KEEP(*(.fast_ram))
235    } > DLM
236
237    .heap (NOLOAD) : {
238        . = ALIGN(8);
239        __heap_start__ = .;
240        . += HEAP_SIZE;
241        __heap_end__ = .;
242    } > DLM
243
244    .stack (NOLOAD) : {
245        . = ALIGN(8);
246        __stack_base__ = .;
247        . += STACK_SIZE;
248        . = ALIGN(8);
249        PROVIDE (_stack = .);
250        PROVIDE (_stack_safe = .);
251    } > DLM
252
253    __noncacheable_start__ = ORIGIN(AXI_SRAM_NONCACHEABLE);
254    __noncacheable_end__ = ORIGIN(AXI_SRAM_NONCACHEABLE) + LENGTH(AXI_SRAM_NONCACHEABLE);
255
256    __fw_size__ = SIZEOF(.start) + SIZEOF(.vectors) + SIZEOF(.rel) + SIZEOF(.text) + SIZEOF(.data) + SIZEOF(.fast) + SIZEOF(.tdata) + SIZEOF(.noncacheable.init);
257    ASSERT(__fw_size__ <= LENGTH(XPI0), "******  FAILED! XPI0 has not enough space!  ******")
258}
259