zuluscsi_gd32f205_btldr.ld 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  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. *(*USBFS_IRQHandler*)
  53. }
  54. DMA1_Channel1_IRQHandler = 0;
  55. DMA1_Channel4_IRQHandler = 0;
  56. EXTI10_15_IRQHandler = 0;
  57. EXTI3_IRQHandler = 0;
  58. USBFS_IRQHandler = 0;
  59. /* The startup code goes first into FLASH */
  60. .isr_vector :
  61. {
  62. . = ALIGN(4);
  63. KEEP(*(.isr_vector)) /* Startup code */
  64. . = ALIGN(4);
  65. } >FLASH
  66. /* The program code and other data goes into FLASH */
  67. .text :
  68. {
  69. . = ALIGN(4);
  70. *(.text) /* .text sections (code) */
  71. *(.text*) /* .text* sections (code) */
  72. *(.glue_7) /* glue arm to thumb code */
  73. *(.glue_7t) /* glue thumb to arm code */
  74. *(.eh_frame)
  75. KEEP (*(.init))
  76. KEEP (*(.fini))
  77. . = ALIGN(4);
  78. _etext = .; /* define a global symbols at end of code */
  79. } >FLASH
  80. /* Constant data goes into FLASH */
  81. .rodata :
  82. {
  83. . = ALIGN(4);
  84. *(.rodata) /* .rodata sections (constants, strings, etc.) */
  85. *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
  86. . = ALIGN(4);
  87. } >FLASH
  88. .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH
  89. .ARM : {
  90. __exidx_start = .;
  91. *(.ARM.exidx*)
  92. __exidx_end = .;
  93. } >FLASH
  94. .preinit_array :
  95. {
  96. PROVIDE_HIDDEN (__preinit_array_start = .);
  97. KEEP (*(.preinit_array*))
  98. PROVIDE_HIDDEN (__preinit_array_end = .);
  99. } >FLASH
  100. .init_array :
  101. {
  102. PROVIDE_HIDDEN (__init_array_start = .);
  103. KEEP (*(SORT(.init_array.*)))
  104. KEEP (*(.init_array*))
  105. PROVIDE_HIDDEN (__init_array_end = .);
  106. } >FLASH
  107. .fini_array :
  108. {
  109. PROVIDE_HIDDEN (__fini_array_start = .);
  110. KEEP (*(SORT(.fini_array.*)))
  111. KEEP (*(.fini_array*))
  112. PROVIDE_HIDDEN (__fini_array_end = .);
  113. } >FLASH
  114. /* used by the startup to initialize data */
  115. _sidata = LOADADDR(.data);
  116. /* Initialized data sections goes into RAM, load LMA copy after code */
  117. .data :
  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 AT> FLASH
  126. /* Uninitialized data section */
  127. . = ALIGN(4);
  128. .bss :
  129. {
  130. /* This is used by the startup in order to initialize the .bss secion */
  131. _sbss = .; /* define a global symbol at bss start */
  132. __bss_start__ = _sbss;
  133. *(.bss)
  134. *(.bss*)
  135. *(COMMON)
  136. . = ALIGN(4);
  137. _ebss = .; /* define a global symbol at bss end */
  138. __bss_end__ = _ebss;
  139. } >RAM
  140. /* User_heap_stack section, used to check that there is enough RAM left */
  141. ._user_heap_stack :
  142. {
  143. . = ALIGN(4);
  144. PROVIDE ( end = . );
  145. PROVIDE ( _end = . );
  146. . = . + _Min_Heap_Size;
  147. . = . + _Min_Stack_Size;
  148. . = ALIGN(4);
  149. } >RAM
  150. /* uninitialized CCRAM objects (like, buffers) */
  151. .ccram_bss :
  152. {
  153. __ccram_start_bss__ = .; /* define a global symbol at ccram start */
  154. KEEP(*(.ccram_bss))
  155. KEEP(*(.ccram_bss*))
  156. . = ALIGN(4);
  157. __ccram_end_bss__ = .; /* define a global symbol at end of *used* CCRAM (BSS) */
  158. } >CCRAM
  159. /* initialized CCRAM objects (like, initialized variables) */
  160. _si_ccram_data = LOADADDR(.ccram_data);
  161. .ccram_data :
  162. {
  163. . = ALIGN(4);
  164. _ccram_start_data = .; /* create a global symbol at data start */
  165. *(.ccram_bss) /* .data sections */
  166. *(.ccram_bss*) /* .data* sections */
  167. . = ALIGN(4);
  168. _ccram_end_data = .; /* define a global symbol at data end */
  169. } >CCRAM AT> FLASH
  170. /* Remove information from the standard libraries */
  171. /DISCARD/ :
  172. {
  173. libc.a ( * )
  174. libm.a ( * )
  175. libgcc.a ( * )
  176. }
  177. .ARM.attributes 0 : { *(.ARM.attributes) }
  178. }