fsp.ld 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768
  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(libgcc.a 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. /* .ctors */
  165. *crtbegin.o(.ctors)
  166. *crtbegin?.o(.ctors)
  167. *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
  168. *(SORT(.ctors.*))
  169. *(.ctors)
  170. /* .dtors */
  171. *crtbegin.o(.dtors)
  172. *crtbegin?.o(.dtors)
  173. *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
  174. *(SORT(.dtors.*))
  175. *(.dtors)
  176. *(.rodata*)
  177. __usb_dev_descriptor_start_fs = .;
  178. KEEP(*(.usb_device_desc_fs*))
  179. __usb_cfg_descriptor_start_fs = .;
  180. KEEP(*(.usb_config_desc_fs*))
  181. __usb_interface_descriptor_start_fs = .;
  182. KEEP(*(.usb_interface_desc_fs*))
  183. __usb_descriptor_end_fs = .;
  184. __usb_dev_descriptor_start_hs = .;
  185. KEEP(*(.usb_device_desc_hs*))
  186. __usb_cfg_descriptor_start_hs = .;
  187. KEEP(*(.usb_config_desc_hs*))
  188. __usb_interface_descriptor_start_hs = .;
  189. KEEP(*(.usb_interface_desc_hs*))
  190. __usb_descriptor_end_hs = .;
  191. KEEP(*(.eh_frame*))
  192. __ROM_End = .;
  193. } > FLASH = 0xFF
  194. __Vectors_Size = __Vectors_End - __Vectors;
  195. . = .;
  196. __itcm_data_pre_location = .;
  197. /* Initialized ITCM data. */
  198. /* Aligned to FCACHE2 for RA8. */
  199. .itcm_data : ALIGN(16)
  200. {
  201. /* Start of ITCM Secure Trustzone region. */
  202. __tz_ITCM_S = ABSOLUTE(ITCM_START);
  203. /* All ITCM data start */
  204. __itcm_data_start = .;
  205. KEEP(*(.itcm_data*))
  206. /* Pad to eight byte alignment in case of ECC initialization. Fill zero. */
  207. . = ALIGN(8);
  208. /* All ITCM data end */
  209. __itcm_data_end = .;
  210. /*
  211. * Start of the ITCM Non-Secure Trustzone region.
  212. * ITCM_NS_START can be used to set a fixed address for non-secure ITCM in secure projects or flat projects.
  213. */
  214. __tz_ITCM_N = DEFINED(ITCM_NS_START) ? ABSOLUTE(ITCM_NS_START) : ALIGN(__itcm_data_end, 8192);
  215. } > ITCM AT > FLASH = 0x00
  216. /* Addresses exported for ITCM initialization. */
  217. __itcm_data_init_start = LOADADDR(.itcm_data);
  218. __itcm_data_init_end = LOADADDR(.itcm_data) + SIZEOF(.itcm_data);
  219. ASSERT(ORIGIN(ITCM) % 8 == 0, "ITCM memory region origin must be aligned to 8 bytes.")
  220. ASSERT(LENGTH(ITCM) % 8 == 0, "ITCM memory region length must be a multiple of 8 bytes.")
  221. ASSERT(LOADADDR(.itcm_data) % 16 == 0, ".itcm_data section must be aligned to 16 bytes.")
  222. ASSERT(SIZEOF(.itcm_data) % 8 == 0, ".itcm_data section size must be a multiple of 8 bytes.")
  223. /* Restore location counter. */
  224. /* If ITCM is not present, this will be the address stored in '.' before ALIGN was attempted. */
  225. /* If ITCM is present, this will be the absolute address that follows the ITCM ROM location. */
  226. . = (SIZEOF(.itcm_data) > 0) ? __itcm_data_init_end : __itcm_data_pre_location;
  227. .ARM.extab :
  228. {
  229. *(.ARM.extab* .gnu.linkonce.armextab.*)
  230. } > FLASH
  231. __exidx_start = .;
  232. .ARM.exidx :
  233. {
  234. *(.ARM.exidx* .gnu.linkonce.armexidx.*)
  235. } > FLASH
  236. __exidx_end = .;
  237. /* To copy multiple ROM to RAM sections,
  238. * uncomment .copy.table section and,
  239. * define __STARTUP_COPY_MULTIPLE in startup_ARMCMx.S */
  240. /*
  241. .copy.table :
  242. {
  243. . = ALIGN(4);
  244. __copy_table_start__ = .;
  245. LONG (__etext)
  246. LONG (__data_start__)
  247. LONG (__data_end__ - __data_start__)
  248. LONG (__etext2)
  249. LONG (__data2_start__)
  250. LONG (__data2_end__ - __data2_start__)
  251. __copy_table_end__ = .;
  252. } > FLASH
  253. */
  254. /* To clear multiple BSS sections,
  255. * uncomment .zero.table section and,
  256. * define __STARTUP_CLEAR_BSS_MULTIPLE in startup_ARMCMx.S */
  257. /*
  258. .zero.table :
  259. {
  260. . = ALIGN(4);
  261. __zero_table_start__ = .;
  262. LONG (__bss_start__)
  263. LONG (__bss_end__ - __bss_start__)
  264. LONG (__bss2_start__)
  265. LONG (__bss2_end__ - __bss2_start__)
  266. __zero_table_end__ = .;
  267. } > FLASH
  268. */
  269. __etext = .;
  270. __tz_RAM_S = ORIGIN(RAM);
  271. /* If DTC is used, put the DTC vector table at the start of SRAM.
  272. This avoids memory holes due to 1K alignment required by it. */
  273. .fsp_dtc_vector_table (NOLOAD) :
  274. {
  275. . = ORIGIN(RAM);
  276. *(.fsp_dtc_vector_table)
  277. } > RAM
  278. /* Initialized data section. */
  279. .data :
  280. {
  281. __data_start__ = .;
  282. . = ALIGN(4);
  283. __Code_In_RAM_Start = .;
  284. KEEP(*(.code_in_ram*))
  285. __Code_In_RAM_End = .;
  286. *(vtable)
  287. /* Don't use *(.data*) because it will place data meant for .data_flash in this section. */
  288. *(.data.*)
  289. *(.data)
  290. . = ALIGN(4);
  291. /* preinit data */
  292. PROVIDE_HIDDEN (__preinit_array_start = .);
  293. KEEP(*(.preinit_array))
  294. PROVIDE_HIDDEN (__preinit_array_end = .);
  295. . = ALIGN(4);
  296. /* init data */
  297. PROVIDE_HIDDEN (__init_array_start = .);
  298. KEEP(*(SORT(.init_array.*)))
  299. KEEP(*(.init_array))
  300. PROVIDE_HIDDEN (__init_array_end = .);
  301. . = ALIGN(4);
  302. /* finit data */
  303. PROVIDE_HIDDEN (__fini_array_start = .);
  304. KEEP(*(SORT(.fini_array.*)))
  305. KEEP(*(.fini_array))
  306. PROVIDE_HIDDEN (__fini_array_end = .);
  307. KEEP(*(.jcr*))
  308. . = ALIGN(4);
  309. /* All data end */
  310. __data_end__ = .;
  311. } > RAM AT > FLASH
  312. . = .;
  313. __dtcm_data_pre_location = LOADADDR(.data) + SIZEOF(.data);
  314. /* Initialized DTCM data. */
  315. /* Aligned to FCACHE2 for RA8. */
  316. .dtcm_data : ALIGN(16)
  317. {
  318. /* Start of DTCM Secure Trustzone region. */
  319. __tz_DTCM_S = ABSOLUTE(DTCM_START);
  320. /* Initialized DTCM data start */
  321. __dtcm_data_start = .;
  322. KEEP(*(.dtcm_data*))
  323. /* Pad to eight byte alignment in case of ECC initialization. Fill zero. */
  324. . = ALIGN(8);
  325. /* Initialized DTCM data end */
  326. __dtcm_data_end = .;
  327. } > DTCM AT > FLASH = 0x00
  328. . = __dtcm_data_end;
  329. /* Uninitialized DTCM data. */
  330. /* 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. */
  331. .dtcm_bss ALIGN(8) (NOLOAD) :
  332. {
  333. /* Uninitialized DTCM data start */
  334. __dtcm_bss_start = .;
  335. KEEP(*(.dtcm_bss*))
  336. /* Pad to eight byte alignment in case of ECC initialization. No fill because of NOLOAD. */
  337. . = ALIGN(8);
  338. /* Uninitialized DTCM data end */
  339. __dtcm_bss_end = .;
  340. /*
  341. * Start of the DTCM Non-Secure Trustzone region.
  342. * DTCM_NS_START can be used to set a fixed address for non-secure DTCM in secure projects or flat projects.
  343. */
  344. __tz_DTCM_N = DEFINED(DTCM_NS_START) ? ABSOLUTE(DTCM_NS_START) : ALIGN(__dtcm_bss_end, 8192);
  345. } > DTCM
  346. /* Addresses exported for DTCM initialization. */
  347. __dtcm_data_init_start = LOADADDR(.dtcm_data);
  348. __dtcm_data_init_end = LOADADDR(.dtcm_data) + SIZEOF(.dtcm_data);
  349. ASSERT(ORIGIN(DTCM) % 8 == 0, "DTCM memory region origin must be aligned to 8 bytes.")
  350. ASSERT(LENGTH(DTCM) % 8 == 0, "DTCM memory region length must be a multiple of 8 bytes.")
  351. ASSERT(LOADADDR(.dtcm_bss) == ADDR(.dtcm_bss), ".dtcm_bss has (VMA != LMA) but should be NOLOAD (VMA == LMA).")
  352. ASSERT(LOADADDR(.dtcm_data) % 16 == 0, ".dtcm_data section must be aligned to 16 bytes.")
  353. ASSERT(SIZEOF(.dtcm_data) % 8 == 0, ".dtcm_data section size must be a multiple of 8 bytes.")
  354. ASSERT(LOADADDR(.dtcm_bss) % 8 == 0, ".dtcm_bss section must be aligned to 8 bytes.")
  355. ASSERT(SIZEOF(.dtcm_bss) % 8 == 0, ".dtcm_bss section size must be a multiple of 8 bytes.")
  356. ASSERT(__dtcm_bss_start == __dtcm_data_end, ".dtcm_bss section is not adjacent to .dtcm_data section.")
  357. /* Restore location counter. */
  358. /* If DTCM is not present, this will be the address stored in '.' before ALIGN was attempted. */
  359. /* If DTCM is present, this will be the absolute address that follows the DTCM ROM location. */
  360. . = (SIZEOF(.dtcm_data) > 0) ? __dtcm_data_init_end : __dtcm_data_pre_location;
  361. /* TrustZone Secure Gateway Stubs Section */
  362. /* Store location counter for SPI non-retentive sections. */
  363. sgstubs_pre_location = .;
  364. /* Determine the secure gateway stubs address either by the provided linker variable or the next 1024-byte block. */
  365. SGSTUBS_LOC = (DEFINED(PROJECT_SECURE) && DEFINED(FLASH_NSC_START)) ? ABSOLUTE(FLASH_NSC_START) : ALIGN(1024);
  366. .gnu.sgstubs SGSTUBS_LOC : ALIGN(1024)
  367. {
  368. __tz_FLASH_C = DEFINED(FLASH_NSC_START) ? ABSOLUTE(FLASH_NSC_START) : __RESERVE_NS_RAM ? ABSOLUTE(FLASH_START + FLASH_LENGTH) : ALIGN(1024);
  369. _start_sg = .;
  370. *(.gnu.sgstubs*)
  371. . = ALIGN(32);
  372. _end_sg = .;
  373. } > FLASH
  374. __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);
  375. FLASH_NS_IMAGE_START = DEFINED(FLASH_NS_IMAGE_START) ? FLASH_NS_IMAGE_START : __tz_FLASH_N;
  376. /* Note: There are no secure/non-secure boundaries for QSPI. These symbols are provided for the RA configuration tool. */
  377. __tz_QSPI_FLASH_S = ORIGIN(QSPI_FLASH);
  378. /* QSPI_FLASH section to be downloaded via debugger */
  379. .qspi_flash :
  380. {
  381. __qspi_flash_start__ = .;
  382. KEEP(*(.qspi_flash*))
  383. KEEP(*(.code_in_qspi*))
  384. __qspi_flash_end__ = .;
  385. } > QSPI_FLASH
  386. __qspi_flash_code_size__ = __qspi_flash_end__ - __qspi_flash_start__;
  387. /* QSPI_FLASH non-retentive section, creates a copy in internal flash that can be copied to QSPI */
  388. __qspi_flash_code_addr__ = sgstubs_pre_location;
  389. .qspi_non_retentive : AT(__qspi_flash_code_addr__)
  390. {
  391. __qspi_non_retentive_start__ = .;
  392. KEEP(*(.qspi_non_retentive*))
  393. __qspi_non_retentive_end__ = .;
  394. } > QSPI_FLASH
  395. __qspi_non_retentive_size__ = __qspi_non_retentive_end__ - __qspi_non_retentive_start__;
  396. __qspi_region_max_size__ = 0x4000000; /* Must be the same as defined in MEMORY above */
  397. __qspi_region_start_address__ = __qspi_flash_start__;
  398. __qspi_region_end_address__ = __qspi_flash_start__ + __qspi_region_max_size__;
  399. /* Note: There are no secure/non-secure boundaries for QSPI. These symbols are provided for the RA configuration tool. */
  400. __tz_QSPI_FLASH_N = __qspi_non_retentive_end__;
  401. /* Support for OctaRAM */
  402. .OSPI_DEVICE_0_NO_LOAD (NOLOAD):
  403. {
  404. . = ALIGN(4);
  405. __ospi_device_0_start__ = .;
  406. *(.ospi_device_0_no_load*)
  407. . = ALIGN(4);
  408. __ospi_device_0_end__ = .;
  409. } > OSPI_DEVICE_0_RAM
  410. .OSPI_DEVICE_1_NO_LOAD (NOLOAD):
  411. {
  412. . = ALIGN(4);
  413. __ospi_device_1_start__ = .;
  414. *(.ospi_device_1_no_load*)
  415. . = ALIGN(4);
  416. __ospi_device_1_end__ = .;
  417. } > OSPI_DEVICE_1_RAM
  418. /* Note: There are no secure/non-secure boundaries for QSPI. These symbols are provided for the RA configuration tool. */
  419. __tz_OSPI_DEVICE_0_S = ORIGIN(OSPI_DEVICE_0);
  420. /* OSPI_DEVICE_0 section to be downloaded via debugger */
  421. .OSPI_DEVICE_0 :
  422. {
  423. __ospi_device_0_start__ = .;
  424. KEEP(*(.ospi_device_0*))
  425. KEEP(*(.code_in_ospi_device_0*))
  426. __ospi_device_0_end__ = .;
  427. } > OSPI_DEVICE_0
  428. __ospi_device_0_code_size__ = __ospi_device_0_end__ - __ospi_device_0_start__;
  429. /* OSPI_DEVICE_0 non-retentive section, creates a copy in internal flash that can be copied to OSPI */
  430. __ospi_device_0_code_addr__ = sgstubs_pre_location + (SIZEOF(.qspi_non_retentive));
  431. .ospi_device_0_non_retentive : AT(__ospi_device_0_code_addr__)
  432. {
  433. __ospi_device_0_non_retentive_start__ = .;
  434. KEEP(*(.ospi_device_0_non_retentive*))
  435. __ospi_device_0_non_retentive_end__ = .;
  436. } > OSPI_DEVICE_0
  437. __ospi_device_0_non_retentive_size__ = __ospi_device_0_non_retentive_end__ - __ospi_device_0_non_retentive_start__;
  438. __ospi_device_0_region_max_size__ = 0x8000000; /* Must be the same as defined in MEMORY above */
  439. __ospi_device_0_region_start_address__ = __ospi_device_0_start__;
  440. __ospi_device_0_region_end_address__ = __ospi_device_0_start__ + __ospi_device_0_region_max_size__;
  441. /* Note: There are no secure/non-secure boundaries for OSPI. These symbols are provided for the RA configuration tool. */
  442. __tz_OSPI_DEVICE_0_N = __ospi_device_0_non_retentive_end__;
  443. /* Note: There are no secure/non-secure boundaries for OSPI. These symbols are provided for the RA configuration tool. */
  444. __tz_OSPI_DEVICE_1_S = ORIGIN(OSPI_DEVICE_1);
  445. /* OSPI_DEVICE_1 section to be downloaded via debugger */
  446. .OSPI_DEVICE_1 :
  447. {
  448. __ospi_device_1_start__ = .;
  449. KEEP(*(.ospi_device_1*))
  450. KEEP(*(.code_in_ospi_device_1*))
  451. __ospi_device_1_end__ = .;
  452. } > OSPI_DEVICE_1
  453. __ospi_device_1_code_size__ = __ospi_device_1_end__ - __ospi_device_1_start__;
  454. /* OSPI_DEVICE_1 non-retentive section, creates a copy in internal flash that can be copied to OSPI */
  455. __ospi_device_1_code_addr__ = sgstubs_pre_location + (SIZEOF(.qspi_non_retentive) + SIZEOF(.ospi_device_0_non_retentive));
  456. .ospi_device_1_non_retentive : AT(__ospi_device_1_code_addr__)
  457. {
  458. __ospi_device_1_non_retentive_start__ = .;
  459. KEEP(*(.ospi_device_1_non_retentive*))
  460. __ospi_device_1_non_retentive_end__ = .;
  461. } > OSPI_DEVICE_1
  462. __ospi_device_1_non_retentive_size__ = __ospi_device_1_non_retentive_end__ - __ospi_device_1_non_retentive_start__;
  463. __ospi_device_1_region_max_size__ = 0x10000000; /* Must be the same as defined in MEMORY above */
  464. __ospi_device_1_region_start_address__ = __ospi_device_1_start__;
  465. __ospi_device_1_region_end_address__ = __ospi_device_1_start__ + __ospi_device_1_region_max_size__;
  466. /* Note: There are no secure/non-secure boundaries for OSPI. These symbols are provided for the RA configuration tool. */
  467. __tz_OSPI_DEVICE_1_N = __ospi_device_1_non_retentive_end__;
  468. .noinit (NOLOAD):
  469. {
  470. . = ALIGN(4);
  471. __noinit_start = .;
  472. KEEP(*(.noinit*))
  473. . = ALIGN(8);
  474. /* Place the FreeRTOS heap here so that the __HeapLimit calculation does not include the freertos heap. */
  475. KEEP(*(.heap.*))
  476. __noinit_end = .;
  477. } > RAM
  478. .bss :
  479. {
  480. . = ALIGN(4);
  481. __bss_start__ = .;
  482. *(.bss*)
  483. *(COMMON)
  484. . = ALIGN(4);
  485. __bss_end__ = .;
  486. } > RAM
  487. .heap (NOLOAD):
  488. {
  489. . = ALIGN(8);
  490. __HeapBase = .;
  491. /* Place the STD heap here. */
  492. KEEP(*(.heap))
  493. __HeapLimit = .;
  494. } > RAM
  495. /* Stacks are stored in this section. */
  496. .stack_dummy (NOLOAD):
  497. {
  498. . = ALIGN(8);
  499. __StackLimit = .;
  500. /* Main stack */
  501. KEEP(*(.stack))
  502. __StackTop = .;
  503. /* Thread stacks */
  504. KEEP(*(.stack*))
  505. __StackTopAll = .;
  506. } > RAM
  507. PROVIDE(__stack = __StackTopAll);
  508. /* This symbol represents the end of user allocated RAM. The RAM after this symbol can be used
  509. at run time for things such as ThreadX memory pool allocations. */
  510. __RAM_segment_used_end__ = ALIGN(__StackTopAll , 4);
  511. /* RAM_NSC_START can be used to set a fixed address for non-secure callable RAM in secure projects.
  512. * If it is not specified, the address for NSC RAM is the end of RAM aligned to a 1K boundary.
  513. * In flat projects that require non-secure RAM, this variable is set to the start of non-secure RAM. */
  514. __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);
  515. /* RAM_NS_START can be used to set a fixed address for non-secure RAM in secure projects or flat projects.
  516. * RAM_NS_BUFFER_BLOCK_LENGTH is used to allocate non-secure buffers in a flat project. If it is not
  517. * specified, the address for NSC RAM is the end of RAM aligned to an 8K boundary.
  518. * In flat projects that require non-secure RAM, this variable is set to the start of non-secure RAM. */
  519. __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);
  520. /* Non-secure buffers must be in non-secure RAM. This is primarily used for the EDMAC in flat projects.
  521. * The EDMAC is a non-secure bus master and can only access non-secure RAM. */
  522. .ns_buffer (NOLOAD):
  523. {
  524. /* Allocate RAM on a 32-byte boundary to help with placement of Ethernet buffers. */
  525. . = __RESERVE_NS_RAM ? ABSOLUTE(RAM_NS_BUFFER_START & 0xFFFFFFE0) : .;
  526. KEEP(*(.ns_buffer*))
  527. } > RAM
  528. /* Data flash. */
  529. .data_flash :
  530. {
  531. . = ORIGIN(DATA_FLASH);
  532. __tz_DATA_FLASH_S = .;
  533. __Data_Flash_Start = .;
  534. KEEP(*(.data_flash*))
  535. __Data_Flash_End = .;
  536. __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);
  537. } > DATA_FLASH
  538. /* Note: There are no secure/non-secure boundaries for SDRAM. These symbols are provided for the RA configuration tool. */
  539. __tz_SDRAM_S = ORIGIN(SDRAM);
  540. /* SDRAM */
  541. .sdram (NOLOAD):
  542. {
  543. __SDRAM_Start = .;
  544. KEEP(*(.sdram*))
  545. KEEP(*(.frame*))
  546. __SDRAM_End = .;
  547. } > SDRAM
  548. /* Note: There are no secure/non-secure boundaries for SDRAM. These symbols are provided for the RA configuration tool. */
  549. __tz_SDRAM_N = __SDRAM_End;
  550. /* Note: There are no secure/non-secure boundaries for ID_CODE. These symbols are provided for the RA configuration tool. */
  551. __tz_ID_CODE_S = ORIGIN(ID_CODE);
  552. /* Note: There are no secure/non-secure boundaries for ID_CODE. These symbols are provided for the RA configuration tool.
  553. * Set this symbol to the same value as __tz_ID_CODE_S so the RA configuration tool does not split the ID_CODE
  554. * memory region between TrustZone projects. */
  555. __tz_ID_CODE_N = __tz_ID_CODE_S;
  556. .id_code :
  557. {
  558. __ID_Code_Start = .;
  559. KEEP(*(.id_code*))
  560. __ID_Code_End = .;
  561. } > ID_CODE
  562. /* Symbol required for RA Configuration tool. */
  563. __tz_OPTION_SETTING_S = ORIGIN(OPTION_SETTING_OFS);
  564. .option_setting_ofs :
  565. {
  566. __OPTION_SETTING_OFS_Start = .;
  567. KEEP(*(.option_setting_ofs0))
  568. . = PROJECT_SECURE_OR_FLAT ? __OPTION_SETTING_OFS_Start + 0x04 : __OPTION_SETTING_OFS_Start;
  569. KEEP(*(.option_setting_ofs2))
  570. . = PROJECT_SECURE_OR_FLAT ? __OPTION_SETTING_OFS_Start + 0x10 : __OPTION_SETTING_OFS_Start;
  571. KEEP(*(.option_setting_dualsel))
  572. __OPTION_SETTING_OFS_End = .;
  573. } > OPTION_SETTING_OFS = 0xFF
  574. .option_setting_sas :
  575. {
  576. __OPTION_SETTING_SAS_Start = .;
  577. KEEP(*(.option_setting_sas))
  578. __OPTION_SETTING_SAS_End = .;
  579. } > OPTION_SETTING_SAS = 0xFF
  580. /* Symbol required for RA Configuration tool. */
  581. __tz_OPTION_SETTING_N = ABSOLUTE(OPTION_SETTING_START_NS);
  582. .option_setting_ns :
  583. {
  584. __OPTION_SETTING_NS_Start = .;
  585. KEEP(*(.option_setting_ofs1))
  586. . = USE_OPTION_SETTING_NS ? __OPTION_SETTING_NS_Start + 0x04 : __OPTION_SETTING_NS_Start;
  587. KEEP(*(.option_setting_ofs3))
  588. . = USE_OPTION_SETTING_NS ? __OPTION_SETTING_NS_Start + 0x10 : __OPTION_SETTING_NS_Start;
  589. KEEP(*(.option_setting_banksel))
  590. . = USE_OPTION_SETTING_NS ? __OPTION_SETTING_NS_Start + 0x40 : __OPTION_SETTING_NS_Start;
  591. KEEP(*(.option_setting_bps0))
  592. . = USE_OPTION_SETTING_NS ? __OPTION_SETTING_NS_Start + 0x44 : __OPTION_SETTING_NS_Start;
  593. KEEP(*(.option_setting_bps1))
  594. . = USE_OPTION_SETTING_NS ? __OPTION_SETTING_NS_Start + 0x48 : __OPTION_SETTING_NS_Start;
  595. KEEP(*(.option_setting_bps2))
  596. . = USE_OPTION_SETTING_NS ? __OPTION_SETTING_NS_Start + 0x4C : __OPTION_SETTING_NS_Start;
  597. KEEP(*(.option_setting_bps3))
  598. . = USE_OPTION_SETTING_NS ? __OPTION_SETTING_NS_Start + 0x60 : __OPTION_SETTING_NS_Start;
  599. KEEP(*(.option_setting_pbps0))
  600. . = USE_OPTION_SETTING_NS ? __OPTION_SETTING_NS_Start + 0x64 : __OPTION_SETTING_NS_Start;
  601. KEEP(*(.option_setting_pbps1))
  602. . = USE_OPTION_SETTING_NS ? __OPTION_SETTING_NS_Start + 0x68 : __OPTION_SETTING_NS_Start;
  603. KEEP(*(.option_setting_pbps2))
  604. . = USE_OPTION_SETTING_NS ? __OPTION_SETTING_NS_Start + 0x6C : __OPTION_SETTING_NS_Start;
  605. KEEP(*(.option_setting_pbps3))
  606. __OPTION_SETTING_NS_End = .;
  607. } > OPTION_SETTING = 0xFF
  608. /* Symbol required for RA Configuration tool. */
  609. __tz_OPTION_SETTING_S_S = ORIGIN(OPTION_SETTING_S);
  610. .option_setting_s :
  611. {
  612. __OPTION_SETTING_S_Start = .;
  613. KEEP(*(.option_setting_ofs1_sec))
  614. . = PROJECT_SECURE_OR_FLAT ? __OPTION_SETTING_S_Start + 0x04 : __OPTION_SETTING_S_Start;
  615. KEEP(*(.option_setting_ofs3_sec))
  616. . = PROJECT_SECURE_OR_FLAT ? __OPTION_SETTING_S_Start + 0x10 : __OPTION_SETTING_S_Start;
  617. KEEP(*(.option_setting_banksel_sec))
  618. . = PROJECT_SECURE_OR_FLAT ? __OPTION_SETTING_S_Start + 0x40 : __OPTION_SETTING_S_Start;
  619. KEEP(*(.option_setting_bps_sec0))
  620. . = PROJECT_SECURE_OR_FLAT ? __OPTION_SETTING_S_Start + 0x44 : __OPTION_SETTING_S_Start;
  621. KEEP(*(.option_setting_bps_sec1))
  622. . = PROJECT_SECURE_OR_FLAT ? __OPTION_SETTING_S_Start + 0x48 : __OPTION_SETTING_S_Start;
  623. KEEP(*(.option_setting_bps_sec2))
  624. . = PROJECT_SECURE_OR_FLAT ? __OPTION_SETTING_S_Start + 0x4C : __OPTION_SETTING_S_Start;
  625. KEEP(*(.option_setting_bps_sec3))
  626. . = PROJECT_SECURE_OR_FLAT ? __OPTION_SETTING_S_Start + 0x60 : __OPTION_SETTING_S_Start;
  627. KEEP(*(.option_setting_pbps_sec0))
  628. . = PROJECT_SECURE_OR_FLAT ? __OPTION_SETTING_S_Start + 0x64 : __OPTION_SETTING_S_Start;
  629. KEEP(*(.option_setting_pbps_sec1))
  630. . = PROJECT_SECURE_OR_FLAT ? __OPTION_SETTING_S_Start + 0x68 : __OPTION_SETTING_S_Start;
  631. KEEP(*(.option_setting_pbps_sec2))
  632. . = PROJECT_SECURE_OR_FLAT ? __OPTION_SETTING_S_Start + 0x6C : __OPTION_SETTING_S_Start;
  633. KEEP(*(.option_setting_pbps_sec3))
  634. . = PROJECT_SECURE_OR_FLAT ? __OPTION_SETTING_S_Start + 0x80 : __OPTION_SETTING_S_Start;
  635. KEEP(*(.option_setting_ofs1_sel))
  636. . = PROJECT_SECURE_OR_FLAT ? __OPTION_SETTING_S_Start + 0x84 : __OPTION_SETTING_S_Start;
  637. KEEP(*(.option_setting_ofs3_sel))
  638. . = PROJECT_SECURE_OR_FLAT ? __OPTION_SETTING_S_Start + 0x90 : __OPTION_SETTING_S_Start;
  639. KEEP(*(.option_setting_banksel_sel))
  640. . = PROJECT_SECURE_OR_FLAT ? __OPTION_SETTING_S_Start + 0xC0 : __OPTION_SETTING_S_Start;
  641. KEEP(*(.option_setting_bps_sel0))
  642. . = PROJECT_SECURE_OR_FLAT ? __OPTION_SETTING_S_Start + 0xC4 : __OPTION_SETTING_S_Start;
  643. KEEP(*(.option_setting_bps_sel1))
  644. . = PROJECT_SECURE_OR_FLAT ? __OPTION_SETTING_S_Start + 0xC8 : __OPTION_SETTING_S_Start;
  645. KEEP(*(.option_setting_bps_sel2))
  646. . = PROJECT_SECURE_OR_FLAT ? __OPTION_SETTING_S_Start + 0xCC : __OPTION_SETTING_S_Start;
  647. KEEP(*(.option_setting_bps_sel3))
  648. __OPTION_SETTING_S_End = .;
  649. } > OPTION_SETTING_S = 0xFF
  650. /* Symbol required for RA Configuration tool. */
  651. __tz_OPTION_SETTING_S_N = __OPTION_SETTING_S_End;
  652. }