You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

startup_MK20D5.s 10KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. /* File: startup_MK20D5.s
  2. * Purpose: startup file for Cortex-M4 devices. Should use with
  3. * GCC for ARM Embedded Processors
  4. * Version: V1.3
  5. * Date: 08 Feb 2012
  6. *
  7. * Copyright (c) 2012, ARM Limited
  8. * All rights reserved.
  9. *
  10. * Redistribution and use in source and binary forms, with or without
  11. * modification, are permitted provided that the following conditions are met:
  12. * Redistributions of source code must retain the above copyright
  13. notice, this list of conditions and the following disclaimer.
  14. * Redistributions in binary form must reproduce the above copyright
  15. notice, this list of conditions and the following disclaimer in the
  16. documentation and/or other materials provided with the distribution.
  17. * Neither the name of the ARM Limited nor the
  18. names of its contributors may be used to endorse or promote products
  19. derived from this software without specific prior written permission.
  20. *
  21. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  22. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  23. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  24. * DISCLAIMED. IN NO EVENT SHALL ARM LIMITED BE LIABLE FOR ANY
  25. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  26. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  27. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  28. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  29. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  30. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  31. */
  32. .syntax unified
  33. .arch armv7-m
  34. .section .stack
  35. .align 3
  36. #ifdef __STACK_SIZE
  37. .equ Stack_Size, __STACK_SIZE
  38. #else
  39. .equ Stack_Size, 0x400
  40. #endif
  41. .globl __StackTop
  42. .globl __StackLimit
  43. __StackLimit:
  44. .space Stack_Size
  45. .size __StackLimit, . - __StackLimit
  46. __StackTop:
  47. .size __StackTop, . - __StackTop
  48. .section .heap
  49. .align 3
  50. #ifdef __HEAP_SIZE
  51. .equ Heap_Size, __HEAP_SIZE
  52. #else
  53. .equ Heap_Size, 0xC00
  54. #endif
  55. .globl __HeapBase
  56. .globl __HeapLimit
  57. __HeapBase:
  58. .if Heap_Size
  59. .space Heap_Size
  60. .endif
  61. .size __HeapBase, . - __HeapBase
  62. __HeapLimit:
  63. .size __HeapLimit, . - __HeapLimit
  64. .section .isr_vector
  65. .align 2
  66. .globl __isr_vector
  67. __isr_vector:
  68. .long __StackTop /* Top of Stack */
  69. .long Reset_Handler /* Reset Handler */
  70. .long NMI_Handler /* NMI Handler */
  71. .long HardFault_Handler /* Hard Fault Handler */
  72. .long MemManage_Handler /* MPU Fault Handler */
  73. .long BusFault_Handler /* Bus Fault Handler */
  74. .long UsageFault_Handler /* Usage Fault Handler */
  75. .long 0 /* Reserved */
  76. .long 0 /* Reserved */
  77. .long 0 /* Reserved */
  78. .long 0 /* Reserved */
  79. .long SVC_Handler /* SVCall Handler */
  80. .long DebugMon_Handler /* Debug Monitor Handler */
  81. .long 0 /* Reserved */
  82. .long PendSV_Handler /* PendSV Handler */
  83. .long SysTick_Handler /* SysTick Handler */
  84. /* External interrupts */
  85. .long DMA0_IRQHandler /* 0: Watchdog Timer */
  86. .long DMA1_IRQHandler /* 1: Real Time Clock */
  87. .long DMA2_IRQHandler /* 2: Timer0 / Timer1 */
  88. .long DMA3_IRQHandler /* 3: Timer2 / Timer3 */
  89. .long DMA_Error_IRQHandler /* 4: MCIa */
  90. .long 0 /* 5: MCIb */
  91. .long FTFL_IRQHandler /* 6: UART0 - DUT FPGA */
  92. .long Read_Collision_IRQHandler /* 7: UART1 - DUT FPGA */
  93. .long LVD_LVW_IRQHandler /* 8: UART2 - DUT FPGA */
  94. .long LLW_IRQHandler /* 9: UART4 - not connected */
  95. .long Watchdog_IRQHandler /* 10: AACI / AC97 */
  96. .long I2C0_IRQHandler /* 11: CLCD Combined Interrupt */
  97. .long SPI0_IRQHandler /* 12: Ethernet */
  98. .long I2S0_Tx_IRQHandler /* 13: USB Device */
  99. .long I2S0_Rx_IRQHandler /* 14: USB Host Controller */
  100. .long UART0_LON_IRQHandler /* 15: Character LCD */
  101. .long UART0_RX_TX_IRQHandler /* 16: Flexray */
  102. .long UART0_ERR_IRQHandler /* 17: CAN */
  103. .long UART1_RX_TX_IRQHandler /* 18: LIN */
  104. .long UART1_ERR_IRQHandler /* 19: I2C ADC/DAC */
  105. .long UART2_RX_TX_IRQHandler /* 20: Reserved */
  106. .long UART2_ERR_IRQHandler /* 21: Reserved */
  107. .long ADC0_IRQHandler /* 22: Reserved */
  108. .long CMP0_IRQHandler /* 23: Reserved */
  109. .long CMP1_IRQHandler /* 24: Reserved */
  110. .long FTM0_IRQHandler /* 25: Reserved */
  111. .long FTM1_IRQHandler /* 26: Reserved */
  112. .long CMT_IRQHandler /* 27: Reserved */
  113. .long RTC_IRQHandler /* 28: Reserved - CPU FPGA CLCD */
  114. .long RTC_Seconds_IRQHandler /* 29: Reserved - CPU FPGA */
  115. .long PIT0_IRQHandler /* 30: UART3 - CPU FPGA */
  116. .long PIT1_IRQHandler /* 31: SPI Touchscreen - CPU FPGA */
  117. .long PIT2_IRQHandler
  118. .long PIT3_IRQHandler
  119. .long PDB0_IRQHandler
  120. .long USB0_IRQHandler
  121. .long USBDCD_IRQHandler
  122. .long TSI0_IRQHandler
  123. .long MCG_IRQHandler
  124. .long LPTimer_IRQHandler
  125. .long PORTA_IRQHandler
  126. .long PORTB_IRQHandler
  127. .long PORTC_IRQHandler
  128. .long PORTD_IRQHandler
  129. .long PORTE_IRQHandler
  130. .long SWI_IRQHandler
  131. .size __isr_vector, . - __isr_vector
  132. .section .text.Reset_Handler
  133. .thumb
  134. .thumb_func
  135. .align 2
  136. .globl Reset_Handler
  137. .type Reset_Handler, %function
  138. Reset_Handler:
  139. /* Loop to copy data from read only memory to RAM. The ranges
  140. * of copy from/to are specified by following symbols evaluated in
  141. * linker script.
  142. * __etext: End of code section, i.e., begin of data sections to copy from.
  143. * __data_start__/__data_end__: RAM address range that data should be
  144. * copied to. Both must be aligned to 4 bytes boundary. */
  145. ldr r0, =SystemInit
  146. blx r0
  147. ldr r1, =__etext
  148. ldr r2, =__data_start__
  149. ldr r3, =__data_end__
  150. .Lflash_to_ram_loop:
  151. cmp r2, r3
  152. ittt lt
  153. ldrlt r0, [r1], #4
  154. strlt r0, [r2], #4
  155. blt .Lflash_to_ram_loop
  156. .Lflash_to_ram_loop_end:
  157. ldr r0, =_start
  158. bx r0
  159. .pool
  160. .size Reset_Handler, . - Reset_Handler
  161. .text
  162. /* Macro to define default handlers. Default handler
  163. * will be weak symbol and just dead loops. They can be
  164. * overwritten by other handlers */
  165. .macro def_default_handler handler_name
  166. .align 1
  167. .thumb_func
  168. .weak \handler_name
  169. .type \handler_name, %function
  170. \handler_name :
  171. b .
  172. .size \handler_name, . - \handler_name
  173. .endm
  174. def_default_handler NMI_Handler
  175. def_default_handler HardFault_Handler
  176. def_default_handler MemManage_Handler
  177. def_default_handler BusFault_Handler
  178. def_default_handler UsageFault_Handler
  179. def_default_handler SVC_Handler
  180. def_default_handler DebugMon_Handler
  181. def_default_handler PendSV_Handler
  182. def_default_handler SysTick_Handler
  183. def_default_handler Default_Handler
  184. .macro def_irq_default_handler handler_name
  185. .weak \handler_name
  186. .set \handler_name, Default_Handler
  187. .endm
  188. def_irq_default_handler DMA0_IRQHandler
  189. def_irq_default_handler DMA1_IRQHandler
  190. def_irq_default_handler DMA2_IRQHandler
  191. def_irq_default_handler DMA3_IRQHandler
  192. def_irq_default_handler DMA_Error_IRQHandler
  193. def_irq_default_handler FTFL_IRQHandler
  194. def_irq_default_handler Read_Collision_IRQHandler
  195. def_irq_default_handler LVD_LVW_IRQHandler
  196. def_irq_default_handler LLW_IRQHandler
  197. def_irq_default_handler Watchdog_IRQHandler
  198. def_irq_default_handler I2C0_IRQHandler
  199. def_irq_default_handler SPI0_IRQHandler
  200. def_irq_default_handler I2S0_Tx_IRQHandler
  201. def_irq_default_handler I2S0_Rx_IRQHandler
  202. def_irq_default_handler UART0_LON_IRQHandler
  203. def_irq_default_handler UART0_RX_TX_IRQHandler
  204. def_irq_default_handler UART0_ERR_IRQHandler
  205. def_irq_default_handler UART1_RX_TX_IRQHandler
  206. def_irq_default_handler UART1_ERR_IRQHandler
  207. def_irq_default_handler UART2_RX_TX_IRQHandler
  208. def_irq_default_handler UART2_ERR_IRQHandler
  209. def_irq_default_handler ADC0_IRQHandler
  210. def_irq_default_handler CMP0_IRQHandler
  211. def_irq_default_handler CMP1_IRQHandler
  212. def_irq_default_handler FTM0_IRQHandler
  213. def_irq_default_handler FTM1_IRQHandler
  214. def_irq_default_handler CMT_IRQHandler
  215. def_irq_default_handler RTC_IRQHandler
  216. def_irq_default_handler RTC_Seconds_IRQHandler
  217. def_irq_default_handler PIT0_IRQHandler
  218. def_irq_default_handler PIT1_IRQHandler
  219. def_irq_default_handler PIT2_IRQHandler
  220. def_irq_default_handler PIT3_IRQHandler
  221. def_irq_default_handler PDB0_IRQHandler
  222. def_irq_default_handler USB0_IRQHandler
  223. def_irq_default_handler USBDCD_IRQHandler
  224. def_irq_default_handler TSI0_IRQHandler
  225. def_irq_default_handler MCG_IRQHandler
  226. def_irq_default_handler LPTimer_IRQHandler
  227. def_irq_default_handler PORTA_IRQHandler
  228. def_irq_default_handler PORTB_IRQHandler
  229. def_irq_default_handler PORTC_IRQHandler
  230. def_irq_default_handler PORTD_IRQHandler
  231. def_irq_default_handler PORTE_IRQHandler
  232. def_irq_default_handler SWI_IRQHandler
  233. def_irq_default_handler DEF_IRQHandler
  234. /* Flash protection region, placed at 0x400 */
  235. .text
  236. .thumb
  237. .align 2
  238. .section .kinetis_flash_config_field,"a",%progbits
  239. kinetis_flash_config:
  240. .long 0xffffffff
  241. .long 0xffffffff
  242. .long 0xffffffff
  243. .long 0xfffffffe
  244. .end