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 : 130K; 10 11MEMORY 12{ 13 XPI0 (rx) : ORIGIN = 0x80000000, LENGTH = _flash_size 14 ILM (wx) : ORIGIN = 0x00000000, LENGTH = 256K 15 DLM (w) : ORIGIN = 0x00080000, LENGTH = 256K 16 AXI_SRAM (wx) : ORIGIN = 0x01200000, LENGTH = 256K 17 NONCACHEABLE_RAM (w) : ORIGIN = 0x01240000, LENGTH = 256K 18 AHB_SRAM (w) : ORIGIN = 0xF0400000, LENGTH = 32k 19 APB_SRAM (w): ORIGIN = 0xF4130000, LENGTH = 16k 20} 21 22__nor_cfg_option_load_addr__ = ORIGIN(XPI0) + 0x400; 23__boot_header_load_addr__ = ORIGIN(XPI0) + 0x1000; 24__app_load_addr__ = ORIGIN(XPI0) + 0x3000; 25__boot_header_length__ = __boot_header_end__ - __boot_header_start__; 26__app_offset__ = __app_load_addr__ - __boot_header_load_addr__; 27 28 29SECTIONS 30{ 31 .nor_cfg_option __nor_cfg_option_load_addr__ : { 32 KEEP(*(.nor_cfg_option)) 33 } > XPI0 34 35 .boot_header __boot_header_load_addr__ : { 36 __boot_header_start__ = .; 37 KEEP(*(.boot_header)) 38 KEEP(*(.fw_info_table)) 39 KEEP(*(.dc_info)) 40 __boot_header_end__ = .; 41 } > XPI0 42 43 .start __app_load_addr__ : { 44 . = ALIGN(8); 45 KEEP(*(.start)) 46 } > XPI0 47 48 __vector_load_addr__ = ADDR(.start) + SIZEOF(.start); 49 .vectors ORIGIN(ILM) : AT(__vector_load_addr__) { 50 . = ALIGN(8); 51 __vector_ram_start__ = .; 52 /* For OHOS Start */ 53 KEEP(*(.interrupt.HalTrapVector.text)); 54 KEEP(*(.interrupt.text)) 55 /* For OHOS End */ 56 57 KEEP(*(.vector_table)) 58 KEEP(*(.isr_vector)) 59 . = ALIGN(8); 60 __vector_ram_end__ = .; 61 } > ILM 62 63 .text (__vector_load_addr__ + SIZEOF(.vectors)) : { 64 . = ALIGN(8); 65 *(EXCLUDE_FILE (nx*.o* *los_*.o *riscv_hal*.o *liteos_m?kal*.o *lwip*.o) .text) /* OHOS */ 66 *(EXCLUDE_FILE (nx*.o* *los_*.o *riscv_hal*.o *liteos_m?kal*.o *lwip*.o) .text*) 67 *(EXCLUDE_FILE (nx*.o* *los_*.o *riscv_hal*.o *liteos_m?kal*.o *lwip*.o) .rodata) 68 *(EXCLUDE_FILE (nx*.o* *los_*.o *riscv_hal*.o *liteos_m?kal*.o *lwip*.o) .rodata*) 69 *(EXCLUDE_FILE (nx*.o*) .srodata) 70 *(EXCLUDE_FILE (nx*.o*) .srodata*) 71 72 *(.hash) 73 *(.dyn*) 74 *(.gnu*) 75 *(.pl*) 76 77 KEEP(*(.eh_frame)) 78 *(.eh_frame*) 79 80 KEEP (*(.init)) 81 KEEP (*(.fini)) 82 83 /* section information for usbh class */ 84 . = ALIGN(8); 85 __usbh_class_info_start__ = .; 86 KEEP(*(.usbh_class_info)) 87 __usbh_class_info_end__ = .; 88 89 /* RT-Thread related sections - Start */ 90 /* section information for finsh shell */ 91 . = ALIGN(4); 92 __fsymtab_start = .; 93 KEEP(*(FSymTab)) 94 __fsymtab_end = .; 95 . = ALIGN(4); 96 __vsymtab_start = .; 97 KEEP(*(VSymTab)) 98 __vsymtab_end = .; 99 . = ALIGN(4); 100 101 . = ALIGN(4); 102 __rt_init_start = .; 103 KEEP(*(SORT(.rti_fn*))) 104 __rt_init_end = .; 105 . = ALIGN(4); 106 107 /* section information for modules */ 108 . = ALIGN(4); 109 __rtmsymtab_start = .; 110 KEEP(*(RTMSymTab)) 111 __rtmsymtab_end = .; 112 113 /* RT-Thread related sections - end */ 114 . = ALIGN(8); 115 116 /* For OHOS Start */ 117 _hdf_drivers_start = .; 118 KEEP(*(.hdf.driver)) 119 _hdf_drivers_end = .; /* define a section for hdf driver */ 120 121 __zinitcall_bsp_start = .; 122 KEEP (*(.zinitcall.bsp0.init)) 123 KEEP (*(.zinitcall.bsp1.init)) 124 KEEP (*(.zinitcall.bsp2.init)) 125 KEEP (*(.zinitcall.bsp3.init)) 126 KEEP (*(.zinitcall.bsp4.init)) 127 __zinitcall_bsp_end = .; 128 . = ALIGN(4); 129 __zinitcall_device_start = .; 130 KEEP (*(.zinitcall.device0.init)) 131 KEEP (*(.zinitcall.device1.init)) 132 KEEP (*(.zinitcall.device2.init)) 133 KEEP (*(.zinitcall.device3.init)) 134 KEEP (*(.zinitcall.device4.init)) 135 __zinitcall_device_end = .; 136 . = ALIGN(4); 137 __zinitcall_core_start = .; 138 KEEP (*(.zinitcall.core0.init)) 139 KEEP (*(.zinitcall.core1.init)) 140 KEEP (*(.zinitcall.core2.init)) 141 KEEP (*(.zinitcall.core3.init)) 142 KEEP (*(.zinitcall.core4.init)) 143 __zinitcall_core_end = .; 144 . = ALIGN(4); 145 __zinitcall_sys_service_start = .; 146 KEEP (*(.zinitcall.sys.service0.init)) 147 KEEP (*(.zinitcall.sys.service1.init)) 148 KEEP (*(.zinitcall.sys.service2.init)) 149 KEEP (*(.zinitcall.sys.service3.init)) 150 KEEP (*(.zinitcall.sys.service4.init)) 151 __zinitcall_sys_service_end = .; 152 . = ALIGN(4); 153 __zinitcall_sys_feature_start = .; 154 KEEP (*(.zinitcall.sys.feature0.init)) 155 KEEP (*(.zinitcall.sys.feature1.init)) 156 KEEP (*(.zinitcall.sys.feature2.init)) 157 KEEP (*(.zinitcall.sys.feature3.init)) 158 KEEP (*(.zinitcall.sys.feature4.init)) 159 __zinitcall_sys_feature_end = .; 160 . = ALIGN(4); 161 __zinitcall_run_start = .; 162 KEEP (*(.zinitcall.run0.init)) 163 KEEP (*(.zinitcall.run1.init)) 164 KEEP (*(.zinitcall.run2.init)) 165 KEEP (*(.zinitcall.run3.init)) 166 KEEP (*(.zinitcall.run4.init)) 167 __zinitcall_run_end = .; 168 . = ALIGN(4); 169 __zinitcall_app_service_start = .; 170 KEEP (*(.zinitcall.app.service0.init)) 171 KEEP (*(.zinitcall.app.service1.init)) 172 KEEP (*(.zinitcall.app.service2.init)) 173 KEEP (*(.zinitcall.app.service3.init)) 174 KEEP (*(.zinitcall.app.service4.init)) 175 __zinitcall_app_service_end = .; 176 . = ALIGN(4); 177 __zinitcall_app_feature_start = .; 178 KEEP (*(.zinitcall.app.feature0.init)) 179 KEEP (*(.zinitcall.app.feature1.init)) 180 KEEP (*(.zinitcall.app.feature2.init)) 181 KEEP (*(.zinitcall.app.feature3.init)) 182 KEEP (*(.zinitcall.app.feature4.init)) 183 __zinitcall_app_feature_end = .; 184 . = ALIGN(4); 185 __zinitcall_test_start = .; 186 KEEP (*(.zinitcall.test0.init)) 187 KEEP (*(.zinitcall.test1.init)) 188 KEEP (*(.zinitcall.test2.init)) 189 KEEP (*(.zinitcall.test3.init)) 190 KEEP (*(.zinitcall.test4.init)) 191 __zinitcall_test_end = .; 192 . = ALIGN(4); 193 __zinitcall_exit_start = .; 194 KEEP (*(.zinitcall.exit0.init)) 195 KEEP (*(.zinitcall.exit1.init)) 196 KEEP (*(.zinitcall.exit2.init)) 197 KEEP (*(.zinitcall.exit3.init)) 198 KEEP (*(.zinitcall.exit4.init)) 199 __zinitcall_exit_end = .; 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 } > DLM 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 *lwip*.o (.text* .rodata*) 280 . = ALIGN(8); 281 PROVIDE(__ramfunc_end__ = .); 282 } > ILM 283 284 .bss (NOLOAD) : { 285 . = ALIGN(8); 286 __bss_start__ = .; 287 *(.bss) 288 *(.bss*) 289 *(.sbss*) 290 *(.scommon) 291 *(.scommon*) 292 *(.dynsbss*) 293 *(COMMON) 294 . = ALIGN(8); 295 _end = .; 296 __bss_end__ = .; 297 } > DLM 298 299 .tbss (NOLOAD) : { 300 . = ALIGN(8); 301 PROVIDE(__tbss_start__ = .); 302 __thread_pointer$ = .; 303 *(.tbss) 304 *(.tbss.*) 305 *(.gnu.linkonce.tb.*) 306 *(.tcommon) 307 . = ALIGN(8); 308 PROVIDE(__tbss_end__ = .); 309 } > AXI_SRAM 310 311 __tdata_load_addr__ = etext + SIZEOF(.data) + SIZEOF(.fast); 312 .tdata : AT(__tdata_load_addr__) { 313 . = ALIGN(8); 314 PROVIDE(__tdata_start__ = .); 315 *(.tdata) 316 *(.tdata.*) 317 *(.gnu.linkonce.td.*) 318 . = ALIGN(8); 319 PROVIDE(__tdata_end__ = .); 320 } > AXI_SRAM 321 322 .framebuffer (NOLOAD) : { 323 . = ALIGN(8); 324 KEEP(*(.framebuffer)) 325 . = ALIGN(8); 326 } > AXI_SRAM 327 328 __noncacheable_init_load_addr__ = etext + SIZEOF(.data) + SIZEOF(.fast) + SIZEOF(.tdata); 329 .noncacheable.init : AT(__noncacheable_init_load_addr__) { 330 . = ALIGN(8); 331 __noncacheable_init_start__ = .; 332 KEEP(*(.noncacheable.init)) 333 __noncacheable_init_end__ = .; 334 . = ALIGN(8); 335 } > NONCACHEABLE_RAM 336 337 .noncacheable.bss (NOLOAD) : { 338 . = ALIGN(8); 339 KEEP(*(.noncacheable)) 340 __noncacheable_bss_start__ = .; 341 KEEP(*(.noncacheable.bss)) 342 __noncacheable_bss_end__ = .; 343 . = ALIGN(8); 344 } > NONCACHEABLE_RAM 345 346 .ahb_sram (NOLOAD) : { 347 KEEP(*(.ahb_sram)) 348 } > AHB_SRAM 349 350 .apb_sram (NOLOAD) : { 351 KEEP(*(.backup_sram)) 352 } > APB_SRAM 353 354 .fast_ram (NOLOAD) : { 355 KEEP(*(.fast_ram)) 356 } > DLM 357 358 .heap (NOLOAD) : { 359 . = ALIGN(8); 360 __heap_start = .; /* Only for OHOS Start*/ 361 __heap_start__ = .; 362 . += HEAP_SIZE; 363 __heap_end__ = .; 364 __heap_end = .; /* Only for OHOS End */ 365 } > AXI_SRAM 366 367 __heap_size = HEAP_SIZE; 368 369 .stack (NOLOAD) : { 370 . = ALIGN(8); 371 __stack_bootom = .; /* Only for OHOS */ 372 . += STACK_SIZE; /* Only for OHOS */ 373 __except_stack_top = .; /* Only for OHOS */ 374 375 __stack_base__ = .; 376 . += STACK_SIZE; 377 . = ALIGN(8); 378 PROVIDE (_stack = .); 379 PROVIDE (_stack_safe = .); 380 __start_and_irq_stack_top = .; /* Only for OHOS */ 381 } > DLM 382 383 __noncacheable_start__ = ORIGIN(NONCACHEABLE_RAM); 384 __noncacheable_end__ = ORIGIN(NONCACHEABLE_RAM) + LENGTH(NONCACHEABLE_RAM); 385 386 __fw_size__ = SIZEOF(.start) + SIZEOF(.vectors) + SIZEOF(.rel) + SIZEOF(.text) + SIZEOF(.data) + SIZEOF(.fast) + SIZEOF(.tdata) + SIZEOF(.noncacheable.init); 387 ASSERT(__fw_size__ <= LENGTH(XPI0), "****** FAILED! XPI0 has not enough space! ******") 388} 389