lpc2148-rom.ld 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. /* ****************************************************************************************************** */
  2. /* demo2148_blink_flash.cmd LINKER SCRIPT */
  3. /* */
  4. /* */
  5. /* The Linker Script defines how the code and data emitted by the GNU C compiler and assembler are */
  6. /* to be loaded into memory (code goes into FLASH, variables go into RAM). */
  7. /* */
  8. /* Any symbols defined in the Linker Script are automatically global and available to the rest of the */
  9. /* program. */
  10. /* */
  11. /* To force the linker to use this LINKER SCRIPT, just add the -T demo2148_blink_flash.cmd directive */
  12. /* to the linker flags in the makefile. */
  13. /* */
  14. /* LFLAGS = -Map main.map -nostartfiles -T demo2148_blink_flash.cmd */
  15. /* */
  16. /* */
  17. /* The Philips boot loader supports the ISP (In System Programming) via the serial port and the IAP */
  18. /* (In Application Programming) for flash programming from within your application. */
  19. /* */
  20. /* The boot loader uses RAM memory and we MUST NOT load variables or code in these areas. */
  21. /* */
  22. /* RAM used by boot loader: 0x40000120 - 0x400001FF (223 bytes) for ISP variables */
  23. /* 0x40007FE0 - 0x4000FFFF (32 bytes) for ISP and IAP variables */
  24. /* 0x40007EE0 - 0x40007FE0 (256 bytes) stack for ISP and IAP */
  25. /* */
  26. /* */
  27. /* MEMORY MAP */
  28. /* | |0x40008000 */
  29. /* .-------->|---------------------------------| */
  30. /* . | variables and stack |0x40007FFF */
  31. /* ram_isp_high | for Philips boot loader | */
  32. /* . | 32 + 256 = 288 bytes | */
  33. /* . | | */
  34. /* . | Do not put anything here |0x40007EE0 */
  35. /* .-------->|---------------------------------| */
  36. /* | UDF Stack 4 bytes |0x40007EDC <---------- _stack_end */
  37. /* .-------->|---------------------------------| */
  38. /* | ABT Stack 4 bytes |0x40007ED8 */
  39. /* .-------->|---------------------------------| */
  40. /* | FIQ Stack 4 bytes |0x40007ED4 */
  41. /* .-------->|---------------------------------| */
  42. /* | IRQ Stack 4 bytes |0x40007ED0 */
  43. /* .-------->|---------------------------------| */
  44. /* | SVC Stack 4 bytes |0x40007ECC */
  45. /* .-------->|---------------------------------| */
  46. /* . | |0x40007EC8 */
  47. /* . | stack area for user program | */
  48. /* . | | | */
  49. /* . | | | */
  50. /* . | | | */
  51. /* . | V | */
  52. /* . | | */
  53. /* . | | */
  54. /* . | | */
  55. /* . | free ram | */
  56. /* ram | | */
  57. /* . | | */
  58. /* . | | */
  59. /* . |.................................|0x40000234 <---------- _bss_end */
  60. /* . | | */
  61. /* . | .bss uninitialized variables | */
  62. /* . |.................................|0x40000218 <---------- _bss_start, _edata */
  63. /* . | | */
  64. /* . | .data initialized variables | */
  65. /* . | |0x40000200 <---------- _data */
  66. /* .-------->|---------------------------------| */
  67. /* . | variables used by |0x400001FF */
  68. /* ram_isp_low | Philips boot loader | */
  69. /* . | 223 bytes |0x40000120 */
  70. /* .-------->|---------------------------------| */
  71. /* . | |0x4000011F */
  72. /* ram_vectors | free ram | */
  73. /* . |---------------------------------|0x40000040 */
  74. /* . | |0x4000003F */
  75. /* . | Interrupt Vectors (re-mapped) | */
  76. /* . | 64 bytes |0x40000000 */
  77. /* .-------->|---------------------------------| */
  78. /* | | */
  79. /* */
  80. /* */
  81. /* */
  82. /* | | */
  83. /* .--------> |---------------------------------| */
  84. /* . | |0x0001FFFF */
  85. /* . | | */
  86. /* . | | */
  87. /* . | | */
  88. /* . | | */
  89. /* . | | */
  90. /* . | unused flash eprom | */
  91. /* . | | */
  92. /* . |.................................|0x0000032c */
  93. /* . | | */
  94. /* . | copy of .data area | */
  95. /* flash | | */
  96. /* . |---------------------------------|0x00000314 <----------- _etext */
  97. /* . | | */
  98. /* . | |0x00000180 main */
  99. /* . | |0x00000278 feed */
  100. /* . | main() |0x000002c4 FIQ_Routine */
  101. /* . | |0x000002d8 SWI_Routine */
  102. /* . | |0x000002ec UNDEF_Routine */
  103. /* . | |0x000002b0 IRQ_routine */
  104. /* . |---------------------------------|0x000001cc initialize */
  105. /* . | |0x000000D4 */
  106. /* . | Startup Code | */
  107. /* . | (assembler) | */
  108. /* . | | */
  109. /* . |---------------------------------|0x00000040 Reset_Handler */
  110. /* . | |0x0000003F */
  111. /* . | Interrupt Vector Table (unused) | */
  112. /* . | 64 bytes | */
  113. /* .--------->|---------------------------------|0x00000000 _startup *
  114. /* */
  115. /* */
  116. /* The easy way to prevent the linker from loading anything into a memory area is to define */
  117. /* a MEMORY region for it and then avoid assigning any .text, .data or .bss sections into it. */
  118. /* */
  119. /* */
  120. /* MEMORY */
  121. /* { */
  122. /* ram_isp_low(A) : ORIGIN = 0x40000120, LENGTH = 223 */
  123. /* */
  124. /* } */
  125. /* */
  126. /* */
  127. /* Author: James P. Lynch */
  128. /* */
  129. /* ****************************************************************************************************** */
  130. /* identify the Entry Point */
  131. ENTRY(_startup)
  132. /* specify the LPC2148 memory areas */
  133. MEMORY
  134. {
  135. flash : ORIGIN = 0, LENGTH = 512K /* FLASH ROM */
  136. ram_isp_low(A) : ORIGIN = 0x40000120, LENGTH = 223 /* variables used by Philips ISP bootloader */
  137. ram : ORIGIN = 0x40000200, LENGTH = 32513 /* free RAM area */
  138. ram_isp_high(A) : ORIGIN = 0x40007FE0, LENGTH = 32 /* variables used by Philips ISP bootloader */
  139. ram_usb_dma : ORIGIN = 0x7FD00000, LENGTH = 8192 /* on-chip USB DMA RAM area (not used) */
  140. }
  141. /* define a global symbol _stack_end */
  142. _stack_end = 0x40007EDC;
  143. /* now define the output sections */
  144. SECTIONS
  145. {
  146. . = 0; /* set location counter to address zero */
  147. startup : { *(.startup)} >flash /* the startup code goes into FLASH */
  148. .text : /* collect all sections that should go into FLASH after startup */
  149. {
  150. *(.text) /* all .text sections (code) */
  151. *(.rodata) /* all .rodata sections (constants, strings, etc.) */
  152. *(.rodata*) /* all .rodata* sections (constants, strings, etc.) */
  153. *(.glue_7) /* all .glue_7 sections (no idea what these are) */
  154. *(.glue_7t) /* all .glue_7t sections (no idea what these are) */
  155. _etext = .; /* define a global symbol _etext just after the last code byte */
  156. } >flash /* put all the above into FLASH */
  157. .data : /* collect all initialized .data sections that go into RAM */
  158. {
  159. _data = .; /* create a global symbol marking the start of the .data section */
  160. *(.data) /* all .data sections */
  161. _edata = .; /* define a global symbol marking the end of the .data section */
  162. } >ram AT >flash /* put all the above into RAM (but load the LMA copy into FLASH) */
  163. .bss : /* collect all uninitialized .bss sections that go into RAM */
  164. {
  165. _bss_start = .; /* define a global symbol marking the start of the .bss section */
  166. *(.bss) /* all .bss sections */
  167. } >ram /* put all the above in RAM (it will be cleared in the startup code */
  168. . = ALIGN(4); /* advance location counter to the next 32-bit boundary */
  169. _bss_end = . ; /* define a global symbol marking the end of the .bss section */
  170. }
  171. _end = .; /* define a global symbol marking the end of application RAM */