fsp.ld 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822
  1. /*
  2. Linker File for Renesas FSP
  3. */
  4. INCLUDE memory_regions.ld
  5. /* Uncomment and set XIP_SECONDARY_SLOT_IMAGE to 1 below for the secondary XIP application image.*/
  6. /*
  7. XIP_SECONDARY_SLOT_IMAGE = 1;
  8. */
  9. QSPI_FLASH_PRV_LENGTH = DEFINED(QSPI_FLASH_SIZE) ? ABSOLUTE(QSPI_FLASH_SIZE) : ABSOLUTE(QSPI_FLASH_LENGTH);
  10. OSPI_DEVICE_0_PRV_LENGTH = DEFINED(OSPI_DEVICE_0_SIZE) ? ABSOLUTE(OSPI_DEVICE_0_SIZE) : ABSOLUTE(OSPI_DEVICE_0_LENGTH);
  11. OSPI_DEVICE_1_PRV_LENGTH = DEFINED(OSPI_DEVICE_1_SIZE) ? ABSOLUTE(OSPI_DEVICE_1_SIZE) : ABSOLUTE(OSPI_DEVICE_1_LENGTH);
  12. /* If a flat (secure) project has DEFINED RAM_NS_BUFFER_LENGTH, then emit IDAU symbols to allocate non-secure RAM. */
  13. __RESERVE_NS_RAM = !DEFINED(PROJECT_NONSECURE) && DEFINED(RAM_NS_BUFFER_LENGTH) && (OPTION_SETTING_S_LENGTH != 0);
  14. ITCM_START = DEFINED(ITCM_START)? ITCM_START : 0;
  15. ITCM_LENGTH = DEFINED(ITCM_LENGTH)? ITCM_LENGTH : 0;
  16. DTCM_START = DEFINED(DTCM_START)? DTCM_START : 0;
  17. DTCM_LENGTH = DEFINED(DTCM_LENGTH)? DTCM_LENGTH : 0;
  18. NS_OFFSET_START = DEFINED(NS_OFFSET_START) ? NS_OFFSET_START : 0;
  19. NS_IMAGE_OFFSET = DEFINED(PROJECT_NONSECURE) ? NS_OFFSET_START : 0;
  20. RAM_NS_BUFFER_BLOCK_LENGTH = DEFINED(RAM_NS_BUFFER_LENGTH) ? ALIGN(RAM_NS_BUFFER_LENGTH, 8192) : 0;
  21. RAM_NS_BUFFER_LENGTH = DEFINED(RAM_NS_BUFFER_LENGTH) ? RAM_NS_BUFFER_LENGTH : 0;
  22. RAM_NS_BUFFER_START = RAM_START + RAM_LENGTH - RAM_NS_BUFFER_LENGTH;
  23. RAM_NS_BUFFER_BLOCK_START = RAM_START + RAM_LENGTH - RAM_NS_BUFFER_BLOCK_LENGTH;
  24. OPTION_SETTING_START_NS = DEFINED(PROJECT_NONSECURE) ? OPTION_SETTING_START : OPTION_SETTING_START + 0x80;
  25. /* This definition is used to avoid moving the counter in OPTION_SETTING regions for projects that should not configure option settings.
  26. * Bootloader images do not configure option settings because they are owned by the bootloader.
  27. * FSP_BOOTABLE_IMAGE is only defined in bootloader images. */
  28. __bl_FSP_BOOTABLE_IMAGE = 1;
  29. __bln_FSP_BOOTABLE_IMAGE = 1;
  30. PROJECT_SECURE_OR_FLAT = (!DEFINED(PROJECT_NONSECURE) || DEFINED(PROJECT_SECURE)) && OPTION_SETTING_LENGTH && !DEFINED(FSP_BOOTABLE_IMAGE);
  31. USE_OPTION_SETTING_NS = DEFINED(PROJECT_NONSECURE) && !DEFINED(FSP_BOOTABLE_IMAGE);
  32. __bl_FLASH_IMAGE_START = !DEFINED(FLASH_BOOTLOADER_LENGTH) ? 0 :
  33. FLASH_APPLICATION_IMAGE_NUMBER == 1 ? FLASH_BOOTLOADER_LENGTH + FLASH_BOOTLOADER_HEADER_LENGTH :
  34. FLASH_BOOTLOADER_LENGTH + FLASH_BOOTLOADER_SCRATCH_LENGTH + FLASH_APPLICATION_S_LENGTH + FLASH_BOOTLOADER_HEADER_LENGTH;
  35. __bl_FLASH_IMAGE_LENGTH = !DEFINED(FLASH_BOOTLOADER_LENGTH) ? 0 :
  36. FLASH_APPLICATION_S_LENGTH - FLASH_BOOTLOADER_HEADER_LENGTH;
  37. __bl_FLASH_IMAGE_END = __bl_FLASH_IMAGE_START + __bl_FLASH_IMAGE_LENGTH;
  38. __bl_XIP_SECONDARY_FLASH_IMAGE_START = !DEFINED(FLASH_BOOTLOADER_LENGTH) ? 0 :
  39. FLASH_BOOTLOADER_LENGTH + FLASH_APPLICATION_S_LENGTH + FLASH_BOOTLOADER_HEADER_LENGTH;
  40. __bl_XIP_SECONDARY_FLASH_IMAGE_END = __bl_XIP_SECONDARY_FLASH_IMAGE_START + __bl_FLASH_IMAGE_LENGTH;
  41. __bl_FLASH_NS_START = !DEFINED(FLASH_BOOTLOADER_LENGTH) ? 0 :
  42. FLASH_APPLICATION_NS_LENGTH == 0 ? __bl_FLASH_IMAGE_END :
  43. __bl_FLASH_IMAGE_START - FLASH_BOOTLOADER_HEADER_LENGTH + FLASH_APPLICATION_S_LENGTH;
  44. __bl_FLASH_NSC_START = !DEFINED(FLASH_BOOTLOADER_LENGTH) ? 0 :
  45. FLASH_APPLICATION_NS_LENGTH == 0 ? __bl_FLASH_IMAGE_END :
  46. __bl_FLASH_NS_START - FLASH_APPLICATION_NSC_LENGTH;
  47. __bl_RAM_NS_START = !DEFINED(FLASH_BOOTLOADER_LENGTH) ? 0 :
  48. FLASH_APPLICATION_NS_LENGTH == 0 ? RAM_START + RAM_LENGTH :
  49. RAM_START + RAM_LENGTH - RAM_APPLICATION_NS_LENGTH;
  50. __bl_RAM_NSC_START = !DEFINED(FLASH_BOOTLOADER_LENGTH) ? 0 :
  51. FLASH_APPLICATION_NS_LENGTH == 0 ? RAM_START + RAM_LENGTH :
  52. __bl_RAM_NS_START - RAM_APPLICATION_NSC_LENGTH;
  53. __bl_FLASH_NS_IMAGE_START = !DEFINED(FLASH_BOOTLOADER_LENGTH) ? 0 :
  54. FLASH_APPLICATION_NS_LENGTH == 0 ? __bl_FLASH_IMAGE_END :
  55. __bl_FLASH_NS_START + FLASH_BOOTLOADER_HEADER_LENGTH_2;
  56. __bln_FLASH_IMAGE_START = __bl_FLASH_NS_IMAGE_START;
  57. __bln_FLASH_IMAGE_LENGTH = !DEFINED(FLASH_BOOTLOADER_LENGTH) ? 0 :
  58. FLASH_APPLICATION_NS_LENGTH == 0 ? __bl_FLASH_IMAGE_END :
  59. FLASH_APPLICATION_NS_LENGTH - FLASH_BOOTLOADER_HEADER_LENGTH_2;
  60. XIP_SECONDARY_SLOT_IMAGE = DEFINED(XIP_SECONDARY_SLOT_IMAGE) ? XIP_SECONDARY_SLOT_IMAGE : 0;
  61. FLASH_ORIGIN = !DEFINED(FLASH_IMAGE_START) ? FLASH_START :
  62. XIP_SECONDARY_SLOT_IMAGE == 1 ? XIP_SECONDARY_FLASH_IMAGE_START :
  63. FLASH_IMAGE_START;
  64. LIMITED_FLASH_LENGTH = DEFINED(FLASH_IMAGE_LENGTH) ? FLASH_IMAGE_LENGTH :
  65. DEFINED(FLASH_BOOTLOADER_LENGTH) ? FLASH_BOOTLOADER_LENGTH :
  66. FLASH_LENGTH;
  67. /* Define memory regions. */
  68. MEMORY
  69. {
  70. ITCM (rx) : ORIGIN = ITCM_START + NS_IMAGE_OFFSET, LENGTH = ITCM_LENGTH
  71. DTCM (rwx) : ORIGIN = DTCM_START + NS_IMAGE_OFFSET, LENGTH = DTCM_LENGTH
  72. FLASH (rx) : ORIGIN = FLASH_ORIGIN + NS_IMAGE_OFFSET, LENGTH = LIMITED_FLASH_LENGTH
  73. RAM (rwx) : ORIGIN = RAM_START + NS_IMAGE_OFFSET, LENGTH = RAM_LENGTH
  74. DATA_FLASH (rx) : ORIGIN = DATA_FLASH_START + NS_IMAGE_OFFSET, LENGTH = DATA_FLASH_LENGTH
  75. QSPI_FLASH (rx) : ORIGIN = QSPI_FLASH_START, LENGTH = QSPI_FLASH_PRV_LENGTH
  76. OSPI_DEVICE_0 (rx) : ORIGIN = OSPI_DEVICE_0_START, LENGTH = OSPI_DEVICE_0_PRV_LENGTH
  77. OSPI_DEVICE_1 (rx) : ORIGIN = OSPI_DEVICE_1_START, LENGTH = OSPI_DEVICE_1_PRV_LENGTH
  78. OSPI_DEVICE_0_RAM (rwx) : ORIGIN = OSPI_DEVICE_0_START, LENGTH = OSPI_DEVICE_0_PRV_LENGTH
  79. OSPI_DEVICE_1_RAM (rwx) : ORIGIN = OSPI_DEVICE_1_START, LENGTH = OSPI_DEVICE_1_PRV_LENGTH
  80. SDRAM (rwx) : ORIGIN = SDRAM_START, LENGTH = SDRAM_LENGTH
  81. OPTION_SETTING (r) : ORIGIN = OPTION_SETTING_START + NS_IMAGE_OFFSET, LENGTH = OPTION_SETTING_LENGTH
  82. OPTION_SETTING_OFS (r) : ORIGIN = OPTION_SETTING_START + NS_IMAGE_OFFSET, LENGTH = 0x18
  83. OPTION_SETTING_SAS (r) : ORIGIN = OPTION_SETTING_START + NS_IMAGE_OFFSET + 0x34, LENGTH = OPTION_SETTING_LENGTH - 0x34
  84. OPTION_SETTING_S (r) : ORIGIN = OPTION_SETTING_S_START + NS_IMAGE_OFFSET, LENGTH = OPTION_SETTING_S_LENGTH
  85. ID_CODE (rx) : ORIGIN = ID_CODE_START, LENGTH = ID_CODE_LENGTH
  86. }
  87. /* Library configurations */
  88. GROUP(libc.a libm.a libnosys.a)
  89. /* Linker script to place sections and symbol values. Should be used together
  90. * with other linker script that defines memory regions FLASH and RAM.
  91. * It references following symbols, which must be DEFINED in code:
  92. * Reset_Handler : Entry of reset handler
  93. *
  94. * It defines following symbols, which code can use without definition:
  95. * __exidx_start
  96. * __exidx_end
  97. * __copy_table_start__
  98. * __copy_table_end__
  99. * __zero_table_start__
  100. * __zero_table_end__
  101. * __etext
  102. * __data_start__
  103. * __preinit_array_start
  104. * __preinit_array_end
  105. * __init_array_start
  106. * __init_array_end
  107. * __fini_array_start
  108. * __fini_array_end
  109. * __data_end__
  110. * __bss_start__
  111. * __bss_end__
  112. * __HeapLimit
  113. * __StackLimit
  114. * __StackTop
  115. * __stack
  116. * __Vectors_End
  117. * __Vectors_Size
  118. * __qspi_flash_start__
  119. * __qspi_flash_end__
  120. * __qspi_flash_code_size__
  121. * __qspi_region_max_size__
  122. * __qspi_region_start_address__
  123. * __qspi_region_end_address__
  124. * __ospi_device_0_start__
  125. * __ospi_device_0_end__
  126. * __ospi_device_0_code_size__
  127. * __ospi_device_0_region_max_size__
  128. * __ospi_device_0_region_start_address__
  129. * __ospi_device_0_region_end_address__
  130. * __ospi_device_1_start__
  131. * __ospi_device_1_end__
  132. * __ospi_device_1_code_size__
  133. * __ospi_device_1_region_max_size__
  134. * __ospi_device_1_region_start_address__
  135. * __ospi_device_1_region_end_address__
  136. */
  137. ENTRY(Reset_Handler)
  138. SECTIONS
  139. {
  140. .text :
  141. {
  142. __tz_FLASH_S = ABSOLUTE(FLASH_START);
  143. __ROM_Start = .;
  144. /* Even though the vector table is not 256 entries (1KB) long, we still allocate that much
  145. * space because ROM registers are at address 0x400 and there is very little space
  146. * in between. */
  147. KEEP(*(.fixed_vectors*))
  148. KEEP(*(.application_vectors*))
  149. __Vectors_End = .;
  150. /* ROM Registers start at address 0x00000400 for devices that do not have the OPTION_SETTING region. */
  151. . = OPTION_SETTING_LENGTH > 0 ? . : __ROM_Start + 0x400;
  152. KEEP(*(.rom_registers*))
  153. /* Reserving 0x100 bytes of space for ROM registers. */
  154. . = OPTION_SETTING_LENGTH > 0 ? . : __ROM_Start + 0x500;
  155. /* Allocate flash write-boundary-aligned
  156. * space for sce9 wrapped public keys for mcuboot if the module is used.
  157. */
  158. . = ALIGN(128);
  159. KEEP(*(.mcuboot_sce9_key*))
  160. *(.text*)
  161. KEEP(*(.version))
  162. KEEP(*(.init))
  163. KEEP(*(.fini))
  164. /* section information for finsh shell */
  165. . = ALIGN(4);
  166. __fsymtab_start = .;
  167. KEEP(*(FSymTab))
  168. __fsymtab_end = .;
  169. . = ALIGN(4);
  170. __vsymtab_start = .;
  171. KEEP(*(VSymTab))
  172. __vsymtab_end = .;
  173. /* section information for initial. */
  174. . = ALIGN(4);
  175. __rt_init_start = .;
  176. KEEP(*(SORT(.rti_fn*)))
  177. __rt_init_end = .;
  178. . = ALIGN(4);
  179. KEEP(*(FalPartTable))
  180. /* .ctors */
  181. *crtbegin.o(.ctors)
  182. *crtbegin?.o(.ctors)
  183. *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
  184. *(SORT(.ctors.*))
  185. *(.ctors)
  186. /* .dtors */
  187. *crtbegin.o(.dtors)
  188. *crtbegin?.o(.dtors)
  189. *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
  190. *(SORT(.dtors.*))
  191. *(.dtors)
  192. *(.rodata*)
  193. __usb_dev_descriptor_start_fs = .;
  194. KEEP(*(.usb_device_desc_fs*))
  195. __usb_cfg_descriptor_start_fs = .;
  196. KEEP(*(.usb_config_desc_fs*))
  197. __usb_interface_descriptor_start_fs = .;
  198. KEEP(*(.usb_interface_desc_fs*))
  199. __usb_descriptor_end_fs = .;
  200. __usb_dev_descriptor_start_hs = .;
  201. KEEP(*(.usb_device_desc_hs*))
  202. __usb_cfg_descriptor_start_hs = .;
  203. KEEP(*(.usb_config_desc_hs*))
  204. __usb_interface_descriptor_start_hs = .;
  205. KEEP(*(.usb_interface_desc_hs*))
  206. __usb_descriptor_end_hs = .;
  207. KEEP(*(.eh_frame*))
  208. /* new GCC version uses .init_array */
  209. PROVIDE(__ctors_start__ = .);
  210. KEEP (*(SORT(.init_array.*)))
  211. KEEP (*(.init_array))
  212. PROVIDE(__ctors_end__ = .);
  213. . = ALIGN(4);
  214. __ROM_End = .;
  215. } > FLASH = 0xFF
  216. __Vectors_Size = __Vectors_End - __Vectors;
  217. . = .;
  218. __itcm_data_pre_location = .;
  219. /* Initialized ITCM data. */
  220. /* Aligned to FCACHE2 for RA8. */
  221. .itcm_data : ALIGN(16)
  222. {
  223. /* Start of ITCM Secure Trustzone region. */
  224. __tz_ITCM_S = ABSOLUTE(ITCM_START);
  225. /* All ITCM data start */
  226. __itcm_data_start = .;
  227. KEEP(*(.itcm_data*))
  228. /* Pad to eight byte alignment in case of ECC initialization. Fill zero. */
  229. . = ALIGN(8);
  230. /* All ITCM data end */
  231. __itcm_data_end = .;
  232. /*
  233. * Start of the ITCM Non-Secure Trustzone region.
  234. * ITCM_NS_START can be used to set a fixed address for non-secure ITCM in secure projects or flat projects.
  235. */
  236. __tz_ITCM_N = DEFINED(ITCM_NS_START) ? ABSOLUTE(ITCM_NS_START) : ALIGN(__itcm_data_end, 8192);
  237. } > ITCM AT > FLASH = 0x00
  238. /* Addresses exported for ITCM initialization. */
  239. __itcm_data_init_start = LOADADDR(.itcm_data);
  240. __itcm_data_init_end = LOADADDR(.itcm_data) + SIZEOF(.itcm_data);
  241. ASSERT(ORIGIN(ITCM) % 8 == 0, "ITCM memory region origin must be aligned to 8 bytes.")
  242. ASSERT(LENGTH(ITCM) % 8 == 0, "ITCM memory region length must be a multiple of 8 bytes.")
  243. ASSERT(LOADADDR(.itcm_data) % 16 == 0, ".itcm_data section must be aligned to 16 bytes.")
  244. ASSERT(SIZEOF(.itcm_data) % 8 == 0, ".itcm_data section size must be a multiple of 8 bytes.")
  245. /* Restore location counter. */
  246. /* If ITCM is not present, this will be the address stored in '.' before ALIGN was attempted. */
  247. /* If ITCM is present, this will be the absolute address that follows the ITCM ROM location. */
  248. . = (SIZEOF(.itcm_data) > 0) ? __itcm_data_init_end : __itcm_data_pre_location;
  249. .ARM.extab :
  250. {
  251. *(.ARM.extab* .gnu.linkonce.armextab.*)
  252. } > FLASH
  253. __exidx_start = .;
  254. .ARM.exidx :
  255. {
  256. *(.ARM.exidx* .gnu.linkonce.armexidx.*)
  257. } > FLASH
  258. __exidx_end = .;
  259. /* To copy multiple ROM to RAM sections,
  260. * uncomment .copy.table section and,
  261. * define __STARTUP_COPY_MULTIPLE in startup_ARMCMx.S */
  262. /*
  263. .copy.table :
  264. {
  265. . = ALIGN(4);
  266. __copy_table_start__ = .;
  267. LONG (__etext)
  268. LONG (__data_start__)
  269. LONG (__data_end__ - __data_start__)
  270. LONG (__etext2)
  271. LONG (__data2_start__)
  272. LONG (__data2_end__ - __data2_start__)
  273. __copy_table_end__ = .;
  274. } > FLASH
  275. */
  276. /* To clear multiple BSS sections,
  277. * uncomment .zero.table section and,
  278. * define __STARTUP_CLEAR_BSS_MULTIPLE in startup_ARMCMx.S */
  279. /*
  280. .zero.table :
  281. {
  282. . = ALIGN(4);
  283. __zero_table_start__ = .;
  284. LONG (__bss_start__)
  285. LONG (__bss_end__ - __bss_start__)
  286. LONG (__bss2_start__)
  287. LONG (__bss2_end__ - __bss2_start__)
  288. __zero_table_end__ = .;
  289. } > FLASH
  290. */
  291. __etext = .;
  292. __tz_RAM_S = ORIGIN(RAM);
  293. /* If DTC is used, put the DTC vector table at the start of SRAM.
  294. This avoids memory holes due to 1K alignment required by it. */
  295. .fsp_dtc_vector_table (NOLOAD) :
  296. {
  297. . = ORIGIN(RAM);
  298. *(.fsp_dtc_vector_table)
  299. } > RAM
  300. /* Initialized data section. */
  301. .data :
  302. {
  303. __data_start__ = .;
  304. . = ALIGN(4);
  305. __Code_In_RAM_Start = .;
  306. KEEP(*(.code_in_ram*))
  307. __Code_In_RAM_End = .;
  308. *(vtable)
  309. /* Don't use *(.data*) because it will place data meant for .data_flash in this section. */
  310. *(.data.*)
  311. *(.data)
  312. . = ALIGN(4);
  313. /* preinit data */
  314. PROVIDE_HIDDEN (__preinit_array_start = .);
  315. KEEP(*(.preinit_array))
  316. PROVIDE_HIDDEN (__preinit_array_end = .);
  317. . = ALIGN(4);
  318. /* init data */
  319. PROVIDE_HIDDEN (__init_array_start = .);
  320. KEEP(*(SORT(.init_array.*)))
  321. KEEP(*(.init_array))
  322. PROVIDE_HIDDEN (__init_array_end = .);
  323. . = ALIGN(4);
  324. /* finit data */
  325. PROVIDE_HIDDEN (__fini_array_start = .);
  326. KEEP(*(SORT(.fini_array.*)))
  327. KEEP(*(.fini_array))
  328. PROVIDE_HIDDEN (__fini_array_end = .);
  329. KEEP(*(.jcr*))
  330. . = ALIGN(4);
  331. /* All data end */
  332. __data_end__ = .;
  333. } > RAM AT > FLASH
  334. . = .;
  335. __dtcm_data_pre_location = LOADADDR(.data) + SIZEOF(.data);
  336. /* Initialized DTCM data. */
  337. /* Aligned to FCACHE2 for RA8. */
  338. .dtcm_data : ALIGN(16)
  339. {
  340. /* Start of DTCM Secure Trustzone region. */
  341. __tz_DTCM_S = ABSOLUTE(DTCM_START);
  342. /* Initialized DTCM data start */
  343. __dtcm_data_start = .;
  344. KEEP(*(.dtcm_data*))
  345. /* Pad to eight byte alignment in case of ECC initialization. Fill zero. */
  346. . = ALIGN(8);
  347. /* Initialized DTCM data end */
  348. __dtcm_data_end = .;
  349. } > DTCM AT > FLASH = 0x00
  350. . = __dtcm_data_end;
  351. /* Uninitialized DTCM data. */
  352. /* ALIGN appears on the left side of the colon because it is being used to assign the VMA directly, as opposed to a right side appearance which would control the LMA. */
  353. .dtcm_bss ALIGN(8) (NOLOAD) :
  354. {
  355. /* Uninitialized DTCM data start */
  356. __dtcm_bss_start = .;
  357. KEEP(*(.dtcm_bss*))
  358. /* Pad to eight byte alignment in case of ECC initialization. No fill because of NOLOAD. */
  359. . = ALIGN(8);
  360. /* Uninitialized DTCM data end */
  361. __dtcm_bss_end = .;
  362. /*
  363. * Start of the DTCM Non-Secure Trustzone region.
  364. * DTCM_NS_START can be used to set a fixed address for non-secure DTCM in secure projects or flat projects.
  365. */
  366. __tz_DTCM_N = DEFINED(DTCM_NS_START) ? ABSOLUTE(DTCM_NS_START) : ALIGN(__dtcm_bss_end, 8192);
  367. } > DTCM
  368. /* Addresses exported for DTCM initialization. */
  369. __dtcm_data_init_start = LOADADDR(.dtcm_data);
  370. __dtcm_data_init_end = LOADADDR(.dtcm_data) + SIZEOF(.dtcm_data);
  371. ASSERT(ORIGIN(DTCM) % 8 == 0, "DTCM memory region origin must be aligned to 8 bytes.")
  372. ASSERT(LENGTH(DTCM) % 8 == 0, "DTCM memory region length must be a multiple of 8 bytes.")
  373. ASSERT(LOADADDR(.dtcm_bss) == ADDR(.dtcm_bss), ".dtcm_bss has (VMA != LMA) but should be NOLOAD (VMA == LMA).")
  374. ASSERT(LOADADDR(.dtcm_data) % 16 == 0, ".dtcm_data section must be aligned to 16 bytes.")
  375. ASSERT(SIZEOF(.dtcm_data) % 8 == 0, ".dtcm_data section size must be a multiple of 8 bytes.")
  376. ASSERT(LOADADDR(.dtcm_bss) % 8 == 0, ".dtcm_bss section must be aligned to 8 bytes.")
  377. ASSERT(SIZEOF(.dtcm_bss) % 8 == 0, ".dtcm_bss section size must be a multiple of 8 bytes.")
  378. ASSERT(__dtcm_bss_start == __dtcm_data_end, ".dtcm_bss section is not adjacent to .dtcm_data section.")
  379. /* Restore location counter. */
  380. /* If DTCM is not present, this will be the address stored in '.' before ALIGN was attempted. */
  381. /* If DTCM is present, this will be the absolute address that follows the DTCM ROM location. */
  382. . = (SIZEOF(.dtcm_data) > 0) ? __dtcm_data_init_end : __dtcm_data_pre_location;
  383. /* TrustZone Secure Gateway Stubs Section */
  384. /* Store location counter for SPI non-retentive sections. */
  385. sgstubs_pre_location = .;
  386. /* Determine the secure gateway stubs address either by the provided linker variable or the next 1024-byte block. */
  387. SGSTUBS_LOC = (DEFINED(PROJECT_SECURE) && DEFINED(FLASH_NSC_START)) ? ABSOLUTE(FLASH_NSC_START) : ALIGN(1024);
  388. .gnu.sgstubs SGSTUBS_LOC : ALIGN(1024)
  389. {
  390. __tz_FLASH_C = DEFINED(FLASH_NSC_START) ? ABSOLUTE(FLASH_NSC_START) : __RESERVE_NS_RAM ? ABSOLUTE(FLASH_START + FLASH_LENGTH) : ALIGN(1024);
  391. _start_sg = .;
  392. *(.gnu.sgstubs*)
  393. . = ALIGN(32);
  394. _end_sg = .;
  395. } > FLASH
  396. __tz_FLASH_N = DEFINED(FLASH_NS_START) ? ABSOLUTE(FLASH_NS_START) : __RESERVE_NS_RAM ? ABSOLUTE(FLASH_START + FLASH_LENGTH) : FLASH_LENGTH < 32768 ? FLASH_LENGTH : ALIGN(32768);
  397. FLASH_NS_IMAGE_START = DEFINED(FLASH_NS_IMAGE_START) ? FLASH_NS_IMAGE_START : __tz_FLASH_N;
  398. /* Note: There are no secure/non-secure boundaries for QSPI. These symbols are provided for the RA configuration tool. */
  399. __tz_QSPI_FLASH_S = ORIGIN(QSPI_FLASH);
  400. /* QSPI_FLASH section to be downloaded via debugger */
  401. .qspi_flash :
  402. {
  403. __qspi_flash_start__ = .;
  404. KEEP(*(.qspi_flash*))
  405. KEEP(*(.code_in_qspi*))
  406. __qspi_flash_end__ = .;
  407. } > QSPI_FLASH
  408. __qspi_flash_code_size__ = __qspi_flash_end__ - __qspi_flash_start__;
  409. /* QSPI_FLASH non-retentive section, creates a copy in internal flash that can be copied to QSPI */
  410. __qspi_flash_code_addr__ = sgstubs_pre_location;
  411. .qspi_non_retentive : AT(__qspi_flash_code_addr__)
  412. {
  413. __qspi_non_retentive_start__ = .;
  414. KEEP(*(.qspi_non_retentive*))
  415. __qspi_non_retentive_end__ = .;
  416. } > QSPI_FLASH
  417. __qspi_non_retentive_size__ = __qspi_non_retentive_end__ - __qspi_non_retentive_start__;
  418. __qspi_region_max_size__ = 0x4000000; /* Must be the same as defined in MEMORY above */
  419. __qspi_region_start_address__ = __qspi_flash_start__;
  420. __qspi_region_end_address__ = __qspi_flash_start__ + __qspi_region_max_size__;
  421. /* Note: There are no secure/non-secure boundaries for QSPI. These symbols are provided for the RA configuration tool. */
  422. __tz_QSPI_FLASH_N = __qspi_non_retentive_end__;
  423. /* Support for OctaRAM */
  424. .OSPI_DEVICE_0_NO_LOAD (NOLOAD):
  425. {
  426. . = ALIGN(4);
  427. __ospi_device_0_start__ = .;
  428. *(.ospi_device_0_no_load*)
  429. . = ALIGN(4);
  430. __ospi_device_0_end__ = .;
  431. } > OSPI_DEVICE_0_RAM
  432. .OSPI_DEVICE_1_NO_LOAD (NOLOAD):
  433. {
  434. . = ALIGN(4);
  435. __ospi_device_1_start__ = .;
  436. *(.ospi_device_1_no_load*)
  437. . = ALIGN(4);
  438. __ospi_device_1_end__ = .;
  439. } > OSPI_DEVICE_1_RAM
  440. /* Note: There are no secure/non-secure boundaries for QSPI. These symbols are provided for the RA configuration tool. */
  441. __tz_OSPI_DEVICE_0_S = ORIGIN(OSPI_DEVICE_0);
  442. /* OSPI_DEVICE_0 section to be downloaded via debugger */
  443. .OSPI_DEVICE_0 :
  444. {
  445. __ospi_device_0_start__ = .;
  446. KEEP(*(.ospi_device_0*))
  447. KEEP(*(.code_in_ospi_device_0*))
  448. __ospi_device_0_end__ = .;
  449. } > OSPI_DEVICE_0
  450. __ospi_device_0_code_size__ = __ospi_device_0_end__ - __ospi_device_0_start__;
  451. /* OSPI_DEVICE_0 non-retentive section, creates a copy in internal flash that can be copied to OSPI */
  452. __ospi_device_0_code_addr__ = sgstubs_pre_location + (SIZEOF(.qspi_non_retentive));
  453. .ospi_device_0_non_retentive : AT(__ospi_device_0_code_addr__)
  454. {
  455. __ospi_device_0_non_retentive_start__ = .;
  456. KEEP(*(.ospi_device_0_non_retentive*))
  457. __ospi_device_0_non_retentive_end__ = .;
  458. } > OSPI_DEVICE_0
  459. __ospi_device_0_non_retentive_size__ = __ospi_device_0_non_retentive_end__ - __ospi_device_0_non_retentive_start__;
  460. __ospi_device_0_region_max_size__ = 0x8000000; /* Must be the same as defined in MEMORY above */
  461. __ospi_device_0_region_start_address__ = __ospi_device_0_start__;
  462. __ospi_device_0_region_end_address__ = __ospi_device_0_start__ + __ospi_device_0_region_max_size__;
  463. /* Note: There are no secure/non-secure boundaries for OSPI. These symbols are provided for the RA configuration tool. */
  464. __tz_OSPI_DEVICE_0_N = __ospi_device_0_non_retentive_end__;
  465. /* Note: There are no secure/non-secure boundaries for OSPI. These symbols are provided for the RA configuration tool. */
  466. __tz_OSPI_DEVICE_1_S = ORIGIN(OSPI_DEVICE_1);
  467. /* OSPI_DEVICE_1 section to be downloaded via debugger */
  468. .OSPI_DEVICE_1 :
  469. {
  470. __ospi_device_1_start__ = .;
  471. KEEP(*(.ospi_device_1*))
  472. KEEP(*(.code_in_ospi_device_1*))
  473. __ospi_device_1_end__ = .;
  474. } > OSPI_DEVICE_1
  475. __ospi_device_1_code_size__ = __ospi_device_1_end__ - __ospi_device_1_start__;
  476. /* OSPI_DEVICE_1 non-retentive section, creates a copy in internal flash that can be copied to OSPI */
  477. __ospi_device_1_code_addr__ = sgstubs_pre_location + (SIZEOF(.qspi_non_retentive) + SIZEOF(.ospi_device_0_non_retentive));
  478. .ospi_device_1_non_retentive : AT(__ospi_device_1_code_addr__)
  479. {
  480. __ospi_device_1_non_retentive_start__ = .;
  481. KEEP(*(.ospi_device_1_non_retentive*))
  482. __ospi_device_1_non_retentive_end__ = .;
  483. } > OSPI_DEVICE_1
  484. __ospi_device_1_non_retentive_size__ = __ospi_device_1_non_retentive_end__ - __ospi_device_1_non_retentive_start__;
  485. __ospi_device_1_region_max_size__ = 0x10000000; /* Must be the same as defined in MEMORY above */
  486. __ospi_device_1_region_start_address__ = __ospi_device_1_start__;
  487. __ospi_device_1_region_end_address__ = __ospi_device_1_start__ + __ospi_device_1_region_max_size__;
  488. /* Note: There are no secure/non-secure boundaries for OSPI. These symbols are provided for the RA configuration tool. */
  489. __tz_OSPI_DEVICE_1_N = __ospi_device_1_non_retentive_end__;
  490. .noinit (NOLOAD):
  491. {
  492. . = ALIGN(4);
  493. __noinit_start = .;
  494. KEEP(*(.noinit*))
  495. . = ALIGN(8);
  496. /* Place the FreeRTOS heap here so that the __HeapLimit calculation does not include the freertos heap. */
  497. KEEP(*(.heap.*))
  498. __noinit_end = .;
  499. } > RAM
  500. . = .;
  501. __nocache_pre_location = .;
  502. .nocache ALIGN(32) (NOLOAD):
  503. {
  504. __nocache_start = .;
  505. KEEP(*(.nocache))
  506. . = ALIGN(32);
  507. __nocache_end = .;
  508. } > RAM
  509. . = (SIZEOF(.nocache) > 0) ? __nocache_end : __nocache_pre_location;
  510. .bss :
  511. {
  512. . = ALIGN(4);
  513. __bss_start__ = .;
  514. *(.bss*)
  515. *(COMMON)
  516. . = ALIGN(4);
  517. __bss_end__ = .;
  518. } > RAM
  519. .heap (NOLOAD):
  520. {
  521. . = ALIGN(8);
  522. __HeapBase = .;
  523. /* Place the STD heap here. */
  524. KEEP(*(.heap))
  525. __HeapLimit = .;
  526. } > RAM
  527. /* Stacks are stored in this section. */
  528. .stack_dummy (NOLOAD):
  529. {
  530. . = ALIGN(8);
  531. __StackLimit = .;
  532. /* Main stack */
  533. KEEP(*(.stack))
  534. __StackTop = .;
  535. /* Thread stacks */
  536. KEEP(*(.stack*))
  537. __StackTopAll = .;
  538. } > RAM
  539. PROVIDE(__stack = __StackTopAll);
  540. /* This symbol represents the end of user allocated RAM. The RAM after this symbol can be used
  541. at run time for things such as ThreadX memory pool allocations. */
  542. __RAM_segment_used_end__ = ALIGN(__StackTopAll , 4);
  543. /* RAM_NSC_START can be used to set a fixed address for non-secure callable RAM in secure projects.
  544. * If it is not specified, the address for NSC RAM is the end of RAM aligned to a 1K boundary.
  545. * In flat projects that require non-secure RAM, this variable is set to the start of non-secure RAM. */
  546. __tz_RAM_C = DEFINED(RAM_NSC_START) ? ABSOLUTE(RAM_NSC_START - RAM_NS_BUFFER_BLOCK_LENGTH) : __RESERVE_NS_RAM ? ABSOLUTE(RAM_NS_BUFFER_BLOCK_START) : ALIGN(__RAM_segment_used_end__, 1024);
  547. /* RAM_NS_START can be used to set a fixed address for non-secure RAM in secure projects or flat projects.
  548. * RAM_NS_BUFFER_BLOCK_LENGTH is used to allocate non-secure buffers in a flat project. If it is not
  549. * specified, the address for NSC RAM is the end of RAM aligned to an 8K boundary.
  550. * In flat projects that require non-secure RAM, this variable is set to the start of non-secure RAM. */
  551. __tz_RAM_N = DEFINED(RAM_NS_START) ? ABSOLUTE(RAM_NS_START - RAM_NS_BUFFER_BLOCK_LENGTH) : __RESERVE_NS_RAM ? ABSOLUTE(RAM_NS_BUFFER_BLOCK_START) : ALIGN(__tz_RAM_C, 8192);
  552. /* Non-secure buffers must be in non-secure RAM. This is primarily used for the EDMAC in flat projects.
  553. * The EDMAC is a non-secure bus master and can only access non-secure RAM. */
  554. .ns_buffer (NOLOAD):
  555. {
  556. /* Allocate RAM on a 32-byte boundary to help with placement of Ethernet buffers. */
  557. . = __RESERVE_NS_RAM ? ABSOLUTE(RAM_NS_BUFFER_START & 0xFFFFFFE0) : .;
  558. KEEP(*(.ns_buffer*))
  559. } > RAM
  560. /* Data flash. */
  561. .data_flash :
  562. {
  563. . = ORIGIN(DATA_FLASH);
  564. __tz_DATA_FLASH_S = .;
  565. __Data_Flash_Start = .;
  566. KEEP(*(.data_flash*))
  567. __Data_Flash_End = .;
  568. __tz_DATA_FLASH_N = DEFINED(DATA_FLASH_NS_START) ? ABSOLUTE(DATA_FLASH_NS_START) : __RESERVE_NS_RAM ? ABSOLUTE(DATA_FLASH_START + DATA_FLASH_LENGTH) : ALIGN(1024);
  569. } > DATA_FLASH
  570. /* Note: There are no secure/non-secure boundaries for SDRAM. These symbols are provided for the RA configuration tool. */
  571. __tz_SDRAM_S = ORIGIN(SDRAM);
  572. /* SDRAM */
  573. .sdram (NOLOAD):
  574. {
  575. __SDRAM_Start = .;
  576. KEEP(*(.sdram*))
  577. KEEP(*(.frame*))
  578. __SDRAM_End = .;
  579. } > SDRAM
  580. . = .;
  581. __nocache_sdram_pre_location = .;
  582. .nocache_sdram ALIGN(32) (NOLOAD):
  583. {
  584. __nocache_sdram_start = .;
  585. KEEP(*(.nocache_sdram))
  586. . = ALIGN(32);
  587. __nocache_sdram_end = .;
  588. } > SDRAM
  589. . = (SIZEOF(.nocache_sdram) > 0) ? __nocache_sdram_end : __nocache_sdram_pre_location;
  590. /* Note: There are no secure/non-secure boundaries for SDRAM. These symbols are provided for the RA configuration tool. */
  591. __tz_SDRAM_N = __SDRAM_End;
  592. /* Note: There are no secure/non-secure boundaries for ID_CODE. These symbols are provided for the RA configuration tool. */
  593. __tz_ID_CODE_S = ORIGIN(ID_CODE);
  594. /* Note: There are no secure/non-secure boundaries for ID_CODE. These symbols are provided for the RA configuration tool.
  595. * Set this symbol to the same value as __tz_ID_CODE_S so the RA configuration tool does not split the ID_CODE
  596. * memory region between TrustZone projects. */
  597. __tz_ID_CODE_N = __tz_ID_CODE_S;
  598. .id_code :
  599. {
  600. __ID_Code_Start = .;
  601. KEEP(*(.id_code*))
  602. __ID_Code_End = .;
  603. } > ID_CODE
  604. /* Symbol required for RA Configuration tool. */
  605. __tz_OPTION_SETTING_S = ORIGIN(OPTION_SETTING_OFS);
  606. .option_setting_ofs :
  607. {
  608. __OPTION_SETTING_OFS_Start = .;
  609. KEEP(*(.option_setting_ofs0))
  610. . = PROJECT_SECURE_OR_FLAT ? __OPTION_SETTING_OFS_Start + 0x04 : __OPTION_SETTING_OFS_Start;
  611. KEEP(*(.option_setting_ofs2))
  612. . = PROJECT_SECURE_OR_FLAT ? __OPTION_SETTING_OFS_Start + 0x10 : __OPTION_SETTING_OFS_Start;
  613. KEEP(*(.option_setting_dualsel))
  614. __OPTION_SETTING_OFS_End = .;
  615. } > OPTION_SETTING_OFS = 0xFF
  616. .option_setting_sas :
  617. {
  618. __OPTION_SETTING_SAS_Start = .;
  619. KEEP(*(.option_setting_sas))
  620. __OPTION_SETTING_SAS_End = .;
  621. } > OPTION_SETTING_SAS = 0xFF
  622. /* Symbol required for RA Configuration tool. */
  623. __tz_OPTION_SETTING_N = ABSOLUTE(OPTION_SETTING_START_NS);
  624. .option_setting_ns :
  625. {
  626. __OPTION_SETTING_NS_Start = .;
  627. KEEP(*(.option_setting_ofs1))
  628. . = USE_OPTION_SETTING_NS ? __OPTION_SETTING_NS_Start + 0x04 : __OPTION_SETTING_NS_Start;
  629. KEEP(*(.option_setting_ofs3))
  630. . = USE_OPTION_SETTING_NS ? __OPTION_SETTING_NS_Start + 0x10 : __OPTION_SETTING_NS_Start;
  631. KEEP(*(.option_setting_banksel))
  632. . = USE_OPTION_SETTING_NS ? __OPTION_SETTING_NS_Start + 0x40 : __OPTION_SETTING_NS_Start;
  633. KEEP(*(.option_setting_bps0))
  634. . = USE_OPTION_SETTING_NS ? __OPTION_SETTING_NS_Start + 0x44 : __OPTION_SETTING_NS_Start;
  635. KEEP(*(.option_setting_bps1))
  636. . = USE_OPTION_SETTING_NS ? __OPTION_SETTING_NS_Start + 0x48 : __OPTION_SETTING_NS_Start;
  637. KEEP(*(.option_setting_bps2))
  638. . = USE_OPTION_SETTING_NS ? __OPTION_SETTING_NS_Start + 0x4C : __OPTION_SETTING_NS_Start;
  639. KEEP(*(.option_setting_bps3))
  640. . = USE_OPTION_SETTING_NS ? __OPTION_SETTING_NS_Start + 0x60 : __OPTION_SETTING_NS_Start;
  641. KEEP(*(.option_setting_pbps0))
  642. . = USE_OPTION_SETTING_NS ? __OPTION_SETTING_NS_Start + 0x64 : __OPTION_SETTING_NS_Start;
  643. KEEP(*(.option_setting_pbps1))
  644. . = USE_OPTION_SETTING_NS ? __OPTION_SETTING_NS_Start + 0x68 : __OPTION_SETTING_NS_Start;
  645. KEEP(*(.option_setting_pbps2))
  646. . = USE_OPTION_SETTING_NS ? __OPTION_SETTING_NS_Start + 0x6C : __OPTION_SETTING_NS_Start;
  647. KEEP(*(.option_setting_pbps3))
  648. __OPTION_SETTING_NS_End = .;
  649. } > OPTION_SETTING = 0xFF
  650. /* Symbol required for RA Configuration tool. */
  651. __tz_OPTION_SETTING_S_S = ORIGIN(OPTION_SETTING_S);
  652. .option_setting_s :
  653. {
  654. __OPTION_SETTING_S_Start = .;
  655. KEEP(*(.option_setting_ofs1_sec))
  656. . = PROJECT_SECURE_OR_FLAT ? __OPTION_SETTING_S_Start + 0x04 : __OPTION_SETTING_S_Start;
  657. KEEP(*(.option_setting_ofs3_sec))
  658. . = PROJECT_SECURE_OR_FLAT ? __OPTION_SETTING_S_Start + 0x10 : __OPTION_SETTING_S_Start;
  659. KEEP(*(.option_setting_banksel_sec))
  660. . = PROJECT_SECURE_OR_FLAT ? __OPTION_SETTING_S_Start + 0x40 : __OPTION_SETTING_S_Start;
  661. KEEP(*(.option_setting_bps_sec0))
  662. . = PROJECT_SECURE_OR_FLAT ? __OPTION_SETTING_S_Start + 0x44 : __OPTION_SETTING_S_Start;
  663. KEEP(*(.option_setting_bps_sec1))
  664. . = PROJECT_SECURE_OR_FLAT ? __OPTION_SETTING_S_Start + 0x48 : __OPTION_SETTING_S_Start;
  665. KEEP(*(.option_setting_bps_sec2))
  666. . = PROJECT_SECURE_OR_FLAT ? __OPTION_SETTING_S_Start + 0x4C : __OPTION_SETTING_S_Start;
  667. KEEP(*(.option_setting_bps_sec3))
  668. . = PROJECT_SECURE_OR_FLAT ? __OPTION_SETTING_S_Start + 0x60 : __OPTION_SETTING_S_Start;
  669. KEEP(*(.option_setting_pbps_sec0))
  670. . = PROJECT_SECURE_OR_FLAT ? __OPTION_SETTING_S_Start + 0x64 : __OPTION_SETTING_S_Start;
  671. KEEP(*(.option_setting_pbps_sec1))
  672. . = PROJECT_SECURE_OR_FLAT ? __OPTION_SETTING_S_Start + 0x68 : __OPTION_SETTING_S_Start;
  673. KEEP(*(.option_setting_pbps_sec2))
  674. . = PROJECT_SECURE_OR_FLAT ? __OPTION_SETTING_S_Start + 0x6C : __OPTION_SETTING_S_Start;
  675. KEEP(*(.option_setting_pbps_sec3))
  676. . = PROJECT_SECURE_OR_FLAT ? __OPTION_SETTING_S_Start + 0x80 : __OPTION_SETTING_S_Start;
  677. KEEP(*(.option_setting_ofs1_sel))
  678. . = PROJECT_SECURE_OR_FLAT ? __OPTION_SETTING_S_Start + 0x84 : __OPTION_SETTING_S_Start;
  679. KEEP(*(.option_setting_ofs3_sel))
  680. . = PROJECT_SECURE_OR_FLAT ? __OPTION_SETTING_S_Start + 0x90 : __OPTION_SETTING_S_Start;
  681. KEEP(*(.option_setting_banksel_sel))
  682. . = PROJECT_SECURE_OR_FLAT ? __OPTION_SETTING_S_Start + 0xC0 : __OPTION_SETTING_S_Start;
  683. KEEP(*(.option_setting_bps_sel0))
  684. . = PROJECT_SECURE_OR_FLAT ? __OPTION_SETTING_S_Start + 0xC4 : __OPTION_SETTING_S_Start;
  685. KEEP(*(.option_setting_bps_sel1))
  686. . = PROJECT_SECURE_OR_FLAT ? __OPTION_SETTING_S_Start + 0xC8 : __OPTION_SETTING_S_Start;
  687. KEEP(*(.option_setting_bps_sel2))
  688. . = PROJECT_SECURE_OR_FLAT ? __OPTION_SETTING_S_Start + 0xCC : __OPTION_SETTING_S_Start;
  689. KEEP(*(.option_setting_bps_sel3))
  690. __OPTION_SETTING_S_End = .;
  691. } > OPTION_SETTING_S = 0xFF
  692. /* Symbol required for RA Configuration tool. */
  693. __tz_OPTION_SETTING_S_N = __OPTION_SETTING_S_End;
  694. }