stm32f0_startup.S 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. /**
  2. ******************************************************************************
  3. * @file startup_stm32.s
  4. * @author Ac6
  5. * @version V1.0.0
  6. * @date 12-June-2014
  7. ******************************************************************************
  8. */
  9. .syntax unified
  10. .cpu cortex-m0
  11. .thumb
  12. .global g_pfnVectors
  13. .global Default_Handler
  14. /* start address for the initialization values of the .data section.
  15. defined in linker script */
  16. .word _sidata
  17. /* start address for the .data section. defined in linker script */
  18. .word _sdata
  19. /* end address for the .data section. defined in linker script */
  20. .word _edata
  21. /* start address for the .bss section. defined in linker script */
  22. .word _sbss
  23. /* end address for the .bss section. defined in linker script */
  24. .word _ebss
  25. .equ BootRAM, 0xF1E0F85F
  26. /**
  27. * @brief This is the code that gets called when the processor first
  28. * starts execution following a reset event. Only the absolutely
  29. * necessary set is performed, after which the application
  30. * supplied main() routine is called.
  31. * @param None
  32. * @retval : None
  33. */
  34. .section .text.Reset_Handler
  35. .weak Reset_Handler
  36. .type Reset_Handler, %function
  37. Reset_Handler:
  38. /* Copy the data segment initializers from flash to SRAM */
  39. movs r1, #0
  40. b LoopCopyDataInit
  41. CopyDataInit:
  42. ldr r3, =_sidata
  43. ldr r3, [r3, r1]
  44. str r3, [r0, r1]
  45. adds r1, r1, #4
  46. LoopCopyDataInit:
  47. ldr r0, =_sdata
  48. ldr r3, =_edata
  49. adds r2, r0, r1
  50. cmp r2, r3
  51. bcc CopyDataInit
  52. ldr r2, =_sbss
  53. b LoopFillZerobss
  54. /* Zero fill the bss segment. */
  55. FillZerobss:
  56. movs r3, #0
  57. str r3, [r2]
  58. adds r2, r2, #4
  59. LoopFillZerobss:
  60. ldr r3, = _ebss
  61. cmp r2, r3
  62. bcc FillZerobss
  63. /* Call the clock system intitialization function.*/
  64. bl SystemInit
  65. /* Call static constructors */
  66. bl __libc_init_array
  67. /* Call the application's entry point.*/
  68. bl main
  69. LoopForever:
  70. b LoopForever
  71. .size Reset_Handler, .-Reset_Handler
  72. /**
  73. * @brief This is the code that gets called when the processor receives an
  74. * unexpected interrupt. This simply enters an infinite loop, preserving
  75. * the system state for examination by a debugger.
  76. *
  77. * @param None
  78. * @retval : None
  79. */
  80. .section .text.Default_Handler,"ax",%progbits
  81. Default_Handler:
  82. Infinite_Loop:
  83. b Infinite_Loop
  84. .size Default_Handler, .-Default_Handler
  85. /******************************************************************************
  86. *
  87. * The minimal vector table for a Cortex-M. Note that the proper constructs
  88. * must be placed on this to ensure that it ends up at physical address
  89. * 0x0000.0000.
  90. *
  91. ******************************************************************************/
  92. .section .isr_vector,"a",%progbits
  93. .type g_pfnVectors, %object
  94. .size g_pfnVectors, .-g_pfnVectors
  95. g_pfnVectors:
  96. .word _estack
  97. .word Reset_Handler
  98. .word NMI_Handler
  99. .word HardFault_Handler
  100. .word MemManage_Handler
  101. .word BusFault_Handler
  102. .word UsageFault_Handler
  103. .word 0
  104. .word 0
  105. .word 0
  106. .word 0
  107. .word SVC_Handler
  108. .word DebugMon_Handler
  109. .word 0
  110. .word PendSV_Handler
  111. .word SysTick_Handler
  112. .word 0
  113. .word 0
  114. .word 0
  115. .word 0
  116. .word 0
  117. .word 0
  118. .word 0
  119. .word 0
  120. .word 0
  121. .word 0
  122. .word 0
  123. .word 0
  124. .word 0
  125. .word 0
  126. .word 0
  127. .word 0
  128. .word 0
  129. .word 0
  130. .word 0
  131. .word 0
  132. .word 0
  133. .word 0
  134. .word 0
  135. .word 0
  136. .word 0
  137. .word 0
  138. .word 0
  139. .word 0
  140. .word 0
  141. .word 0
  142. .word 0
  143. .word 0
  144. .word 0
  145. .word 0
  146. .word 0
  147. .word 0
  148. .word 0
  149. .word 0
  150. .word 0
  151. .word 0
  152. .word 0
  153. .word 0
  154. .word 0
  155. .word 0
  156. .word 0
  157. .word 0
  158. .word 0
  159. .word 0
  160. .word 0
  161. .word 0
  162. .word 0
  163. .word 0
  164. .word 0
  165. .word 0
  166. .word 0
  167. .word 0
  168. .word 0
  169. .word 0
  170. .word 0
  171. .word 0
  172. .word 0
  173. .word 0
  174. .word 0
  175. .word 0
  176. .word 0
  177. .word 0
  178. .word 0
  179. .word 0
  180. .word 0
  181. .word 0
  182. .word 0
  183. .word 0
  184. .word 0
  185. .word 0
  186. .word 0
  187. .word 0
  188. .word 0
  189. .word 0
  190. .word 0
  191. .word 0
  192. .word 0
  193. .word 0
  194. /*******************************************************************************
  195. *
  196. * Provide weak aliases for each Exception handler to the Default_Handler.
  197. * As they are weak aliases, any function with the same name will override
  198. * this definition.
  199. *
  200. *******************************************************************************/
  201. .weak NMI_Handler
  202. .thumb_set NMI_Handler,Default_Handler
  203. .weak HardFault_Handler
  204. .thumb_set HardFault_Handler,Default_Handler
  205. .weak MemManage_Handler
  206. .thumb_set MemManage_Handler,Default_Handler
  207. .weak BusFault_Handler
  208. .thumb_set BusFault_Handler,Default_Handler
  209. .weak UsageFault_Handler
  210. .thumb_set UsageFault_Handler,Default_Handler
  211. .weak SVC_Handler
  212. .thumb_set SVC_Handler,Default_Handler
  213. .weak DebugMon_Handler
  214. .thumb_set DebugMon_Handler,Default_Handler
  215. .weak PendSV_Handler
  216. .thumb_set PendSV_Handler,Default_Handler
  217. .weak SysTick_Handler
  218. .thumb_set SysTick_Handler,Default_Handler
  219. .weak SystemInit
  220. /************************ (C) COPYRIGHT Ac6 *****END OF FILE****/