ldscript.ld 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. /*
  2. ******************************************************************************
  3. **
  4. ** File : LinkerScript.ld
  5. **
  6. ** Author : STM32CubeIDE
  7. **
  8. ** Abstract : Linker script for STM32H7 series
  9. ** 512Kbytes FLASH and 560Kbytes RAM
  10. **
  11. ** Set heap size, stack size and stack location according
  12. ** to application requirements.
  13. **
  14. ** Set memory bank area and size if external memory is used.
  15. **
  16. ** Target : STMicroelectronics STM32
  17. **
  18. ** Distribution: The file is distributed as is, without any warranty
  19. ** of any kind.
  20. **
  21. *****************************************************************************
  22. ** @attention
  23. **
  24. ** Copyright (c) 2022 STMicroelectronics.
  25. ** All rights reserved.
  26. **
  27. ** This software is licensed under terms that can be found in the LICENSE file
  28. ** in the root directory of this software component.
  29. ** If no LICENSE file comes with this software, it is provided AS-IS.
  30. **
  31. ****************************************************************************
  32. */
  33. /* Entry Point */
  34. ENTRY(Reset_Handler)
  35. /* Highest address of the user mode stack */
  36. _estack = ORIGIN(RAM_D1) + LENGTH(RAM_D1); /* end of RAM */
  37. /* Generate a link error if heap and stack don't fit into RAM */
  38. _Min_Heap_Size = 0x200 ; /* required amount of heap */
  39. _Min_Stack_Size = 0x400 ; /* required amount of stack */
  40. /* Specify the memory areas */
  41. MEMORY
  42. {
  43. ITCMRAM (xrw) : ORIGIN = 0x00000000, LENGTH = 64K
  44. DTCMRAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K
  45. FLASH (rx) : ORIGIN = 0x8000000 + LD_FLASH_OFFSET, LENGTH = LD_MAX_SIZE - LD_FLASH_OFFSET
  46. RAM_D1 (xrw) : ORIGIN = 0x24000000, LENGTH = 320K
  47. RAM_D2 (xrw) : ORIGIN = 0x30000000, LENGTH = 32K
  48. RAM_D3 (xrw) : ORIGIN = 0x38000000, LENGTH = 16K
  49. }
  50. /* Define output sections */
  51. SECTIONS
  52. {
  53. /* The startup code goes first into FLASH */
  54. .isr_vector :
  55. {
  56. . = ALIGN(4);
  57. KEEP(*(.isr_vector)) /* Startup code */
  58. . = ALIGN(4);
  59. } >FLASH
  60. /* The program code and other data goes into FLASH */
  61. .text :
  62. {
  63. . = ALIGN(4);
  64. *(.text) /* .text sections (code) */
  65. *(.text*) /* .text* sections (code) */
  66. *(.glue_7) /* glue arm to thumb code */
  67. *(.glue_7t) /* glue thumb to arm code */
  68. *(.eh_frame)
  69. KEEP (*(.init))
  70. KEEP (*(.fini))
  71. . = ALIGN(4);
  72. _etext = .; /* define a global symbols at end of code */
  73. } >FLASH
  74. /* Constant data goes into FLASH */
  75. .rodata :
  76. {
  77. . = ALIGN(4);
  78. *(.rodata) /* .rodata sections (constants, strings, etc.) */
  79. *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
  80. . = ALIGN(4);
  81. } >FLASH
  82. .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH
  83. .ARM : {
  84. __exidx_start = .;
  85. *(.ARM.exidx*)
  86. __exidx_end = .;
  87. } >FLASH
  88. .preinit_array :
  89. {
  90. PROVIDE_HIDDEN (__preinit_array_start = .);
  91. KEEP (*(.preinit_array*))
  92. PROVIDE_HIDDEN (__preinit_array_end = .);
  93. } >FLASH
  94. .init_array :
  95. {
  96. PROVIDE_HIDDEN (__init_array_start = .);
  97. KEEP (*(SORT(.init_array.*)))
  98. KEEP (*(.init_array*))
  99. PROVIDE_HIDDEN (__init_array_end = .);
  100. } >FLASH
  101. .fini_array :
  102. {
  103. PROVIDE_HIDDEN (__fini_array_start = .);
  104. KEEP (*(SORT(.fini_array.*)))
  105. KEEP (*(.fini_array*))
  106. PROVIDE_HIDDEN (__fini_array_end = .);
  107. } >FLASH
  108. /* used by the startup to initialize data */
  109. _sidata = LOADADDR(.data);
  110. /* Initialized data sections goes into RAM, load LMA copy after code */
  111. .data :
  112. {
  113. . = ALIGN(4);
  114. _sdata = .; /* create a global symbol at data start */
  115. *(.data) /* .data sections */
  116. *(.data*) /* .data* sections */
  117. *(.RamFunc) /* .RamFunc sections */
  118. *(.RamFunc*) /* .RamFunc* sections */
  119. . = ALIGN(4);
  120. _edata = .; /* define a global symbol at data end */
  121. } >RAM_D1 AT> FLASH
  122. /* Uninitialized data section */
  123. . = ALIGN(4);
  124. .bss :
  125. {
  126. /* This is used by the startup in order to initialize the .bss section */
  127. _sbss = .; /* define a global symbol at bss start */
  128. __bss_start__ = _sbss;
  129. *(.bss)
  130. *(.bss*)
  131. *(COMMON)
  132. . = ALIGN(4);
  133. _ebss = .; /* define a global symbol at bss end */
  134. __bss_end__ = _ebss;
  135. } >RAM_D1
  136. /* User_heap_stack section, used to check that there is enough RAM left */
  137. ._user_heap_stack :
  138. {
  139. . = ALIGN(8);
  140. PROVIDE ( end = . );
  141. PROVIDE ( _end = . );
  142. . = . + _Min_Heap_Size;
  143. . = . + _Min_Stack_Size;
  144. . = ALIGN(8);
  145. } >RAM_D1
  146. /* Remove information from the standard libraries */
  147. /DISCARD/ :
  148. {
  149. libc.a ( * )
  150. libm.a ( * )
  151. libgcc.a ( * )
  152. }
  153. .ARM.attributes 0 : { *(.ARM.attributes) }
  154. }