start.S 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  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-m3
  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. /**
  26. * @brief This is the code that gets called when the processor first
  27. * starts execution following a reset event. Only the absolutely
  28. * necessary set is performed, after which the application
  29. * supplied main() routine is called.
  30. * @param None
  31. * @retval : None
  32. */
  33. .section .text.Reset_Handler
  34. .weak Reset_Handler
  35. .type Reset_Handler, %function
  36. Reset_Handler:
  37. /* Copy the data segment initializers from flash to SRAM */
  38. /* LDR A2, $C$CON1
  39. MOVS A1, #255
  40. STR A1, [A2, #28]
  41. LDR A1, [A2, #0]
  42. ORR A1, A1, #1
  43. STR A1, [A2, #0]*/
  44. /* uneeded below? */
  45. movs r1, #0
  46. b LoopCopyDataInit
  47. CopyDataInit:
  48. ldr r3, =_sidata
  49. ldr r3, [r3, r1]
  50. str r3, [r0, r1]
  51. adds r1, r1, #4
  52. LoopCopyDataInit:
  53. ldr r0, =_sdata
  54. ldr r3, =_edata
  55. adds r2, r0, r1
  56. cmp r2, r3
  57. bcc CopyDataInit
  58. ldr r2, =_sbss
  59. b LoopFillZerobss
  60. /* Zero fill the bss segment. */
  61. FillZerobss:
  62. movs r3, #0
  63. str r3, [r2]
  64. adds r2, r2, #4
  65. LoopFillZerobss:
  66. ldr r3, = _ebss
  67. cmp r2, r3
  68. bcc FillZerobss
  69. /* Call the clock system intitialization function.*/
  70. bl SystemInit
  71. /* Call static constructors */
  72. bl __libc_init_array
  73. /* Call the application's entry point.*/
  74. bl main
  75. LoopForever:
  76. b LoopForever
  77. .size Reset_Handler, .-Reset_Handler
  78. /**
  79. * @brief This is the code that gets called when the processor receives an
  80. * unexpected interrupt. This simply enters an infinite loop, preserving
  81. * the system state for examination by a debugger.
  82. *
  83. * @param None
  84. * @retval : None
  85. */
  86. .section .text.Default_Handler,"ax",%progbits
  87. Default_Handler:
  88. Infinite_Loop:
  89. b Infinite_Loop
  90. .size Default_Handler, .-Default_Handler
  91. /******************************************************************************
  92. *
  93. * The minimal vector table for a Cortex-M. Note that the proper constructs
  94. * must be placed on this to ensure that it ends up at physical address
  95. * 0x0000.0000.
  96. *
  97. ******************************************************************************/
  98. .section .isr_vector,"a",%progbits
  99. .type g_pfnVectors, %object
  100. .size g_pfnVectors, .-g_pfnVectors
  101. g_pfnVectors:
  102. .word _estack
  103. .word Reset_Handler
  104. .word NMI_Handler
  105. .word HardFault_Handler
  106. .word MemManage_Handler
  107. .word BusFault_Handler
  108. .word UsageFault_Handler
  109. .word 0
  110. .word 0
  111. .word 0
  112. .word 0
  113. .word SVC_Handler
  114. .word DebugMon_Handler
  115. .word 0
  116. .word PendSV_Handler
  117. .word SysTick_Handler
  118. .word Default_Handler
  119. .word Default_Handler
  120. .word Default_Handler
  121. .word Default_Handler
  122. .word 0
  123. .word Default_Handler
  124. .word Default_Handler
  125. .word Default_Handler
  126. .word Default_Handler
  127. .word 0
  128. .word 0
  129. .word 0
  130. .word 0
  131. .word 0
  132. .word Default_Handler
  133. .word 0
  134. .word 0
  135. .word 0
  136. .word Default_Handler
  137. .word Default_Handler
  138. .word Default_Handler
  139. .word Default_Handler
  140. .word Default_Handler
  141. .word Default_Handler
  142. .word Default_Handler
  143. .word Default_Handler
  144. .word Default_Handler
  145. .word Default_Handler
  146. .word Default_Handler
  147. .word Default_Handler
  148. .word Default_Handler
  149. .word Default_Handler
  150. .word Default_Handler
  151. .word Default_Handler
  152. .word Default_Handler
  153. .word Default_Handler
  154. .word Default_Handler
  155. .word 0
  156. .word 0
  157. .word 0
  158. .word 0
  159. .word 0
  160. .word 0
  161. .word 0
  162. .word Default_Handler
  163. .word 0
  164. .word Default_Handler
  165. .word Default_Handler
  166. /*******************************************************************************
  167. *
  168. * Provide weak aliases for each Exception handler to the Default_Handler.
  169. * As they are weak aliases, any function with the same name will override
  170. * this definition.
  171. *
  172. *******************************************************************************/
  173. .weak NMI_Handler
  174. .thumb_set NMI_Handler,Default_Handler
  175. .weak HardFault_Handler
  176. .thumb_set HardFault_Handler,Default_Handler
  177. .weak MemManage_Handler
  178. .thumb_set MemManage_Handler,Default_Handler
  179. .weak BusFault_Handler
  180. .thumb_set BusFault_Handler,Default_Handler
  181. .weak UsageFault_Handler
  182. .thumb_set UsageFault_Handler,Default_Handler
  183. .weak SVC_Handler
  184. .thumb_set SVC_Handler,Default_Handler
  185. .weak DebugMon_Handler
  186. .thumb_set DebugMon_Handler,Default_Handler
  187. .weak PendSV_Handler
  188. .thumb_set PendSV_Handler,Default_Handler
  189. .weak SysTick_Handler
  190. .thumb_set SysTick_Handler,Default_Handler
  191. .weak SystemInit
  192. /************************ (C) COPYRIGHT Ac6 *****END OF FILE****/