1
0

startup_ACM32F4_gcc.s 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344
  1. /*********************** (C) COPYRIGHT 2020 Aisinochip *************************
  2. ;* File Name : Startup_ACM32F4.s
  3. ;* Author : AisinoChip Firmware Team
  4. ;* Version : V1.0.0
  5. ;* Date : 2020
  6. ;* Description : ACM32F4 Devices vector table for GCC toolchain.
  7. ;* This module performs:
  8. ;* - Set the initial SP
  9. ;* - Set the initial PC == Reset_Handler
  10. ;* - Set the vector table entries with the exceptions ISR address
  11. ;* - Configure the clock system
  12. ;* - Branches to __main in the C library (which eventually
  13. ;* calls main()).
  14. ;* After Reset the Cortex-M33 processor is in Thread mode,
  15. ;* priority is Privileged, and the Stack is set to Main.
  16. ;********************************************************************************
  17. ;* @attention
  18. ;*
  19. ;* Copyright (c) 2020 AisinoChip.
  20. ;* All rights reserved.
  21. ;*******************************************************************************/
  22. .syntax unified
  23. .cpu cortex-m33
  24. .fpu softvfp
  25. .thumb
  26. .global g_pfnVectors
  27. .global Default_Handler
  28. /* start address for the initialization values of the .data section.
  29. defined in linker script */
  30. .word _sidata
  31. /* start address for the .data section. defined in linker script */
  32. .word _sdata
  33. /* end address for the .data section. defined in linker script */
  34. .word _edata
  35. /* start address for the .bss section. defined in linker script */
  36. .word _sbss
  37. /* end address for the .bss section. defined in linker script */
  38. .word _ebss
  39. /*.equ BootRAM, 0xF108F85F */
  40. /**
  41. * @brief This is the code that gets called when the processor first
  42. * starts execution following a reset event. Only the absolutely
  43. * necessary set is performed, after which the application
  44. * supplied main() routine is called.
  45. * @param None
  46. * @retval : None
  47. */
  48. .section .text.Reset_Handler
  49. .weak Reset_Handler
  50. .type Reset_Handler, %function
  51. Reset_Handler:
  52. /* Copy the data segment initializers from flash to SRAM */
  53. movs r1, #0
  54. b LoopCopyDataInit
  55. CopyDataInit:
  56. ldr r3, =_sidata
  57. ldr r3, [r3, r1]
  58. str r3, [r0, r1]
  59. adds r1, r1, #4
  60. LoopCopyDataInit:
  61. ldr r0, =_sdata
  62. ldr r3, =_edata
  63. adds r2, r0, r1
  64. cmp r2, r3
  65. bcc CopyDataInit
  66. ldr r2, =_sbss
  67. b LoopFillZerobss
  68. /* Zero fill the bss segment. */
  69. FillZerobss:
  70. movs r3, #0
  71. str r3, [r2], #4
  72. LoopFillZerobss:
  73. ldr r3, = _ebss
  74. cmp r2, r3
  75. bcc FillZerobss
  76. /* Call the clock system intitialization function.*/
  77. /* bl SystemInit */
  78. /* Call static constructors */
  79. /* bl __libc_init_array */
  80. /* Call the application's entry point.*/
  81. bl entry
  82. bx lr
  83. .size Reset_Handler, .-Reset_Handler
  84. /**
  85. * @brief This is the code that gets called when the processor receives an
  86. * unexpected interrupt. This simply enters an infinite loop, preserving
  87. * the system state for examination by a debugger.
  88. *
  89. * @param None
  90. * @retval : None
  91. */
  92. .section .text.Default_Handler,"ax",%progbits
  93. Default_Handler:
  94. Infinite_Loop:
  95. b Infinite_Loop
  96. .size Default_Handler, .-Default_Handler
  97. /******************************************************************************
  98. *
  99. * The minimal vector table for a Cortex M3. Note that the proper constructs
  100. * must be placed on this to ensure that it ends up at physical address
  101. * 0x0000.0000.
  102. *
  103. ******************************************************************************/
  104. .section .isr_vector,"a",%progbits
  105. .type g_pfnVectors, %object
  106. .size g_pfnVectors, .-g_pfnVectors
  107. g_pfnVectors:
  108. .word _estack
  109. .word Reset_Handler
  110. .word NMI_Handler
  111. .word HardFault_Handler
  112. .word MemManage_Handler
  113. .word BusFault_Handler
  114. .word UsageFault_Handler
  115. .word 0
  116. .word 0
  117. .word 0
  118. .word 0
  119. .word SVC_Handler
  120. .word DebugMon_Handler
  121. .word 0
  122. .word PendSV_Handler
  123. .word SysTick_Handler
  124. /* External Interrupts */
  125. .word WDT_IRQHandler
  126. .word RTC_IRQHandler
  127. .word EFC_IRQHandler
  128. .word GPIOAB_IRQHandler
  129. .word GPIOCD_IRQHandler
  130. .word EXIT_IRQHandler
  131. .word SRAM_PAPITY_IRQHandler
  132. .word CLKRDY_IRQHandler
  133. .word UART4_IRQHandler
  134. .word DMA_IRQHandler
  135. .word UART3_IRQHandler
  136. .word RSV_IRQHandler
  137. .word ADC_IRQHandler
  138. .word TIM1_BRK_UP_TRG_COM_IRQHandler
  139. .word TIM1_CC_IRQHandler
  140. .word TIM2_IRQHandler
  141. .word TIM3_IRQHandler
  142. .word TIM6_IRQHandler
  143. .word TIM7_IRQHandler
  144. .word TIM14_IRQHandler
  145. .word TIM15_IRQHandler
  146. .word TIM16_IRQHandler
  147. .word TIM17_IRQHandler
  148. .word I2C1_IRQHandler
  149. .word I2C2_IRQHandler
  150. .word SPI1_IRQHandler
  151. .word SPI2_IRQHandler
  152. .word UART1_IRQHandler
  153. .word UART2_IRQHandler
  154. .word LPUART_IRQHandler
  155. .word SPI3_IRQHandler
  156. .word AES_IRQHandler
  157. .word USB_IRQHandler
  158. .word DAC_IRQHandler
  159. .word I2S_IRQHandler
  160. .word GPIOEF_IRQHandler
  161. .word CAN1_IRQHandler
  162. .word CAN2_IRQHandler
  163. .word FPU_IRQHandler
  164. .word TIM4_IRQHandler
  165. .word SPI4_IRQHandler
  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 WDT_IRQHandler
  192. .thumb_set WDT_IRQHandler,Default_Handler
  193. .weak RTC_IRQHandler
  194. .thumb_set RTC_IRQHandler,Default_Handler
  195. .weak EFC_IRQHandler
  196. .thumb_set EFC_IRQHandler,Default_Handler
  197. .weak GPIOAB_IRQHandler
  198. .thumb_set GPIOAB_IRQHandler,Default_Handler
  199. .weak GPIOCD_IRQHandler
  200. .thumb_set GPIOCD_IRQHandler,Default_Handler
  201. .weak EXIT_IRQHandler
  202. .thumb_set EXIT_IRQHandler,Default_Handler
  203. .weak SRAM_PAPITY_IRQHandler
  204. .thumb_set SRAM_PAPITY_IRQHandler,Default_Handler
  205. .weak CLKRDY_IRQHandler
  206. .thumb_set CLKRDY_IRQHandler,Default_Handler
  207. .weak UART4_IRQHandler
  208. .thumb_set UART4_IRQHandler,Default_Handler
  209. .weak DMA_IRQHandler
  210. .thumb_set DMA_IRQHandler,Default_Handler
  211. .weak UART3_IRQHandler
  212. .thumb_set UART3_IRQHandler,Default_Handler
  213. .weak RSV_IRQHandler
  214. .thumb_set RSV_IRQHandler,Default_Handler
  215. .weak ADC_IRQHandler
  216. .thumb_set ADC_IRQHandler,Default_Handler
  217. .weak TIM1_BRK_UP_TRG_COM_IRQHandler
  218. .thumb_set TIM1_BRK_UP_TRG_COM_IRQHandler,Default_Handler
  219. .weak TIM1_CC_IRQHandler
  220. .thumb_set TIM1_CC_IRQHandler,Default_Handler
  221. .weak TIM2_IRQHandler
  222. .thumb_set TIM2_IRQHandler,Default_Handler
  223. .weak TIM3_IRQHandler
  224. .thumb_set TIM3_IRQHandler,Default_Handler
  225. .weak TIM6_IRQHandler
  226. .thumb_set TIM6_IRQHandler,Default_Handler
  227. .weak TIM7_IRQHandler
  228. .thumb_set TIM7_IRQHandler,Default_Handler
  229. .weak TIM14_IRQHandler
  230. .thumb_set TIM14_IRQHandler,Default_Handler
  231. .weak TIM15_IRQHandler
  232. .thumb_set TIM15_IRQHandler,Default_Handler
  233. .weak TIM16_IRQHandler
  234. .thumb_set TIM16_IRQHandler,Default_Handler
  235. .weak TIM17_IRQHandler
  236. .thumb_set TIM17_IRQHandler,Default_Handler
  237. .weak I2C1_IRQHandler
  238. .thumb_set I2C1_IRQHandler,Default_Handler
  239. .weak I2C2_IRQHandler
  240. .thumb_set I2C2_IRQHandler,Default_Handler
  241. .weak SPI1_IRQHandler
  242. .thumb_set SPI1_IRQHandler,Default_Handler
  243. .weak SPI2_IRQHandler
  244. .thumb_set SPI2_IRQHandler,Default_Handler
  245. .weak UART1_IRQHandler
  246. .thumb_set UART1_IRQHandler,Default_Handler
  247. .weak UART2_IRQHandler
  248. .thumb_set UART2_IRQHandler,Default_Handler
  249. .weak LPUART_IRQHandler
  250. .thumb_set LPUART_IRQHandler,Default_Handler
  251. .weak SPI3_IRQHandler
  252. .thumb_set SPI3_IRQHandler,Default_Handler
  253. .weak AES_IRQHandler
  254. .thumb_set AES_IRQHandler,Default_Handler
  255. .weak USB_IRQHandler
  256. .thumb_set USB_IRQHandler,Default_Handler
  257. .weak DAC_IRQHandler
  258. .thumb_set DAC_IRQHandler,Default_Handler
  259. .weak I2S_IRQHandler
  260. .thumb_set I2S_IRQHandler,Default_Handler
  261. .weak GPIOEF_IRQHandler
  262. .thumb_set GPIOEF_IRQHandler,Default_Handler
  263. .weak CAN1_IRQHandler
  264. .thumb_set CAN1_IRQHandler,Default_Handler
  265. .weak CAN2_IRQHandler
  266. .thumb_set CAN2_IRQHandler,Default_Handler
  267. .weak FPU_IRQHandler
  268. .thumb_set FPU_IRQHandler,Default_Handler
  269. .weak TIM4_IRQHandler
  270. .thumb_set TIM4_IRQHandler,Default_Handler
  271. .weak SPI4_IRQHandler
  272. .thumb_set SPI4_IRQHandler,Default_Handler