fsp.ld 33 KB

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