stm32_flash.ld 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  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 = 0x3000; /* required amount of heap */
  37. _Min_Stack_Size = 0x4000; /* 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. VECTOR (rx) : ORIGIN = 0x08020000, LENGTH = 496
  46. HWREV (rx) : ORIGIN = 0x080201F0, LENGTH = 16
  47. FLASH (rx) : ORIGIN = 0x08020200, LENGTH = 384K - 512
  48. CRC (rx) : ORIGIN = 0x0807FFFC, LENGTH = 4
  49. RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K
  50. MEMORY_B1 (rx) : ORIGIN = 0x10000000, LENGTH = 64K
  51. }
  52. /* Define output sections */
  53. SECTIONS
  54. {
  55. /* The startup code goes first into FLASH */
  56. .isr_vector :
  57. {
  58. . = ALIGN(4);
  59. KEEP(*(.isr_vector)) /* Startup code */
  60. . = ALIGN(4);
  61. } >VECTOR
  62. /* The HWREV section contains hardware revision
  63. * number for binary validation in bootloader */
  64. .hw_rev :
  65. {
  66. . = ALIGN(4);
  67. KEEP(*(.hw_rev)) /* Startup code */
  68. . = ALIGN(4);
  69. } >HWREV
  70. /* The program code and other data goes into FLASH */
  71. .text :
  72. {
  73. . = ALIGN(4);
  74. *(.text) /* .text sections (code) */
  75. *(.text*) /* .text* sections (code) */
  76. *(.rodata) /* .rodata sections (constants, strings, etc.) */
  77. *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
  78. *(.glue_7) /* glue arm to thumb code */
  79. *(.glue_7t) /* glue thumb to arm code */
  80. *(.eh_frame)
  81. KEEP (*(.init))
  82. KEEP (*(.fini))
  83. . = ALIGN(4);
  84. _etext = .; /* define a global symbols at end of code */
  85. _exit = .;
  86. } >FLASH
  87. .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH
  88. .ARM : {
  89. __exidx_start = .;
  90. *(.ARM.exidx*)
  91. __exidx_end = .;
  92. } >FLASH
  93. .preinit_array :
  94. {
  95. PROVIDE_HIDDEN (__preinit_array_start = .);
  96. KEEP (*(.preinit_array*))
  97. PROVIDE_HIDDEN (__preinit_array_end = .);
  98. } >FLASH
  99. .init_array :
  100. {
  101. PROVIDE_HIDDEN (__init_array_start = .);
  102. KEEP (*(SORT(.init_array.*)))
  103. KEEP (*(.init_array*))
  104. PROVIDE_HIDDEN (__init_array_end = .);
  105. } >FLASH
  106. .fini_array :
  107. {
  108. PROVIDE_HIDDEN (__fini_array_start = .);
  109. /* _fini = .; */
  110. KEEP (*(.fini_array*))
  111. KEEP (*(SORT(.fini_array.*)))
  112. PROVIDE_HIDDEN (__fini_array_end = .);
  113. } >FLASH
  114. /* used by the startup to initialize data */
  115. _sidata = .;
  116. /* Initialized data sections goes into RAM, load LMA copy after code */
  117. .data : AT ( _sidata )
  118. {
  119. . = ALIGN(4);
  120. _sdata = .; /* create a global symbol at data start */
  121. *(.data) /* .data sections */
  122. *(.data*) /* .data* sections */
  123. . = ALIGN(4);
  124. _edata = .; /* define a global symbol at data end */
  125. } >RAM
  126. .fill LOADADDR(.data) + SIZEOF(.data) :
  127. {
  128. FILL(0xFFFFFFFF);
  129. /* . = ORIGIN(FLASH) + LENGTH(FLASH) - 4 - 1; */
  130. . = ORIGIN(CRC) - 1;
  131. BYTE(0xFF)
  132. /* PROVIDE_HIDDEN (__fini_array_end = .); */
  133. } > FLASH
  134. .crc :
  135. {
  136. . = ALIGN(4);
  137. KEEP(*(.crc))
  138. . = ALIGN(4);
  139. }>CRC
  140. /* Uninitialized data section */
  141. . = ALIGN(4);
  142. .bss :
  143. {
  144. /* This is used by the startup in order to initialize the .bss secion */
  145. _sbss = .; /* define a global symbol at bss start */
  146. __bss_start__ = _sbss;
  147. *(.bss)
  148. *(.bss*)
  149. *(COMMON)
  150. . = ALIGN(4);
  151. _ebss = .; /* define a global symbol at bss end */
  152. __bss_end__ = _ebss;
  153. } >RAM
  154. /* User_heap_stack section, used to check that there is enough RAM left */
  155. ._user_heap_stack :
  156. {
  157. . = ALIGN(4);
  158. PROVIDE ( end = . );
  159. PROVIDE ( _end = . );
  160. . = . + _Min_Heap_Size;
  161. . = . + _Min_Stack_Size;
  162. . = ALIGN(4);
  163. } >RAM
  164. /* MEMORY_bank1 section, code must be located here explicitly */
  165. /* Example: extern int foo(void) __attribute__ ((section (".mb1text"))); */
  166. .memory_b1_text (NOLOAD) :
  167. {
  168. *(.mb1text) /* .mb1text sections (code) */
  169. *(.mb1text*) /* .mb1text* sections (code) */
  170. *(.mb1rodata) /* read-only data (constants) */
  171. *(.mb1rodata*)
  172. } >MEMORY_B1
  173. /* Remove information from the standard libraries */
  174. /DISCARD/ :
  175. {
  176. libc.a ( * )
  177. libm.a ( * )
  178. libgcc.a ( * )
  179. }
  180. .ARM.attributes 0 : { *(.ARM.attributes) }
  181. }