flash.ld 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. /*
  2. * Copyright (c) 2022-2023 HPMicro
  3. * SPDX-License-Identifier: BSD-3-Clause
  4. */
  5. ENTRY(_start)
  6. STACK_SIZE = DEFINED(_stack_size) ? _stack_size : 0x4000;
  7. HEAP_SIZE = DEFINED(_heap_size) ? _heap_size : 0x4000;
  8. MEMORY
  9. {
  10. XPI0 (rx) : ORIGIN = 0x80003000, LENGTH = _flash_size - 0x3000
  11. ILM (wx) : ORIGIN = 0x00000000, LENGTH = 128K
  12. DLM (w) : ORIGIN = 0x00080000, LENGTH = 128K
  13. AXI_SRAM (wx) : ORIGIN = 0x01080000, LENGTH = 256K
  14. AXI_SRAM_NONCACHEABLE (wx) : ORIGIN = 0x010C0000, LENGTH = 256K
  15. AHB_SRAM (w) : ORIGIN = 0xF0300000, LENGTH = 32k
  16. }
  17. SECTIONS
  18. {
  19. .start : {
  20. . = ALIGN(8);
  21. KEEP(*(.start))
  22. } > XPI0
  23. .text : {
  24. . = ALIGN(8);
  25. *(.text)
  26. *(.text*)
  27. *(.rodata)
  28. *(.rodata*)
  29. *(.srodata)
  30. *(.srodata*)
  31. *(.hash)
  32. *(.dyn*)
  33. *(.gnu*)
  34. *(.pl*)
  35. KEEP(*(.eh_frame))
  36. *(.eh_frame*)
  37. KEEP (*(.init))
  38. KEEP (*(.fini))
  39. . = ALIGN(8);
  40. } > XPI0
  41. .rel : {
  42. KEEP(*(.rel*))
  43. } > XPI0
  44. /* section information for usbh class */
  45. .usbh_class_info : {
  46. . = ALIGN(4);
  47. __usbh_class_info_start__ = .;
  48. KEEP(*(.usbh_class_info))
  49. __usbh_class_info_end__ = .;
  50. . = ALIGN(8);
  51. } > XPI0
  52. PROVIDE (__etext = .);
  53. PROVIDE (_etext = .);
  54. PROVIDE (etext = .);
  55. .vectors ORIGIN(ILM) : AT(etext) {
  56. . = ALIGN(8);
  57. __vector_ram_start__ = .;
  58. KEEP(*(.vector_table))
  59. KEEP(*(.isr_vector))
  60. . = ALIGN(8);
  61. __vector_ram_end__ = .;
  62. } > ILM
  63. .data : AT(etext + __vector_ram_end__ - __vector_ram_start__) {
  64. . = ALIGN(8);
  65. __data_start__ = .;
  66. __global_pointer$ = . + 0x800;
  67. *(.data)
  68. *(.data*)
  69. *(.sdata)
  70. *(.sdata*)
  71. *(.tdata)
  72. *(.tdata*)
  73. KEEP(*(.jcr))
  74. KEEP(*(.dynamic))
  75. KEEP(*(.got*))
  76. KEEP(*(.got))
  77. KEEP(*(.gcc_except_table))
  78. KEEP(*(.gcc_except_table.*))
  79. . = ALIGN(8);
  80. PROVIDE(__preinit_array_start = .);
  81. KEEP(*(.preinit_array))
  82. PROVIDE(__preinit_array_end = .);
  83. . = ALIGN(8);
  84. PROVIDE(__init_array_start = .);
  85. KEEP(*(SORT_BY_INIT_PRIORITY(.init_array.*)))
  86. KEEP(*(.init_array))
  87. PROVIDE(__init_array_end = .);
  88. . = ALIGN(8);
  89. PROVIDE(__finit_array_start = .);
  90. KEEP(*(SORT_BY_INIT_PRIORITY(.finit_array.*)))
  91. KEEP(*(.finit_array))
  92. PROVIDE(__finit_array_end = .);
  93. . = ALIGN(8);
  94. KEEP(*crtbegin*.o(.ctors))
  95. KEEP(*(EXCLUDE_FILE (*crtend*.o) .ctors))
  96. KEEP(*(SORT(.ctors.*)))
  97. KEEP(*(.ctors))
  98. . = ALIGN(8);
  99. KEEP(*crtbegin*.o(.dtors))
  100. KEEP(*(EXCLUDE_FILE (*crtend*.o) .dtors))
  101. KEEP(*(SORT(.dtors.*)))
  102. KEEP(*(.dtors))
  103. . = ALIGN(8);
  104. __data_end__ = .;
  105. PROVIDE (__edata = .);
  106. PROVIDE (_edata = .);
  107. PROVIDE (edata = .);
  108. } > AXI_SRAM
  109. .fast : AT(etext + __vector_ram_end__ - __vector_ram_start__ + __data_end__ - __data_start__) {
  110. . = ALIGN(8);
  111. __ramfunc_start__ = .;
  112. *(.fast)
  113. . = ALIGN(8);
  114. __ramfunc_end__ = .;
  115. } > ILM
  116. .bss (NOLOAD) : {
  117. . = ALIGN(8);
  118. __bss_start__ = .;
  119. *(.bss)
  120. *(.bss*)
  121. *(.tbss*)
  122. *(.sbss*)
  123. *(.scommon)
  124. *(.scommon*)
  125. *(.tcommon*)
  126. *(.dynsbss*)
  127. *(COMMON)
  128. . = ALIGN(8);
  129. _end = .;
  130. __bss_end__ = .;
  131. } > AXI_SRAM
  132. .framebuffer (NOLOAD) : {
  133. . = ALIGN(8);
  134. KEEP(*(.framebuffer))
  135. . = ALIGN(8);
  136. } > AXI_SRAM
  137. .noncacheable.init : AT(etext + __vector_ram_end__ - __vector_ram_start__ + __data_end__ - __data_start__ + __ramfunc_end__ - __ramfunc_start__){
  138. . = ALIGN(8);
  139. __noncacheable_init_start__ = .;
  140. KEEP(*(.noncacheable.init))
  141. __noncacheable_init_end__ = .;
  142. . = ALIGN(8);
  143. } > AXI_SRAM_NONCACHEABLE
  144. .noncacheable.bss (NOLOAD) : {
  145. . = ALIGN(8);
  146. KEEP(*(.noncacheable))
  147. __noncacheable_bss_start__ = .;
  148. KEEP(*(.noncacheable.bss))
  149. __noncacheable_bss_end__ = .;
  150. . = ALIGN(8);
  151. } > AXI_SRAM_NONCACHEABLE
  152. .ahb_sram (NOLOAD) : {
  153. KEEP(*(.ahb_sram))
  154. } > AHB_SRAM
  155. .fast_ram (NOLOAD) : {
  156. KEEP(*(.fast_ram))
  157. } > DLM
  158. .heap (NOLOAD) : {
  159. . = ALIGN(8);
  160. __heap_start__ = .;
  161. . += HEAP_SIZE;
  162. __heap_end__ = .;
  163. } > DLM
  164. .stack (NOLOAD) : {
  165. . = ALIGN(8);
  166. __stack_base__ = .;
  167. . += STACK_SIZE;
  168. . = ALIGN(8);
  169. PROVIDE (_stack = .);
  170. PROVIDE (_stack_safe = .);
  171. } > DLM
  172. __noncacheable_start__ = ORIGIN(AXI_SRAM_NONCACHEABLE);
  173. __noncacheable_end__ = ORIGIN(AXI_SRAM_NONCACHEABLE) + LENGTH(AXI_SRAM_NONCACHEABLE);
  174. ASSERT((STACK_SIZE + HEAP_SIZE) <= 128K, "stack and heap total size larger than 128k")
  175. }