startup_stm32f101x6.s 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  1. /**
  2. *************** (C) COPYRIGHT 2017 STMicroelectronics ************************
  3. * @file startup_stm32f101x6.s
  4. * @author MCD Application Team
  5. * @brief STM32F101x6 Devices vector table for Atollic toolchain.
  6. * This module performs:
  7. * - Set the initial SP
  8. * - Set the initial PC == Reset_Handler,
  9. * - Set the vector table entries with the exceptions ISR address
  10. * - Configure the clock system
  11. * - Branches to main in the C library (which eventually
  12. * calls main()).
  13. * After Reset the Cortex-M3 processor is in Thread mode,
  14. * priority is Privileged, and the Stack is set to Main.
  15. ******************************************************************************
  16. * @attention
  17. *
  18. * Copyright (c) 2017-2021 STMicroelectronics.
  19. * All rights reserved.
  20. *
  21. * This software is licensed under terms that can be found in the LICENSE file
  22. * in the root directory of this software component.
  23. * If no LICENSE file comes with this software, it is provided AS-IS.
  24. *
  25. ******************************************************************************
  26. */
  27. .syntax unified
  28. .cpu cortex-m3
  29. .fpu softvfp
  30. .thumb
  31. .global g_pfnVectors
  32. .global Default_Handler
  33. /* start address for the initialization values of the .data section.
  34. defined in linker script */
  35. .word _sidata
  36. /* start address for the .data section. defined in linker script */
  37. .word _sdata
  38. /* end address for the .data section. defined in linker script */
  39. .word _edata
  40. /* start address for the .bss section. defined in linker script */
  41. .word _sbss
  42. /* end address for the .bss section. defined in linker script */
  43. .word _ebss
  44. .equ BootRAM, 0xF108F85F
  45. /**
  46. * @brief This is the code that gets called when the processor first
  47. * starts execution following a reset event. Only the absolutely
  48. * necessary set is performed, after which the application
  49. * supplied main() routine is called.
  50. * @param None
  51. * @retval : None
  52. */
  53. .section .text.Reset_Handler
  54. .weak Reset_Handler
  55. .type Reset_Handler, %function
  56. Reset_Handler:
  57. /* Call the clock system initialization function.*/
  58. bl SystemInit
  59. /* Copy the data segment initializers from flash to SRAM */
  60. ldr r0, =_sdata
  61. ldr r1, =_edata
  62. ldr r2, =_sidata
  63. movs r3, #0
  64. b LoopCopyDataInit
  65. CopyDataInit:
  66. ldr r4, [r2, r3]
  67. str r4, [r0, r3]
  68. adds r3, r3, #4
  69. LoopCopyDataInit:
  70. adds r4, r0, r3
  71. cmp r4, r1
  72. bcc CopyDataInit
  73. /* Zero fill the bss segment. */
  74. ldr r2, =_sbss
  75. ldr r4, =_ebss
  76. movs r3, #0
  77. b LoopFillZerobss
  78. FillZerobss:
  79. str r3, [r2]
  80. adds r2, r2, #4
  81. LoopFillZerobss:
  82. cmp r2, r4
  83. bcc FillZerobss
  84. /* Call static constructors */
  85. bl __libc_init_array
  86. /* Call the application's entry point.*/
  87. bl main
  88. bx lr
  89. .size Reset_Handler, .-Reset_Handler
  90. /**
  91. * @brief This is the code that gets called when the processor receives an
  92. * unexpected interrupt. This simply enters an infinite loop, preserving
  93. * the system state for examination by a debugger.
  94. *
  95. * @param None
  96. * @retval : None
  97. */
  98. .section .text.Default_Handler,"ax",%progbits
  99. Default_Handler:
  100. Infinite_Loop:
  101. b Infinite_Loop
  102. .size Default_Handler, .-Default_Handler
  103. /******************************************************************************
  104. *
  105. * The minimal vector table for a Cortex M3. Note that the proper constructs
  106. * must be placed on this to ensure that it ends up at physical address
  107. * 0x0000.0000.
  108. *
  109. ******************************************************************************/
  110. .section .isr_vector,"a",%progbits
  111. .type g_pfnVectors, %object
  112. .size g_pfnVectors, .-g_pfnVectors
  113. g_pfnVectors:
  114. .word _estack
  115. .word Reset_Handler
  116. .word NMI_Handler
  117. .word HardFault_Handler
  118. .word MemManage_Handler
  119. .word BusFault_Handler
  120. .word UsageFault_Handler
  121. .word 0
  122. .word 0
  123. .word 0
  124. .word 0
  125. .word SVC_Handler
  126. .word DebugMon_Handler
  127. .word 0
  128. .word PendSV_Handler
  129. .word SysTick_Handler
  130. .word WWDG_IRQHandler
  131. .word PVD_IRQHandler
  132. .word TAMPER_IRQHandler
  133. .word RTC_IRQHandler
  134. .word FLASH_IRQHandler
  135. .word RCC_IRQHandler
  136. .word EXTI0_IRQHandler
  137. .word EXTI1_IRQHandler
  138. .word EXTI2_IRQHandler
  139. .word EXTI3_IRQHandler
  140. .word EXTI4_IRQHandler
  141. .word DMA1_Channel1_IRQHandler
  142. .word DMA1_Channel2_IRQHandler
  143. .word DMA1_Channel3_IRQHandler
  144. .word DMA1_Channel4_IRQHandler
  145. .word DMA1_Channel5_IRQHandler
  146. .word DMA1_Channel6_IRQHandler
  147. .word DMA1_Channel7_IRQHandler
  148. .word ADC1_IRQHandler
  149. .word 0
  150. .word 0
  151. .word 0
  152. .word 0
  153. .word EXTI9_5_IRQHandler
  154. .word 0
  155. .word 0
  156. .word 0
  157. .word 0
  158. .word TIM2_IRQHandler
  159. .word TIM3_IRQHandler
  160. .word 0
  161. .word I2C1_EV_IRQHandler
  162. .word I2C1_ER_IRQHandler
  163. .word 0
  164. .word 0
  165. .word SPI1_IRQHandler
  166. .word 0
  167. .word USART1_IRQHandler
  168. .word USART2_IRQHandler
  169. .word 0
  170. .word EXTI15_10_IRQHandler
  171. .word RTC_Alarm_IRQHandler
  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 BootRAM /* @0x108. This is for boot in RAM mode for
  181. STM32F10x Low Density devices.*/
  182. /*******************************************************************************
  183. *
  184. * Provide weak aliases for each Exception handler to the Default_Handler.
  185. * As they are weak aliases, any function with the same name will override
  186. * this definition.
  187. *
  188. *******************************************************************************/
  189. .weak NMI_Handler
  190. .thumb_set NMI_Handler,Default_Handler
  191. .weak HardFault_Handler
  192. .thumb_set HardFault_Handler,Default_Handler
  193. .weak MemManage_Handler
  194. .thumb_set MemManage_Handler,Default_Handler
  195. .weak BusFault_Handler
  196. .thumb_set BusFault_Handler,Default_Handler
  197. .weak UsageFault_Handler
  198. .thumb_set UsageFault_Handler,Default_Handler
  199. .weak SVC_Handler
  200. .thumb_set SVC_Handler,Default_Handler
  201. .weak DebugMon_Handler
  202. .thumb_set DebugMon_Handler,Default_Handler
  203. .weak PendSV_Handler
  204. .thumb_set PendSV_Handler,Default_Handler
  205. .weak SysTick_Handler
  206. .thumb_set SysTick_Handler,Default_Handler
  207. .weak WWDG_IRQHandler
  208. .thumb_set WWDG_IRQHandler,Default_Handler
  209. .weak PVD_IRQHandler
  210. .thumb_set PVD_IRQHandler,Default_Handler
  211. .weak TAMPER_IRQHandler
  212. .thumb_set TAMPER_IRQHandler,Default_Handler
  213. .weak RTC_IRQHandler
  214. .thumb_set RTC_IRQHandler,Default_Handler
  215. .weak FLASH_IRQHandler
  216. .thumb_set FLASH_IRQHandler,Default_Handler
  217. .weak RCC_IRQHandler
  218. .thumb_set RCC_IRQHandler,Default_Handler
  219. .weak EXTI0_IRQHandler
  220. .thumb_set EXTI0_IRQHandler,Default_Handler
  221. .weak EXTI1_IRQHandler
  222. .thumb_set EXTI1_IRQHandler,Default_Handler
  223. .weak EXTI2_IRQHandler
  224. .thumb_set EXTI2_IRQHandler,Default_Handler
  225. .weak EXTI3_IRQHandler
  226. .thumb_set EXTI3_IRQHandler,Default_Handler
  227. .weak EXTI4_IRQHandler
  228. .thumb_set EXTI4_IRQHandler,Default_Handler
  229. .weak DMA1_Channel1_IRQHandler
  230. .thumb_set DMA1_Channel1_IRQHandler,Default_Handler
  231. .weak DMA1_Channel2_IRQHandler
  232. .thumb_set DMA1_Channel2_IRQHandler,Default_Handler
  233. .weak DMA1_Channel3_IRQHandler
  234. .thumb_set DMA1_Channel3_IRQHandler,Default_Handler
  235. .weak DMA1_Channel4_IRQHandler
  236. .thumb_set DMA1_Channel4_IRQHandler,Default_Handler
  237. .weak DMA1_Channel5_IRQHandler
  238. .thumb_set DMA1_Channel5_IRQHandler,Default_Handler
  239. .weak DMA1_Channel6_IRQHandler
  240. .thumb_set DMA1_Channel6_IRQHandler,Default_Handler
  241. .weak DMA1_Channel7_IRQHandler
  242. .thumb_set DMA1_Channel7_IRQHandler,Default_Handler
  243. .weak ADC1_IRQHandler
  244. .thumb_set ADC1_IRQHandler,Default_Handler
  245. .weak EXTI9_5_IRQHandler
  246. .thumb_set EXTI9_5_IRQHandler,Default_Handler
  247. .weak TIM2_IRQHandler
  248. .thumb_set TIM2_IRQHandler,Default_Handler
  249. .weak TIM3_IRQHandler
  250. .thumb_set TIM3_IRQHandler,Default_Handler
  251. .weak I2C1_EV_IRQHandler
  252. .thumb_set I2C1_EV_IRQHandler,Default_Handler
  253. .weak I2C1_ER_IRQHandler
  254. .thumb_set I2C1_ER_IRQHandler,Default_Handler
  255. .weak SPI1_IRQHandler
  256. .thumb_set SPI1_IRQHandler,Default_Handler
  257. .weak USART1_IRQHandler
  258. .thumb_set USART1_IRQHandler,Default_Handler
  259. .weak USART2_IRQHandler
  260. .thumb_set USART2_IRQHandler,Default_Handler
  261. .weak EXTI15_10_IRQHandler
  262. .thumb_set EXTI15_10_IRQHandler,Default_Handler
  263. .weak RTC_Alarm_IRQHandler
  264. .thumb_set RTC_Alarm_IRQHandler,Default_Handler