stm32_flash.ld 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. /*
  2. *****************************************************************************
  3. **
  4. ** File : stm32_flash.ld
  5. **
  6. ** Abstract : Linker script for STM32F407VG Device with
  7. ** 512KByte FLASH, 192KByte RAM
  8. **
  9. ** Set heap size, stack size and stack location according
  10. ** to application requirements.
  11. **
  12. ** Set memory bank area and size if external memory is used.
  13. **
  14. ** Target : STMicroelectronics STM32
  15. **
  16. ** Environment : Atollic TrueSTUDIO(R)
  17. **
  18. ** Distribution: The file is distributed �as is,� without any warranty
  19. ** of any kind.
  20. **
  21. ** (c)Copyright Atollic AB.
  22. ** You may use this file as-is or modify it according to the needs of your
  23. ** project. Distribution of this file (unmodified or modified) is not
  24. ** permitted. Atollic AB permit registered Atollic TrueSTUDIO(R) users the
  25. ** rights to distribute the assembled, compiled & linked contents of this
  26. ** file as part of an application binary file, provided that it is built
  27. ** using the Atollic TrueSTUDIO(R) toolchain.
  28. **
  29. *****************************************************************************
  30. */
  31. /* Entry Point */
  32. ENTRY(Reset_Handler)
  33. /* Highest address of the user mode stack */
  34. _estack = 0x2001ffff; /* end of 128K RAM on AHB bus*/
  35. /* Generate a link error if heap and stack don't fit into RAM */
  36. _Min_Heap_Size = 0x800; /* required amount of heap */
  37. _Min_Stack_Size = 0x100; /* required amount of stack */
  38. /* Specify the memory areas */
  39. MEMORY
  40. {
  41. BOOTLOADER_P1 (rx) : ORIGIN = 0x08000000, LENGTH = 16K
  42. SETTINGS (rx) : ORIGIN = 0x08004000, LENGTH = 16K
  43. SETTINGS_SYS (rx) : ORIGIN = 0x08008000, LENGTH = 16K
  44. BOOTLOADER (rx) : ORIGIN = 0x0800C000, LENGTH = 80K
  45. CRC (rx) : ORIGIN = 0x0801FFFC, LENGTH = 4
  46. FLASH (rx) : ORIGIN = 0x08020000, LENGTH = 384K
  47. RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K
  48. MEMORY_B1 (rx) : ORIGIN = 0x10000000, LENGTH = 64K
  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. } >BOOTLOADER_P1
  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. *(.rodata) /* .rodata sections (constants, strings, etc.) */
  67. *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
  68. *(.glue_7) /* glue arm to thumb code */
  69. *(.glue_7t) /* glue thumb to arm code */
  70. *(.eh_frame)
  71. KEEP (*(.init))
  72. KEEP (*(.fini))
  73. . = ALIGN(4);
  74. _etext = .; /* define a global symbols at end of code */
  75. _exit = .;
  76. } >BOOTLOADER
  77. .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >BOOTLOADER
  78. .ARM : {
  79. __exidx_start = .;
  80. *(.ARM.exidx*)
  81. __exidx_end = .;
  82. } >BOOTLOADER
  83. .preinit_array :
  84. {
  85. PROVIDE_HIDDEN (__preinit_array_start = .);
  86. KEEP (*(.preinit_array*))
  87. PROVIDE_HIDDEN (__preinit_array_end = .);
  88. } >BOOTLOADER
  89. .init_array :
  90. {
  91. PROVIDE_HIDDEN (__init_array_start = .);
  92. KEEP (*(SORT(.init_array.*)))
  93. KEEP (*(.init_array*))
  94. PROVIDE_HIDDEN (__init_array_end = .);
  95. } >BOOTLOADER
  96. .fini_array :
  97. {
  98. PROVIDE_HIDDEN (__fini_array_start = .);
  99. /* _fini = .; */
  100. KEEP (*(.fini_array*))
  101. KEEP (*(SORT(.fini_array.*)))
  102. PROVIDE_HIDDEN (__fini_array_end = .);
  103. } >BOOTLOADER
  104. /* used by the startup to initialize data */
  105. _sidata = .;
  106. /* Initialized data sections goes into RAM, load LMA copy after code */
  107. .data : AT ( _sidata )
  108. {
  109. . = ALIGN(4);
  110. _sdata = .; /* create a global symbol at data start */
  111. *(.data) /* .data sections */
  112. *(.data*) /* .data* sections */
  113. . = ALIGN(4);
  114. _edata = .; /* define a global symbol at data end */
  115. } >RAM
  116. .fill LOADADDR(.data) + SIZEOF(.data) :
  117. {
  118. FILL(0xFFFFFFFF);
  119. /* . = ORIGIN(BOOTLOADER) + LENGTH(BOOTLOADER) - 4 - 1; */
  120. . = ORIGIN(CRC) - 1;
  121. BYTE(0xFF)
  122. /* PROVIDE_HIDDEN (__fini_array_end = .); */
  123. } > BOOTLOADER
  124. .crc :
  125. {
  126. . = ALIGN(4);
  127. KEEP(*(.crc))
  128. . = ALIGN(4);
  129. }>CRC
  130. /* Uninitialized data section */
  131. . = ALIGN(4);
  132. .bss :
  133. {
  134. /* This is used by the startup in order to initialize the .bss secion */
  135. _sbss = .; /* define a global symbol at bss start */
  136. __bss_start__ = _sbss;
  137. *(.bss)
  138. *(.bss*)
  139. *(COMMON)
  140. . = ALIGN(4);
  141. _ebss = .; /* define a global symbol at bss end */
  142. __bss_end__ = _ebss;
  143. } >RAM
  144. /* User_heap_stack section, used to check that there is enough RAM left */
  145. ._user_heap_stack :
  146. {
  147. . = ALIGN(4);
  148. PROVIDE ( end = . );
  149. PROVIDE ( _end = . );
  150. . = . + _Min_Heap_Size;
  151. . = . + _Min_Stack_Size;
  152. . = ALIGN(4);
  153. } >RAM
  154. /* MEMORY_bank1 section, code must be located here explicitly */
  155. /* Example: extern int foo(void) __attribute__ ((section (".mb1text"))); */
  156. .memory_b1_text :
  157. {
  158. *(.mb1text) /* .mb1text sections (code) */
  159. *(.mb1text*) /* .mb1text* sections (code) */
  160. *(.mb1rodata) /* read-only data (constants) */
  161. *(.mb1rodata*)
  162. } >MEMORY_B1
  163. /* Remove information from the standard libraries */
  164. /DISCARD/ :
  165. {
  166. libc.a ( * )
  167. libm.a ( * )
  168. libgcc.a ( * )
  169. }
  170. .settings :
  171. {
  172. . = ALIGN(4);
  173. FILL(0xFF);
  174. . = ORIGIN(SETTINGS) + LENGTH(SETTINGS) - 1;
  175. BYTE(0xFF)
  176. } >SETTINGS
  177. .settings_sys :
  178. {
  179. . = ALIGN(4);
  180. FILL(0xFF);
  181. . = ORIGIN(SETTINGS_SYS) + LENGTH(SETTINGS_SYS) - 1;
  182. BYTE(0xFF)
  183. } >SETTINGS_SYS
  184. .ARM.attributes 0 : { *(.ARM.attributes) }
  185. }