corstone300.ld 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  1. /*
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing,
  13. * software distributed under the License is distributed on an
  14. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  15. * KIND, either express or implied. See the License for the
  16. * specific language governing permissions and limitations
  17. * under the License.
  18. */
  19. /*------------------ Reference System Memories -------------
  20. +===================+============+=======+============+============+
  21. | Memory | Address | Size | CPU Access | NPU Access |
  22. +===================+============+=======+============+============+
  23. | ITCM | 0x00000000 | 512KB | Yes (RO) | No |
  24. +-------------------+------------+-------+------------+------------+
  25. | DTCM | 0x20000000 | 512KB | Yes (R/W) | No |
  26. +-------------------+------------+-------+------------+------------+
  27. | SSE-300 SRAM | 0x21000000 | 2MB | Yes (R/W) | Yes (R/W) |
  28. +-------------------+------------+-------+------------+------------+
  29. | Data SRAM | 0x01000000 | 2MB | Yes (R/W) | Yes (R/W) |
  30. +-------------------+------------+-------+------------+------------+
  31. | DDR | 0x60000000 | 32MB | Yes (R/W) | Yes (R/W) |
  32. +-------------------+------------+-------+------------+------------+ */
  33. /*---------------------- ITCM Configuration ----------------------------------
  34. <h> Flash Configuration
  35. <o0> Flash Base Address <0x0-0xFFFFFFFF:8>
  36. <o1> Flash Size (in Bytes) <0x0-0xFFFFFFFF:8>
  37. </h>
  38. -----------------------------------------------------------------------------*/
  39. __ROM_BASE = 0x00000000;
  40. __ROM_SIZE = 0x00080000;
  41. /*--------------------- DTCM RAM Configuration ----------------------------
  42. <h> RAM Configuration
  43. <o0> RAM Base Address <0x0-0xFFFFFFFF:8>
  44. <o1> RAM Size (in Bytes) <0x0-0xFFFFFFFF:8>
  45. </h>
  46. -----------------------------------------------------------------------------*/
  47. __RAM_BASE = 0x20000000;
  48. __RAM_SIZE = 0x00080000;
  49. /*----------------------- Data SRAM Configuration ------------------------------
  50. <h> Data SRAM Configuration
  51. <o0> DATA_SRAM Base Address <0x0-0xFFFFFFFF:8>
  52. <o1> DATA_SRAM Size (in Bytes) <0x0-0xFFFFFFFF:8>
  53. </h>
  54. -----------------------------------------------------------------------------*/
  55. __DATA_SRAM_BASE = 0x01000000;
  56. __DATA_SRAM_SIZE = 0x00200000;
  57. /*--------------------- Embedded SRAM Configuration ----------------------------
  58. <h> SRAM Configuration
  59. <o0> SRAM Base Address <0x0-0xFFFFFFFF:8>
  60. <o1> SRAM Size (in Bytes) <0x0-0xFFFFFFFF:8>
  61. </h>
  62. -----------------------------------------------------------------------------*/
  63. __SRAM_BASE = 0x21000000;
  64. __SRAM_SIZE = 0x00200000;
  65. /*--------------------- Stack / Heap Configuration ----------------------------
  66. <h> Stack / Heap Configuration
  67. <o0> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>
  68. <o1> Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
  69. </h>
  70. -----------------------------------------------------------------------------*/
  71. __STACK_SIZE = 0x00008000;
  72. __HEAP_SIZE = 0x00008000;
  73. /*--------------------- Embedded RAM Configuration ----------------------------
  74. <h> DDR Configuration
  75. <o0> DDR Base Address <0x0-0xFFFFFFFF:8>
  76. <o1> DDR Size (in Bytes) <0x0-0xFFFFFFFF:8>
  77. </h>
  78. -----------------------------------------------------------------------------*/
  79. __DDR_BASE = 0x60000000;
  80. __DDR_SIZE = 0x02000000;
  81. /*
  82. *-------------------- <<< end of configuration section >>> -------------------
  83. */
  84. MEMORY
  85. {
  86. ITCM (rx) : ORIGIN = __ROM_BASE, LENGTH = __ROM_SIZE
  87. DTCM (rwx) : ORIGIN = __RAM_BASE, LENGTH = __RAM_SIZE
  88. DATA_SRAM (rwx) : ORIGIN = __DATA_SRAM_BASE, LENGTH = __DATA_SRAM_SIZE
  89. SRAM (rwx) : ORIGIN = __SRAM_BASE, LENGTH = __SRAM_SIZE
  90. DDR (rwx) : ORIGIN = __DDR_BASE, LENGTH = __DDR_SIZE
  91. }
  92. /* Linker script to place sections and symbol values. Should be used together
  93. * with other linker script that defines memory regions ITCM and RAM.
  94. * It references following symbols, which must be defined in code:
  95. * Reset_Handler : Entry of reset handler
  96. *
  97. * It defines following symbols, which code can use without definition:
  98. * __exidx_start
  99. * __exidx_end
  100. * __copy_table_start__
  101. * __copy_table_end__
  102. * __zero_table_start__
  103. * __zero_table_end__
  104. * __etext
  105. * __data_start__
  106. * __preinit_array_start
  107. * __preinit_array_end
  108. * __init_array_start
  109. * __init_array_end
  110. * __fini_array_start
  111. * __fini_array_end
  112. * __data_end__
  113. * __bss_start__
  114. * __bss_end__
  115. * __end__
  116. * end
  117. * __HeapLimit
  118. * __StackLimit
  119. * __StackTop
  120. * __stack
  121. */
  122. ENTRY(Reset_Handler)
  123. SECTIONS
  124. {
  125. /* .ddr is placed before .text so that .rodata.tvm is encountered before .rodata* */
  126. .ddr :
  127. {
  128. . = ALIGN (16);
  129. *(.rodata.tvm)
  130. . = ALIGN (16);
  131. *(.data.tvm);
  132. . = ALIGN(16);
  133. } > DDR
  134. .text :
  135. {
  136. KEEP(*(.vectors))
  137. *(.text*)
  138. KEEP(*(.init))
  139. KEEP(*(.fini))
  140. /* .ctors */
  141. *crtbegin.o(.ctors)
  142. *crtbegin?.o(.ctors)
  143. *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
  144. *(SORT(.ctors.*))
  145. *(.ctors)
  146. /* .dtors */
  147. *crtbegin.o(.dtors)
  148. *crtbegin?.o(.dtors)
  149. *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
  150. *(SORT(.dtors.*))
  151. *(.dtors)
  152. *(.rodata*)
  153. KEEP(*(.eh_frame*))
  154. } > ITCM
  155. .ARM.extab :
  156. {
  157. *(.ARM.extab* .gnu.linkonce.armextab.*)
  158. } > ITCM
  159. __exidx_start = .;
  160. .ARM.exidx :
  161. {
  162. *(.ARM.exidx* .gnu.linkonce.armexidx.*)
  163. } > ITCM
  164. __exidx_end = .;
  165. .copy.table :
  166. {
  167. . = ALIGN(4);
  168. __copy_table_start__ = .;
  169. LONG (__etext)
  170. LONG (__data_start__)
  171. LONG (__data_end__ - __data_start__)
  172. /* Add each additional data section here */
  173. __copy_table_end__ = .;
  174. } > ITCM
  175. .zero.table :
  176. {
  177. . = ALIGN(4);
  178. __zero_table_start__ = .;
  179. __zero_table_end__ = .;
  180. } > ITCM
  181. /**
  182. * Location counter can end up 2byte aligned with narrow Thumb code but
  183. * __etext is assumed by startup code to be the LMA of a section in DTCM
  184. * which must be 4byte aligned
  185. */
  186. __etext = ALIGN (4);
  187. .sram :
  188. {
  189. . = ALIGN(16);
  190. } > SRAM AT > SRAM
  191. .data : AT (__etext)
  192. {
  193. __data_start__ = .;
  194. *(vtable)
  195. *(.data)
  196. *(.data.*)
  197. . = ALIGN(4);
  198. /* preinit data */
  199. PROVIDE_HIDDEN (__preinit_array_start = .);
  200. KEEP(*(.preinit_array))
  201. PROVIDE_HIDDEN (__preinit_array_end = .);
  202. . = ALIGN(4);
  203. /* init data */
  204. PROVIDE_HIDDEN (__init_array_start = .);
  205. KEEP(*(SORT(.init_array.*)))
  206. KEEP(*(.init_array))
  207. PROVIDE_HIDDEN (__init_array_end = .);
  208. . = ALIGN(4);
  209. /* finit data */
  210. PROVIDE_HIDDEN (__fini_array_start = .);
  211. KEEP(*(SORT(.fini_array.*)))
  212. KEEP(*(.fini_array))
  213. PROVIDE_HIDDEN (__fini_array_end = .);
  214. KEEP(*(.jcr*))
  215. . = ALIGN(4);
  216. /* All data end */
  217. __data_end__ = .;
  218. } > DTCM
  219. .bss.noinit (NOLOAD):
  220. {
  221. . = ALIGN(16);
  222. *(.bss.noinit.*)
  223. . = ALIGN(16);
  224. } > SRAM AT > SRAM
  225. .bss :
  226. {
  227. . = ALIGN(4);
  228. __bss_start__ = .;
  229. *(.bss)
  230. *(.bss.*)
  231. *(COMMON)
  232. . = ALIGN(4);
  233. __bss_end__ = .;
  234. } > DTCM AT > DTCM
  235. .data_sram :
  236. {
  237. . = ALIGN(16);
  238. } > DATA_SRAM
  239. .heap (COPY) :
  240. {
  241. . = ALIGN(8);
  242. __end__ = .;
  243. PROVIDE(end = .);
  244. . = . + __HEAP_SIZE;
  245. . = ALIGN(8);
  246. __HeapLimit = .;
  247. } > DTCM
  248. .stack (ORIGIN(DTCM) + LENGTH(DTCM) - __STACK_SIZE) (COPY) :
  249. {
  250. . = ALIGN(8);
  251. __StackLimit = .;
  252. . = . + __STACK_SIZE;
  253. . = ALIGN(8);
  254. __StackTop = .;
  255. } > DTCM
  256. PROVIDE(__stack = __StackTop);
  257. /* Check if data + stack exceeds DTCM limit */
  258. ASSERT(__StackLimit >= __bss_end__, "region DTCM overflowed with stack")
  259. }