1/**************************************************************************//** 2 * @file gcc.ld 3 * @brief Linker script for ASR582x Device 4 * @version V1.00 5 * @date 3. March 2022 6 * 7 * @note 8 * 9 ******************************************************************************/ 10/* 11 * Copyright (c) 2022 ASR Microelectronics (Shanghai) Co., Ltd. All rights reserved. 12 * Licensed under the Apache License, Version 2.0 (the "License"); 13 * you may not use this file except in compliance with the License. 14 * You may obtain a copy of the License at 15 * 16 * http://www.apache.org/licenses/LICENSE-2.0 17 * 18 * Unless required by applicable law or agreed to in writing, software 19 * distributed under the License is distributed on an "AS IS" BASIS, 20 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21 * See the License for the specific language governing permissions and 22 * limitations under the License. 23 */ 24 25/* Entry Point */ 26ENTRY(Reset_Handler) 27 28/* Highest address of the user mode stack */ 29_estack = 0x20FFF000; 30 31/* Generate a link error if heap and stack don't fit into RAM */ 32_Min_Heap_Size = 0x10000; /* required amount of heap */ 33_Min_Stack_Size = 0x2000; /* required amount of stack */ 34 35_VECTOR_REMAP_ADDR = 0x00087F00; 36 37/* Specify the memory areas */ 38MEMORY 39{ 40 FLASH (xr) : ORIGIN = 0x10012000, LENGTH = 1432K 41 ITCM (xrw) : ORIGIN = 0x00080000, LENGTH = 32K 42 RAM (xrw) : ORIGIN = 0x20FD0400, LENGTH = 187K 43 RAM2 (xrw) : ORIGIN = 0x21000000, LENGTH = 96K /*RAM2 for Application*/ 44 SHARED_MEMORY(rw) : ORIGIN = 0x60000000, LENGTH = 32K 45} 46 47/* Define output sections */ 48SECTIONS 49{ 50 _stext = .; 51/* The startup code goes first into FLASH */ 52 .isr_vector : 53 { 54 . = ALIGN(4); 55 KEEP(*(.isr_vector)) /* Startup code */ 56 . = 0x100; 57 } >FLASH 58 59 .app_version_sec : 60 { 61 KEEP(*(app_version_sec)) 62 . = ALIGN(0x10); 63 } >FLASH 64 65 /* The program code and other data goes into FLASH */ 66 .text : 67 { 68 . = ALIGN(4); 69 70 *(EXCLUDE_FILE (*memcpy.o *rand.o *_clzsi2.o *los_dispatch.o *los_exc.o *lega_rtos.o).text) 71 *(EXCLUDE_FILE (*memcpy.o *rand.o *_clzsi2.o *los_dispatch.o *los_exc.o *lega_rtos.o).text*) 72 73 *(.glue_7) /* glue arm to thumb code */ 74 *(.glue_7t) /* glue thumb to arm code */ 75 *(.eh_frame) 76 77 . = ALIGN(4); 78 __zinitcall_bsp_start = .; 79 KEEP (*(.zinitcall.bsp0.init)) 80 KEEP (*(.zinitcall.bsp1.init)) 81 KEEP (*(.zinitcall.bsp2.init)) 82 KEEP (*(.zinitcall.bsp3.init)) 83 KEEP (*(.zinitcall.bsp4.init)) 84 __zinitcall_bsp_end = .; 85 __zinitcall_device_start = .; 86 KEEP (*(.zinitcall.device0.init)) 87 KEEP (*(.zinitcall.device1.init)) 88 KEEP (*(.zinitcall.device2.init)) 89 KEEP (*(.zinitcall.device3.init)) 90 KEEP (*(.zinitcall.device4.init)) 91 __zinitcall_device_end = .; 92 __zinitcall_core_start = .; 93 KEEP (*(.zinitcall.core0.init)) 94 KEEP (*(.zinitcall.core1.init)) 95 KEEP (*(.zinitcall.core2.init)) 96 KEEP (*(.zinitcall.core3.init)) 97 KEEP (*(.zinitcall.core4.init)) 98 __zinitcall_core_end = .; 99 __zinitcall_sys_service_start = .; 100 KEEP (*(.zinitcall.sys.service0.init)) 101 KEEP (*(.zinitcall.sys.service1.init)) 102 KEEP (*(.zinitcall.sys.service2.init)) 103 KEEP (*(.zinitcall.sys.service3.init)) 104 KEEP (*(.zinitcall.sys.service4.init)) 105 __zinitcall_sys_service_end = .; 106 __zinitcall_sys_feature_start = .; 107 KEEP (*(.zinitcall.sys.feature0.init)) 108 KEEP (*(.zinitcall.sys.feature1.init)) 109 KEEP (*(.zinitcall.sys.feature2.init)) 110 KEEP (*(.zinitcall.sys.feature3.init)) 111 KEEP (*(.zinitcall.sys.feature4.init)) 112 __zinitcall_sys_feature_end = .; 113 __zinitcall_run_start = .; 114 KEEP (*(.zinitcall.run0.init)) 115 KEEP (*(.zinitcall.run1.init)) 116 KEEP (*(.zinitcall.run2.init)) 117 KEEP (*(.zinitcall.run3.init)) 118 KEEP (*(.zinitcall.run4.init)) 119 __zinitcall_run_end = .; 120 __zinitcall_app_service_start = .; 121 KEEP (*(.zinitcall.app.service0.init)) 122 KEEP (*(.zinitcall.app.service1.init)) 123 KEEP (*(.zinitcall.app.service2.init)) 124 KEEP (*(.zinitcall.app.service3.init)) 125 KEEP (*(.zinitcall.app.service4.init)) 126 __zinitcall_app_service_end = .; 127 __zinitcall_app_feature_start = .; 128 KEEP (*(.zinitcall.app.feature0.init)) 129 KEEP (*(.zinitcall.app.feature1.init)) 130 KEEP (*(.zinitcall.app.feature2.init)) 131 KEEP (*(.zinitcall.app.feature3.init)) 132 KEEP (*(.zinitcall.app.feature4.init)) 133 __zinitcall_app_feature_end = .; 134 __zinitcall_test_start = .; 135 KEEP (*(.zinitcall.test0.init)) 136 KEEP (*(.zinitcall.test1.init)) 137 KEEP (*(.zinitcall.test2.init)) 138 KEEP (*(.zinitcall.test3.init)) 139 KEEP (*(.zinitcall.test4.init)) 140 __zinitcall_test_end = .; 141 __zinitcall_exit_start = .; 142 KEEP (*(.zinitcall.exit0.init)) 143 KEEP (*(.zinitcall.exit1.init)) 144 KEEP (*(.zinitcall.exit2.init)) 145 KEEP (*(.zinitcall.exit3.init)) 146 KEEP (*(.zinitcall.exit4.init)) 147 __zinitcall_exit_end = .; 148 149 KEEP (*(.init)) 150 KEEP (*(.fini)) 151 152 . = ALIGN(4); 153 _etext = .; /* define a global symbols at end of code */ 154 } >FLASH 155 156 /* Constant data goes into FLASH */ 157 .rodata : 158 { 159 . = ALIGN(4); 160 161 *(EXCLUDE_FILE (*_clz.o).rodata) 162 *(EXCLUDE_FILE (*_clz.o).rodata*) 163 164 . = ALIGN(4); 165 } >FLASH 166 167 .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH 168 .ARM : { 169 __exidx_start = .; 170 *(.ARM.exidx*) 171 __exidx_end = .; 172 } >FLASH 173 174 .preinit_array : 175 { 176 PROVIDE_HIDDEN (__preinit_array_start = .); 177 KEEP (*(.preinit_array*)) 178 PROVIDE_HIDDEN (__preinit_array_end = .); 179 } >FLASH 180 181 .init_array : 182 { 183 PROVIDE_HIDDEN (__init_array_start = .); 184 KEEP (*(SORT(.init_array.*))) 185 KEEP (*(.init_array*)) 186 PROVIDE_HIDDEN (__init_array_end = .); 187 } >FLASH 188 189 .fini_array : 190 { 191 PROVIDE_HIDDEN (__fini_array_start = .); 192 KEEP (*(SORT(.fini_array.*))) 193 KEEP (*(.fini_array*)) 194 PROVIDE_HIDDEN (__fini_array_end = .); 195 } >FLASH 196 197 .hdf_drivers_entry : 198 { 199 _hdf_drivers_start = .; 200 KEEP(*(.hdf.driver)) 201 _hdf_drivers_end = .; 202 } >FLASH 203 204 /* shared RAM */ 205 sharemem(NOLOAD): 206 { 207 . = ALIGN(4); 208 _shmem_s = .; 209 *(SHAREDRAM) 210 . = ALIGN(4); 211 _shmem_e = .; 212 } >SHARED_MEMORY 213 214 /* used by the startup to initialize data */ 215 _sidata = LOADADDR(.data); 216 217 /* Initialized data sections goes into RAM, load LMA copy after code */ 218 .data : 219 { 220 . = ALIGN(4); 221 _sdata = .; /* create a global symbol at data start */ 222 *(.data) /* .data sections */ 223 *(.data*) /* .data* sections */ 224 225 *_clz.o (.rodata .rodata*) 226 227 . = ALIGN(4); 228 _edata = .; 229 } >RAM AT>FLASH 230 231 /* some bss filed putted in DTCM*/ 232 . = ALIGN(4); 233 .bss_dtcm(NOLOAD) : 234 { 235 _bdsdata = .; 236 . = ALIGN(4); 237 KEEP(*(BSS_DTCM)) 238 . = ALIGN(4); 239 _bdedata = .; /* define a global symbol at data end */ 240 } >RAM 241 242 /* Uninitialized data section */ 243 . = ALIGN(4); 244 .bss : 245 { 246 /* This is used by the startup in order to initialize the .bss secion */ 247 _sbss = .; /* define a global symbol at bss start */ 248 __bss_start__ = _sbss; 249 *(.bss) 250 *(.bss*) 251 *(COMMON) 252 253 . = ALIGN(4); 254 _ebss = .; /* define a global symbol at bss end */ 255 __bss_end__ = _ebss; 256 } >RAM2 257 258 /* used by the startup to initialize data */ 259 _sifunc = LOADADDR(.func); 260 261 /* Initialized func sections goes into ROM, load LMA copy after code */ 262 .func : 263 { 264 . = ALIGN(4); 265 _sfunc = .; /* create a global symbol at func start */ 266 *(seg_critical_function) /* .func sections */ 267 *(seg_flash_driver) 268 *(seg_wf_flash_driver) 269 *rand.o(.text*) 270 *memcpy.o(.text*) 271 *_clzsi2.o (.text .text*) 272 *los_dispatch.o(.text .text*) 273 *los_exc.o(.text .text*) 274 *lega_rtos.o (.text .text*) 275 276 . = ALIGN(4); 277 _efunc = .; /* define a global symbol at func end */ 278 } >ITCM AT>FLASH 279 280 /* some bss filed putted in ITCM*/ 281 . = ALIGN(4); 282 .bss_itcm(NOLOAD) : 283 { 284 _bisdata = .; 285 . = ALIGN(4); 286 KEEP(*(BSS_ITCM)) 287 . = ALIGN(4); 288 _biedata = .; /* define a global symbol at data end */ 289 } >ITCM 290 291 /* Remove information from the standard libraries */ 292 /DISCARD/ : 293 { 294 libc.a ( * ) 295 libm.a ( * ) 296 libgcc.a ( * ) 297 } 298 _sstack = .; 299 300 /* User_heap_stack section, used to check that there is enough RAM left */ 301 PROVIDE ( end = _bdedata ); 302 PROVIDE ( _end = _bdedata ); 303 304 /* system stack */ 305 PROVIDE (_stack_base = _estack - _Min_Stack_Size); /* _estack is top of stack*/ 306 ASSERT ((_stack_base > end), "Error: No room left for the stack") 307 /* _estack is top of stack*/ 308 309 /* left ram for heap */ 310 PROVIDE (__los_heap_addr_start__ = _end); 311 PROVIDE (__los_heap_addr_end__ = _stack_base - 1); 312 PROVIDE (heap_len = __los_heap_addr_end__ - __los_heap_addr_start__); 313 ASSERT ((heap_len > _Min_Heap_Size), "Error: No room left for the heap") 314 315 ASSERT ((_biedata < _VECTOR_REMAP_ADDR), "Error: No room left for ITCM") 316 317 .ARM.attributes 0 : { *(.ARM.attributes) } 318} 319