zuluscsi_gd32f205_btldr.ld 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. /**
  2. * ZuluSCSI™ - Copyright (c) 2022 Rabbit Hole Computing™
  3. *
  4. * ZuluSCSI™ firmware is licensed under the GPL version 3 or any later version. 
  5. *
  6. * https://www.gnu.org/licenses/gpl-3.0.html
  7. * ----
  8. * This program is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version. 
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16. * GNU General Public License for more details. 
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program.  If not, see <https://www.gnu.org/licenses/>.
  20. **/
  21. /*
  22. *
  23. * Customized linker script for building bootloader
  24. *
  25. */
  26. /* Entry Point */
  27. ENTRY(Reset_Handler)
  28. /* Highest address of the user mode stack */
  29. _estack = 0x20020000; /* end of RAM */
  30. /* Generate a link error if heap and stack don't fit into RAM */
  31. _Min_Heap_Size = 0x200; /* required amount of heap */
  32. _Min_Stack_Size = 0x400; /* required amount of stack */
  33. /* Specify the memory areas */
  34. MEMORY
  35. {
  36. RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K
  37. CCRAM (xrw) : ORIGIN = 0x10000000, LENGTH = 0K
  38. FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 32K
  39. }
  40. /* Define output sections */
  41. SECTIONS
  42. {
  43. /* Discard interrupt vectors that are not needed for bootloader.
  44. * This way unnecessary code doesn't get pulled in.
  45. */
  46. /DISCARD/ :
  47. {
  48. *(*DMA1_Channel4_IRQHandler*)
  49. *(*DMA1_Channel1_IRQHandler*)
  50. *(*EXTI3_IRQHandler*)
  51. *(*EXTI10_15_IRQHandler*)
  52. }
  53. DMA1_Channel1_IRQHandler = 0;
  54. DMA1_Channel4_IRQHandler = 0;
  55. EXTI10_15_IRQHandler = 0;
  56. EXTI3_IRQHandler = 0;
  57. /* The startup code goes first into FLASH */
  58. .isr_vector :
  59. {
  60. . = ALIGN(4);
  61. KEEP(*(.isr_vector)) /* Startup code */
  62. . = ALIGN(4);
  63. } >FLASH
  64. /* The program code and other data goes into FLASH */
  65. .text :
  66. {
  67. . = ALIGN(4);
  68. *(.text) /* .text sections (code) */
  69. *(.text*) /* .text* sections (code) */
  70. *(.glue_7) /* glue arm to thumb code */
  71. *(.glue_7t) /* glue thumb to arm code */
  72. *(.eh_frame)
  73. KEEP (*(.init))
  74. KEEP (*(.fini))
  75. . = ALIGN(4);
  76. _etext = .; /* define a global symbols at end of code */
  77. } >FLASH
  78. /* Constant data goes into FLASH */
  79. .rodata :
  80. {
  81. . = ALIGN(4);
  82. *(.rodata) /* .rodata sections (constants, strings, etc.) */
  83. *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
  84. . = ALIGN(4);
  85. } >FLASH
  86. .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH
  87. .ARM : {
  88. __exidx_start = .;
  89. *(.ARM.exidx*)
  90. __exidx_end = .;
  91. } >FLASH
  92. .preinit_array :
  93. {
  94. PROVIDE_HIDDEN (__preinit_array_start = .);
  95. KEEP (*(.preinit_array*))
  96. PROVIDE_HIDDEN (__preinit_array_end = .);
  97. } >FLASH
  98. .init_array :
  99. {
  100. PROVIDE_HIDDEN (__init_array_start = .);
  101. KEEP (*(SORT(.init_array.*)))
  102. KEEP (*(.init_array*))
  103. PROVIDE_HIDDEN (__init_array_end = .);
  104. } >FLASH
  105. .fini_array :
  106. {
  107. PROVIDE_HIDDEN (__fini_array_start = .);
  108. KEEP (*(SORT(.fini_array.*)))
  109. KEEP (*(.fini_array*))
  110. PROVIDE_HIDDEN (__fini_array_end = .);
  111. } >FLASH
  112. /* used by the startup to initialize data */
  113. _sidata = LOADADDR(.data);
  114. /* Initialized data sections goes into RAM, load LMA copy after code */
  115. .data :
  116. {
  117. . = ALIGN(4);
  118. _sdata = .; /* create a global symbol at data start */
  119. *(.data) /* .data sections */
  120. *(.data*) /* .data* sections */
  121. . = ALIGN(4);
  122. _edata = .; /* define a global symbol at data end */
  123. } >RAM AT> FLASH
  124. /* Uninitialized data section */
  125. . = ALIGN(4);
  126. .bss :
  127. {
  128. /* This is used by the startup in order to initialize the .bss secion */
  129. _sbss = .; /* define a global symbol at bss start */
  130. __bss_start__ = _sbss;
  131. *(.bss)
  132. *(.bss*)
  133. *(COMMON)
  134. . = ALIGN(4);
  135. _ebss = .; /* define a global symbol at bss end */
  136. __bss_end__ = _ebss;
  137. } >RAM
  138. /* User_heap_stack section, used to check that there is enough RAM left */
  139. ._user_heap_stack :
  140. {
  141. . = ALIGN(4);
  142. PROVIDE ( end = . );
  143. PROVIDE ( _end = . );
  144. . = . + _Min_Heap_Size;
  145. . = . + _Min_Stack_Size;
  146. . = ALIGN(4);
  147. } >RAM
  148. /* uninitialized CCRAM objects (like, buffers) */
  149. .ccram_bss :
  150. {
  151. __ccram_start_bss__ = .; /* define a global symbol at ccram start */
  152. KEEP(*(.ccram_bss))
  153. KEEP(*(.ccram_bss*))
  154. . = ALIGN(4);
  155. __ccram_end_bss__ = .; /* define a global symbol at end of *used* CCRAM (BSS) */
  156. } >CCRAM
  157. /* initialized CCRAM objects (like, initialized variables) */
  158. _si_ccram_data = LOADADDR(.ccram_data);
  159. .ccram_data :
  160. {
  161. . = ALIGN(4);
  162. _ccram_start_data = .; /* create a global symbol at data start */
  163. *(.ccram_bss) /* .data sections */
  164. *(.ccram_bss*) /* .data* sections */
  165. . = ALIGN(4);
  166. _ccram_end_data = .; /* define a global symbol at data end */
  167. } >CCRAM AT> FLASH
  168. /* Remove information from the standard libraries */
  169. /DISCARD/ :
  170. {
  171. libc.a ( * )
  172. libm.a ( * )
  173. libgcc.a ( * )
  174. }
  175. .ARM.attributes 0 : { *(.ARM.attributes) }
  176. }