pinguino-debug.ld 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336
  1. /****************************************************************************
  2. * configs/pic32mz-starterkit/nsh/mips-debug.ld
  3. *
  4. * Copyright (C) 2015 Gregory Nutt. All rights reserved.
  5. * Author: Gregory Nutt <gnutt@nuttx.org>
  6. *
  7. * Redistribution and use in source and binary forms, with or without
  8. * modification, are permitted provided that the following conditions
  9. * are met:
  10. *
  11. * 1. Redistributions of source code must retain the above copyright
  12. * notice, this list of conditions and the following disclaimer.
  13. * 2. Redistributions in binary form must reproduce the above copyright
  14. * notice, this list of conditions and the following disclaimer in
  15. * the documentation and/or other materials provided with the
  16. * distribution.
  17. * 3. Neither the name NuttX nor the names of its contributors may be
  18. * used to endorse or promote products derived from this software
  19. * without specific prior written permission.
  20. *
  21. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  22. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  23. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  24. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  25. * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  26. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  27. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  28. * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  29. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  30. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
  31. * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  32. * POSSIBILITY OF SUCH DAMAGE.
  33. *
  34. ****************************************************************************/
  35. /* Memory Regions ***********************************************************/
  36. MEMORY
  37. {
  38. /* The PIC32MZ2048ECH144 and PIC32MZ2048ECM144 chips have has 2048Kb of
  39. * program FLASH at physical address 0x1d000000 but is always accessed
  40. * at KSEG0 address 0x9d00:0000
  41. */
  42. kseg0_progmem (rx) : ORIGIN = 0x9d000000, LENGTH = 2048K
  43. /* The PIC32MZ2048ECH144 and PIC32MZ2048ECM144 chips have 160Kb of boot
  44. * FLASH: 80Kb at physical address 0x1fc4000 (Boot Flash 1, boot1) and
  45. * 80Kb at physical address 0x1fc60000 (Boot Flash 2, boot2). Either
  46. * may be mappled to the lower boot alias region (0x1fc00000,
  47. * boolalias1) or the upper boot alias region (0x1fc20000, bootalias2).
  48. * This linker script assumes that Boot Flash 1 is mapped to the lower
  49. * alias region and Boot Flash 2 to the upper region.
  50. *
  51. * NOTE: This linker script simply writes into the lower boot alias,
  52. * whichever boot FLASH that may correspond to. The other boot FLASH
  53. * is simply ignored.
  54. *
  55. * The initial reset vector is in KSEG1, but all other accesses are in
  56. * KSEG0.
  57. *
  58. * REGION PHYSICAL KSEG SIZE
  59. * DESCRIPTION START ADDR (BYTES)
  60. * ------------- ---------- ------ ----------------------
  61. * Exceptions:*
  62. * Reset 0x1fc00000 KSEG1 512 512
  63. * TLB Refill 0x1fc00200 KSEG1 256 768
  64. * Cache Error 0x1fc00300 KSEG1 128 896
  65. * Others 0x1fc00380 KSEG1 128 1024 (1Kb)
  66. * Interrupt 0x1fc00400 KSEG1 128 1152
  67. * JTAG 0x1fc00480 KSEG1 16 1168
  68. * Exceptions 0x1fc00490 KSEG0 8192-1168 8192 (4Kb)
  69. * Debug code 0x1fc02000 KSEG1 4096-16 12272
  70. * ADEVCFG3-0 0x1fc0ff40 KSEG1 16 12288 (12Kb)
  71. * DEVCFG3-0 0x1fc0ffc0 KSEG1 16 12288 (12Kb)
  72. *
  73. * Exceptions assume:
  74. *
  75. * STATUS: BEV=0/1 and EXL=0
  76. * CAUSE: IV=1
  77. * JTAG: ProbEn=0
  78. * And multi-vector support disabled
  79. */
  80. kseg1_reset (rx) : ORIGIN = 0xbfc00000, LENGTH = 384
  81. kseg1_genexcpt (rx) : ORIGIN = 0xbfc00180, LENGTH = 128
  82. kseg1_ebexcpt (rx) : ORIGIN = 0xbfc00200, LENGTH = 128
  83. kseg1_bevexcpt (rx) : ORIGIN = 0xbfc00380, LENGTH = 128
  84. kseg1_intexcpt (rx) : ORIGIN = 0xbfc00400, LENGTH = 128
  85. kseg1_dbgexcpt (rx) : ORIGIN = 0xbfc00480, LENGTH = 16
  86. kseg0_bootmem (rx) : ORIGIN = 0x9fc004ac, LENGTH = 8192-1196
  87. kseg1_dbgcode (rx) : ORIGIN = 0xbfc02000, LENGTH = 4096-16
  88. kseg1_adevcfg (r) : ORIGIN = 0x1fc0ff40, LENGTH = 128
  89. kseg1_devcfg (r) : ORIGIN = 0x1fc0ffc0, LENGTH = 128
  90. /* The The PIC32MZ2048ECH144 and PIC32MZ2048ECM144 chips have has 512Kb
  91. * of data memory at physical address 0x00000000. Since the PIC32MZ
  92. * has no data cache, this memory is always accessed through KSEG1.
  93. *
  94. * When used with MPLABX, we need to set aside 512 bytes of memory
  95. * for use by MPLABX and 128 for DSP register storage.
  96. */
  97. kseg1_datamem (rw!x) : ORIGIN = 0xa0000200, LENGTH = 512K - 640
  98. }
  99. OUTPUT_FORMAT("elf32-littlemips")
  100. OUTPUT_ARCH(mips)
  101. ENTRY(__start)
  102. SECTIONS
  103. {
  104. /* Boot FLASH sections */
  105. .reset :
  106. {
  107. KEEP (*(.reset))
  108. } > kseg1_reset
  109. /* Exception handlers. The following is assumed:
  110. *
  111. * STATUS: BEV=1 and EXL=0
  112. * CAUSE: IV=1
  113. * JTAG: ProbEn=0
  114. * And multi-vector support disabled
  115. *
  116. * In that configuration, the vector locations become:
  117. *
  118. * Reset, Soft Reset bfc0:0000
  119. * TLB Refill bfc0:0200
  120. * Cache Error bfc0:0300
  121. * All others bfc0:0380
  122. * Interrupt bfc0:0400
  123. * EJTAG Debug bfc0:0480
  124. */
  125. /* KSEG1 exception handler "trampolines" */
  126. .gen_excpt :
  127. {
  128. KEEP (*(.gen_excpt))
  129. } > kseg1_genexcpt
  130. .ebase_excpt :
  131. {
  132. KEEP (*(.ebase_excpt))
  133. } > kseg1_ebexcpt
  134. .bev_excpt :
  135. {
  136. KEEP (*(.bev_excpt))
  137. } > kseg1_bevexcpt
  138. .int_excpt :
  139. {
  140. KEEP (*(.int_excpt))
  141. } > kseg1_intexcpt
  142. .dbg_excpt = ORIGIN(kseg1_dbgexcpt);
  143. .start :
  144. {
  145. /* KSEG0 Reset startup logic */
  146. *(.start)
  147. /* KSEG0 exception handlers */
  148. *(.nmi_handler)
  149. *(.bev_handler)
  150. *(.int_handler)
  151. } > kseg0_bootmem
  152. .dbg_code = ORIGIN(kseg1_dbgcode);
  153. .adevcfg :
  154. {
  155. KEEP (*(.adevcfg))
  156. } > kseg1_adevcfg
  157. .devcfg :
  158. {
  159. KEEP (*(.devcfg))
  160. } > kseg1_devcfg
  161. /* Program FLASH sections */
  162. .text :
  163. {
  164. _stext = ABSOLUTE(.);
  165. *(.text .text.*)
  166. *(.stub)
  167. KEEP (*(.text.*personality*))
  168. *(.gnu.linkonce.t.*)
  169. *(.gnu.warning)
  170. *(.mips16.fn.*)
  171. *(.mips16.call.*)
  172. /* Read-only data is included in the text section */
  173. *(.rodata .rodata.*)
  174. *(.rodata1)
  175. *(.gnu.linkonce.r.*)
  176. /* Small initialized constant global and static data */
  177. *(.sdata2 .sdata2.*)
  178. *(.gnu.linkonce.s2.*)
  179. /* Uninitialized constant global and static data */
  180. *(.sbss2 .sbss2.*)
  181. *(.gnu.linkonce.sb2.*)
  182. _etext = ABSOLUTE(.);
  183. } > kseg0_progmem
  184. /* Initialization data begins here in progmem */
  185. _data_loaddr = LOADADDR(.data);
  186. .eh_frame_hdr : { *(.eh_frame_hdr) *(.eh_frame_entry .eh_frame_entry.*) }
  187. .eh_frame : ONLY_IF_RO { KEEP (*(.eh_frame)) }
  188. /* RAM functions are positioned at the beginning of RAM so that
  189. * they can be guaranteed to satisfy the 2Kb alignment requirement.
  190. */
  191. /* This causes failures if there are no RAM functions
  192. .ramfunc ALIGN(2K) :
  193. {
  194. _sramfunc = ABSOLUTE(.);
  195. *(.ramfunc .ramfunc.*)
  196. _eramfunc = ABSOLUTE(.);
  197. } > kseg1_datamem AT > kseg0_progmem
  198. _ramfunc_loadaddr = LOADADDR(.ramfunc);
  199. _ramfunc_sizeof = SIZEOF(.ramfunc);
  200. _bmxdkpba_address = _sramfunc - ORIGIN(kseg1_datamem) ;
  201. _bmxdudba_address = LENGTH(kseg1_datamem) ;
  202. _bmxdupba_address = LENGTH(kseg1_datamem) ;
  203. */
  204. .data :
  205. {
  206. _sdata = ABSOLUTE(.);
  207. *(.data .data.*)
  208. *(.gnu.linkonce.d.*)
  209. KEEP (*(.gnu.linkonce.d.*personality*))
  210. *(.data1)
  211. } > kseg1_datamem AT > kseg0_progmem
  212. .eh_frame : ONLY_IF_RW { KEEP (*(.eh_frame)) }
  213. _gp = ALIGN(16) + 0x7FF0 ;
  214. .got :
  215. {
  216. *(.got.plt) *(.got)
  217. } > kseg1_datamem AT > kseg0_progmem
  218. .sdata :
  219. {
  220. *(.sdata .sdata.* .gnu.linkonce.s.*)
  221. } > kseg1_datamem AT > kseg0_progmem
  222. .lit8 :
  223. {
  224. *(.lit8)
  225. } > kseg1_datamem AT > kseg0_progmem
  226. .lit4 :
  227. {
  228. *(.lit4)
  229. _edata = ABSOLUTE(.);
  230. } >kseg1_datamem AT>kseg0_progmem
  231. .sbss :
  232. {
  233. _sbss = ABSOLUTE(.);
  234. *(.dynsbss)
  235. *(.sbss .sbss.* .gnu.linkonce.sb.*)
  236. *(.scommon)
  237. } >kseg1_datamem
  238. .bss :
  239. {
  240. *(.dynbss)
  241. *(.bss .bss.*)
  242. *(.gnu.linkonce.b.*)
  243. *(COMMON)
  244. _ebss = ABSOLUTE(.);
  245. } > kseg1_datamem
  246. /* Stabs debugging sections */
  247. .stab 0 : { *(.stab) }
  248. .stabstr 0 : { *(.stabstr) }
  249. .stab.excl 0 : { *(.stab.excl) }
  250. .stab.exclstr 0 : { *(.stab.exclstr) }
  251. .stab.index 0 : { *(.stab.index) }
  252. .stab.indexstr 0 : { *(.stab.indexstr) }
  253. .comment 0 : { *(.comment) }
  254. /* DWARF debug sections */
  255. /* DWARF 1 */
  256. .debug 0 : { *(.debug) }
  257. .line 0 : { *(.line) }
  258. /* GNU DWARF 1 extensions */
  259. .debug_srcinfo 0 : { *(.debug_srcinfo) }
  260. .debug_sfnames 0 : { *(.debug_sfnames) }
  261. /* DWARF 1.1 and DWARF 2 */
  262. .debug_aranges 0 : { *(.debug_aranges) }
  263. .debug_pubnames 0 : { *(.debug_pubnames) }
  264. /* DWARF 2 */
  265. .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
  266. .debug_abbrev 0 : { *(.debug_abbrev) }
  267. .debug_line 0 : { *(.debug_line) }
  268. .debug_frame 0 : { *(.debug_frame) }
  269. .debug_str 0 : { *(.debug_str) }
  270. .debug_loc 0 : { *(.debug_loc) }
  271. .debug_macinfo 0 : { *(.debug_macinfo) }
  272. /* SGI/MIPS DWARF 2 extensions */
  273. .debug_weaknames 0 : { *(.debug_weaknames) }
  274. .debug_funcnames 0 : { *(.debug_funcnames) }
  275. .debug_typenames 0 : { *(.debug_typenames) }
  276. .debug_varnames 0 : { *(.debug_varnames) }
  277. /DISCARD/ : { *(.note.GNU-stack) }
  278. }