flash.ld 5.1 KB

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