Target_FLASH.ld 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. /*
  2. *****************************************************************************
  3. **
  4. ** File : Target_FLASH.ld
  5. **
  6. ** Abstract : Linker script for Target Device with
  7. ** 256KByte FLASH, 32KByte 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. ** Date : 2019-01-07
  15. **
  16. *****************************************************************************
  17. */
  18. /* Entry Point */
  19. ENTRY(Reset_Handler)
  20. /* Highest address of the user mode stack */
  21. _estack = 0x20008000; /* end of RAM */
  22. /* Generate a link error if heap and stack don't fit into RAM */
  23. _Min_Heap_Size = 0x400; /* required amount of heap */
  24. _Min_Stack_Size = 0x1000; /* required amount of stack */
  25. /* Specify the memory areas */
  26. MEMORY
  27. {
  28. RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 32K
  29. FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 256K
  30. }
  31. /* Define output sections */
  32. SECTIONS
  33. {
  34. /* The startup code goes first into FLASH */
  35. .isr_vector : AT(0)
  36. {
  37. . = ALIGN(4);
  38. KEEP(*(.isr_vector)) /* Startup code */
  39. . = ALIGN(4);
  40. } >FLASH
  41. .chipinit_section : AT(0xC0)
  42. {
  43. . = ALIGN(4);
  44. *(.chipinit_section) /* .text sections (code) */
  45. *(.chipinit_section*) /* .text* sections (code) */
  46. *(.glue_7) /* glue arm to thumb code */
  47. *(.glue_7t) /* glue thumb to arm code */
  48. *(.eh_frame)
  49. KEEP (*(.init))
  50. KEEP (*(.fini))
  51. . = ALIGN(4);
  52. _etext = .; /* define a global symbols at end of code */
  53. } >FLASH
  54. /* The program code and other data goes into FLASH */
  55. .text :
  56. {
  57. . = ALIGN(4);
  58. *(.text) /* .text sections (code) */
  59. *(.text*) /* .text* sections (code) */
  60. *(.glue_7) /* glue arm to thumb code */
  61. *(.glue_7t) /* glue thumb to arm code */
  62. *(.eh_frame)
  63. KEEP (*(.init))
  64. KEEP (*(.fini))
  65. . = ALIGN(4);
  66. _etext = .; /* define a global symbols at end of code */
  67. } >FLASH
  68. /* Constant data goes into FLASH */
  69. .rodata :
  70. {
  71. . = ALIGN(4);
  72. *(.rodata) /* .rodata sections (constants, strings, etc.) */
  73. *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
  74. . = ALIGN(4);
  75. } >FLASH
  76. .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH
  77. .ARM : {
  78. __exidx_start = .;
  79. *(.ARM.exidx*)
  80. __exidx_end = .;
  81. } >FLASH
  82. .preinit_array :
  83. {
  84. PROVIDE_HIDDEN (__preinit_array_start = .);
  85. KEEP (*(.preinit_array*))
  86. PROVIDE_HIDDEN (__preinit_array_end = .);
  87. } >FLASH
  88. .init_array :
  89. {
  90. PROVIDE_HIDDEN (__init_array_start = .);
  91. KEEP (*(SORT(.init_array.*)))
  92. KEEP (*(.init_array*))
  93. PROVIDE_HIDDEN (__init_array_end = .);
  94. } >FLASH
  95. .fini_array :
  96. {
  97. PROVIDE_HIDDEN (__fini_array_start = .);
  98. KEEP (*(SORT(.fini_array.*)))
  99. KEEP (*(.fini_array*))
  100. PROVIDE_HIDDEN (__fini_array_end = .);
  101. } >FLASH
  102. /* used by the startup to initialize data */
  103. _sidata = LOADADDR(.data);
  104. /* Initialized data sections goes into RAM, load LMA copy after code */
  105. .data :
  106. {
  107. . = ALIGN(4);
  108. _sdata = .; /* create a global symbol at data start */
  109. *(.data) /* .data sections */
  110. *(.data*) /* .data* sections */
  111. . = ALIGN(4);
  112. _edata = .; /* define a global symbol at data end */
  113. } >RAM AT> FLASH
  114. /* Uninitialized data section */
  115. . = ALIGN(4);
  116. .bss :
  117. {
  118. /* This is used by the startup in order to initialize the .bss secion */
  119. _sbss = .; /* define a global symbol at bss start */
  120. __bss_start__ = _sbss;
  121. *(.bss)
  122. *(.bss*)
  123. *(COMMON)
  124. . = ALIGN(4);
  125. _ebss = .; /* define a global symbol at bss end */
  126. __bss_end__ = _ebss;
  127. } >RAM
  128. /* User_heap_stack section, used to check that there is enough RAM left */
  129. ._user_heap_stack :
  130. {
  131. . = ALIGN(8);
  132. PROVIDE ( end = . );
  133. PROVIDE ( _end = . );
  134. . = . + _Min_Heap_Size;
  135. . = . + _Min_Stack_Size;
  136. . = ALIGN(8);
  137. } >RAM
  138. /* Remove information from the standard libraries */
  139. /DISCARD/ :
  140. {
  141. libc.a ( * )
  142. libm.a ( * )
  143. libgcc.a ( * )
  144. }
  145. .ARM.attributes 0 : { *(.ARM.attributes) }
  146. }