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