startup_stm32f2xx.s 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424
  1. ;******************** (C) COPYRIGHT 2012 STMicroelectronics ********************
  2. ;* File Name : startup_stm32f2xx.s
  3. ;* Author : MCD Application Team
  4. ;* Version : V1.1.5
  5. ;* Date : 31-December-2021
  6. ;* Description : STM32F2xx devices vector table for MDK-ARM 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 system clock and the external SRAM mounted on
  12. ;* STM322xG-EVAL board to be used as data memory (optional,
  13. ;* to be enabled by user)
  14. ;* - Branches to main in the C library (which eventually
  15. ;* calls main()).
  16. ;* After Reset the CortexM3 processor is in Thread mode,
  17. ;* priority is Privileged, and the Stack is set to Main.
  18. ;* <<< Use Configuration Wizard in Context Menu >>>
  19. ;*******************************************************************************
  20. ;
  21. ; Copyright (c) 2012 STMicroelectronics.
  22. ; All rights reserved.
  23. ;
  24. ; This software is licensed under terms that can be found in the LICENSE file
  25. ; in the root directory of this software component.
  26. ; If no LICENSE file comes with this software, it is provided AS-IS.
  27. ;
  28. ;*******************************************************************************
  29. ; Amount of memory (in bytes) allocated for Stack
  30. ; Tailor this value to your application needs
  31. ; <h> Stack Configuration
  32. ; <o> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>
  33. ; </h>
  34. Stack_Size EQU 0x0001000
  35. AREA STACK, NOINIT, READWRITE, ALIGN=3
  36. Stack_Mem SPACE Stack_Size
  37. __initial_sp ;EQU 0x20000000 + Stack_Size
  38. ; <h> Heap Configuration
  39. ; <o> Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
  40. ; </h>
  41. Heap_Size EQU 0x00002000
  42. AREA HEAP, NOINIT, READWRITE, ALIGN=3
  43. __heap_base
  44. Heap_Mem SPACE Heap_Size
  45. __heap_limit
  46. PRESERVE8
  47. THUMB
  48. ; Vector Table Mapped to Address 0 at Reset
  49. AREA RESET, DATA, READONLY
  50. EXPORT __Vectors
  51. EXPORT __Vectors_End
  52. EXPORT __Vectors_Size
  53. __Vectors DCD __initial_sp ; Top of Stack
  54. DCD Reset_Handler ; Reset Handler
  55. DCD NMI_Handler ; NMI Handler
  56. DCD HardFault_Handler ; Hard Fault Handler
  57. DCD MemManage_Handler ; MPU Fault Handler
  58. DCD BusFault_Handler ; Bus Fault Handler
  59. DCD UsageFault_Handler ; Usage Fault Handler
  60. DCD 0 ; Reserved
  61. DCD 0 ; Reserved
  62. DCD 0 ; Reserved
  63. DCD 0 ; Reserved
  64. DCD SVC_Handler ; SVCall Handler
  65. DCD DebugMon_Handler ; Debug Monitor Handler
  66. DCD 0 ; Reserved
  67. DCD PendSV_Handler ; PendSV Handler
  68. DCD SysTick_Handler ; SysTick Handler
  69. ; External Interrupts
  70. DCD WWDG_IRQHandler ; Window WatchDog
  71. DCD PVD_IRQHandler ; PVD through EXTI Line detection
  72. DCD TAMP_STAMP_IRQHandler ; Tamper and TimeStamps through the EXTI line
  73. DCD RTC_WKUP_IRQHandler ; RTC Wakeup through the EXTI line
  74. DCD FLASH_IRQHandler ; FLASH
  75. DCD RCC_IRQHandler ; RCC
  76. DCD EXTI0_IRQHandler ; EXTI Line0
  77. DCD EXTI1_IRQHandler ; EXTI Line1
  78. DCD EXTI2_IRQHandler ; EXTI Line2
  79. DCD EXTI3_IRQHandler ; EXTI Line3
  80. DCD EXTI4_IRQHandler ; EXTI Line4
  81. DCD DMA1_Stream0_IRQHandler ; DMA1 Stream 0
  82. DCD DMA1_Stream1_IRQHandler ; DMA1 Stream 1
  83. DCD DMA1_Stream2_IRQHandler ; DMA1 Stream 2
  84. DCD DMA1_Stream3_IRQHandler ; DMA1 Stream 3
  85. DCD DMA1_Stream4_IRQHandler ; DMA1 Stream 4
  86. DCD DMA1_Stream5_IRQHandler ; DMA1 Stream 5
  87. DCD DMA1_Stream6_IRQHandler ; DMA1 Stream 6
  88. DCD ADC_IRQHandler ; ADC1, ADC2 and ADC3s
  89. DCD CAN1_TX_IRQHandler ; CAN1 TX
  90. DCD CAN1_RX0_IRQHandler ; CAN1 RX0
  91. DCD CAN1_RX1_IRQHandler ; CAN1 RX1
  92. DCD CAN1_SCE_IRQHandler ; CAN1 SCE
  93. DCD EXTI9_5_IRQHandler ; External Line[9:5]s
  94. DCD TIM1_BRK_TIM9_IRQHandler ; TIM1 Break and TIM9
  95. DCD TIM1_UP_TIM10_IRQHandler ; TIM1 Update and TIM10
  96. DCD TIM1_TRG_COM_TIM11_IRQHandler ; TIM1 Trigger and Commutation and TIM11
  97. DCD TIM1_CC_IRQHandler ; TIM1 Capture Compare
  98. DCD TIM2_IRQHandler ; TIM2
  99. DCD TIM3_IRQHandler ; TIM3
  100. DCD TIM4_IRQHandler ; TIM4
  101. DCD I2C1_EV_IRQHandler ; I2C1 Event
  102. DCD I2C1_ER_IRQHandler ; I2C1 Error
  103. DCD I2C2_EV_IRQHandler ; I2C2 Event
  104. DCD I2C2_ER_IRQHandler ; I2C2 Error
  105. DCD SPI1_IRQHandler ; SPI1
  106. DCD SPI2_IRQHandler ; SPI2
  107. DCD USART1_IRQHandler ; USART1
  108. DCD USART2_IRQHandler ; USART2
  109. DCD USART3_IRQHandler ; USART3
  110. DCD EXTI15_10_IRQHandler ; External Line[15:10]s
  111. DCD RTC_Alarm_IRQHandler ; RTC Alarm (A and B) through EXTI Line
  112. DCD OTG_FS_WKUP_IRQHandler ; USB OTG FS Wakeup through EXTI line
  113. DCD TIM8_BRK_TIM12_IRQHandler ; TIM8 Break and TIM12
  114. DCD TIM8_UP_TIM13_IRQHandler ; TIM8 Update and TIM13
  115. DCD TIM8_TRG_COM_TIM14_IRQHandler ; TIM8 Trigger and Commutation and TIM14
  116. DCD TIM8_CC_IRQHandler ; TIM8 Capture Compare
  117. DCD DMA1_Stream7_IRQHandler ; DMA1 Stream7
  118. DCD FSMC_IRQHandler ; FSMC
  119. DCD SDIO_IRQHandler ; SDIO
  120. DCD TIM5_IRQHandler ; TIM5
  121. DCD SPI3_IRQHandler ; SPI3
  122. DCD UART4_IRQHandler ; UART4
  123. DCD UART5_IRQHandler ; UART5
  124. DCD TIM6_DAC_IRQHandler ; TIM6 and DAC1&2 underrun errors
  125. DCD TIM7_IRQHandler ; TIM7
  126. DCD DMA2_Stream0_IRQHandler ; DMA2 Stream 0
  127. DCD DMA2_Stream1_IRQHandler ; DMA2 Stream 1
  128. DCD DMA2_Stream2_IRQHandler ; DMA2 Stream 2
  129. DCD DMA2_Stream3_IRQHandler ; DMA2 Stream 3
  130. DCD DMA2_Stream4_IRQHandler ; DMA2 Stream 4
  131. DCD ETH_IRQHandler ; Ethernet
  132. DCD ETH_WKUP_IRQHandler ; Ethernet Wakeup through EXTI line
  133. DCD CAN2_TX_IRQHandler ; CAN2 TX
  134. DCD CAN2_RX0_IRQHandler ; CAN2 RX0
  135. DCD CAN2_RX1_IRQHandler ; CAN2 RX1
  136. DCD CAN2_SCE_IRQHandler ; CAN2 SCE
  137. DCD OTG_FS_IRQHandler ; USB OTG FS
  138. DCD DMA2_Stream5_IRQHandler ; DMA2 Stream 5
  139. DCD DMA2_Stream6_IRQHandler ; DMA2 Stream 6
  140. DCD DMA2_Stream7_IRQHandler ; DMA2 Stream 7
  141. DCD USART6_IRQHandler ; USART6
  142. DCD I2C3_EV_IRQHandler ; I2C3 event
  143. DCD I2C3_ER_IRQHandler ; I2C3 error
  144. DCD OTG_HS_EP1_OUT_IRQHandler ; USB OTG HS End Point 1 Out
  145. DCD OTG_HS_EP1_IN_IRQHandler ; USB OTG HS End Point 1 In
  146. DCD OTG_HS_WKUP_IRQHandler ; USB OTG HS Wakeup through EXTI
  147. DCD OTG_HS_IRQHandler ; USB OTG HS
  148. DCD DCMI_IRQHandler ; DCMI
  149. DCD CRYP_IRQHandler ; CRYP crypto
  150. DCD HASH_RNG_IRQHandler ; Hash and Rng
  151. __Vectors_End
  152. __Vectors_Size EQU __Vectors_End - __Vectors
  153. AREA |.text|, CODE, READONLY
  154. ; Reset handler
  155. Reset_Handler PROC
  156. EXPORT Reset_Handler [WEAK]
  157. IMPORT SystemInit
  158. IMPORT __main
  159. LDR R0, =SystemInit
  160. BLX R0
  161. LDR R0, =__main
  162. BX R0
  163. ENDP
  164. ; Dummy Exception Handlers (infinite loops which can be modified)
  165. NMI_Handler PROC
  166. EXPORT NMI_Handler [WEAK]
  167. B .
  168. ENDP
  169. HardFault_Handler\
  170. PROC
  171. EXPORT HardFault_Handler [WEAK]
  172. B .
  173. ENDP
  174. MemManage_Handler\
  175. PROC
  176. EXPORT MemManage_Handler [WEAK]
  177. B .
  178. ENDP
  179. BusFault_Handler\
  180. PROC
  181. EXPORT BusFault_Handler [WEAK]
  182. B .
  183. ENDP
  184. UsageFault_Handler\
  185. PROC
  186. EXPORT UsageFault_Handler [WEAK]
  187. B .
  188. ENDP
  189. SVC_Handler PROC
  190. EXPORT SVC_Handler [WEAK]
  191. B .
  192. ENDP
  193. DebugMon_Handler\
  194. PROC
  195. EXPORT DebugMon_Handler [WEAK]
  196. B .
  197. ENDP
  198. PendSV_Handler PROC
  199. EXPORT PendSV_Handler [WEAK]
  200. B .
  201. ENDP
  202. SysTick_Handler PROC
  203. EXPORT SysTick_Handler [WEAK]
  204. B .
  205. ENDP
  206. Default_Handler PROC
  207. EXPORT WWDG_IRQHandler [WEAK]
  208. EXPORT PVD_IRQHandler [WEAK]
  209. EXPORT TAMP_STAMP_IRQHandler [WEAK]
  210. EXPORT RTC_WKUP_IRQHandler [WEAK]
  211. EXPORT FLASH_IRQHandler [WEAK]
  212. EXPORT RCC_IRQHandler [WEAK]
  213. EXPORT EXTI0_IRQHandler [WEAK]
  214. EXPORT EXTI1_IRQHandler [WEAK]
  215. EXPORT EXTI2_IRQHandler [WEAK]
  216. EXPORT EXTI3_IRQHandler [WEAK]
  217. EXPORT EXTI4_IRQHandler [WEAK]
  218. EXPORT DMA1_Stream0_IRQHandler [WEAK]
  219. EXPORT DMA1_Stream1_IRQHandler [WEAK]
  220. EXPORT DMA1_Stream2_IRQHandler [WEAK]
  221. EXPORT DMA1_Stream3_IRQHandler [WEAK]
  222. EXPORT DMA1_Stream4_IRQHandler [WEAK]
  223. EXPORT DMA1_Stream5_IRQHandler [WEAK]
  224. EXPORT DMA1_Stream6_IRQHandler [WEAK]
  225. EXPORT ADC_IRQHandler [WEAK]
  226. EXPORT CAN1_TX_IRQHandler [WEAK]
  227. EXPORT CAN1_RX0_IRQHandler [WEAK]
  228. EXPORT CAN1_RX1_IRQHandler [WEAK]
  229. EXPORT CAN1_SCE_IRQHandler [WEAK]
  230. EXPORT EXTI9_5_IRQHandler [WEAK]
  231. EXPORT TIM1_BRK_TIM9_IRQHandler [WEAK]
  232. EXPORT TIM1_UP_TIM10_IRQHandler [WEAK]
  233. EXPORT TIM1_TRG_COM_TIM11_IRQHandler [WEAK]
  234. EXPORT TIM1_CC_IRQHandler [WEAK]
  235. EXPORT TIM2_IRQHandler [WEAK]
  236. EXPORT TIM3_IRQHandler [WEAK]
  237. EXPORT TIM4_IRQHandler [WEAK]
  238. EXPORT I2C1_EV_IRQHandler [WEAK]
  239. EXPORT I2C1_ER_IRQHandler [WEAK]
  240. EXPORT I2C2_EV_IRQHandler [WEAK]
  241. EXPORT I2C2_ER_IRQHandler [WEAK]
  242. EXPORT SPI1_IRQHandler [WEAK]
  243. EXPORT SPI2_IRQHandler [WEAK]
  244. EXPORT USART1_IRQHandler [WEAK]
  245. EXPORT USART2_IRQHandler [WEAK]
  246. EXPORT USART3_IRQHandler [WEAK]
  247. EXPORT EXTI15_10_IRQHandler [WEAK]
  248. EXPORT RTC_Alarm_IRQHandler [WEAK]
  249. EXPORT OTG_FS_WKUP_IRQHandler [WEAK]
  250. EXPORT TIM8_BRK_TIM12_IRQHandler [WEAK]
  251. EXPORT TIM8_UP_TIM13_IRQHandler [WEAK]
  252. EXPORT TIM8_TRG_COM_TIM14_IRQHandler [WEAK]
  253. EXPORT TIM8_CC_IRQHandler [WEAK]
  254. EXPORT DMA1_Stream7_IRQHandler [WEAK]
  255. EXPORT FSMC_IRQHandler [WEAK]
  256. EXPORT SDIO_IRQHandler [WEAK]
  257. EXPORT TIM5_IRQHandler [WEAK]
  258. EXPORT SPI3_IRQHandler [WEAK]
  259. EXPORT UART4_IRQHandler [WEAK]
  260. EXPORT UART5_IRQHandler [WEAK]
  261. EXPORT TIM6_DAC_IRQHandler [WEAK]
  262. EXPORT TIM7_IRQHandler [WEAK]
  263. EXPORT DMA2_Stream0_IRQHandler [WEAK]
  264. EXPORT DMA2_Stream1_IRQHandler [WEAK]
  265. EXPORT DMA2_Stream2_IRQHandler [WEAK]
  266. EXPORT DMA2_Stream3_IRQHandler [WEAK]
  267. EXPORT DMA2_Stream4_IRQHandler [WEAK]
  268. EXPORT ETH_IRQHandler [WEAK]
  269. EXPORT ETH_WKUP_IRQHandler [WEAK]
  270. EXPORT CAN2_TX_IRQHandler [WEAK]
  271. EXPORT CAN2_RX0_IRQHandler [WEAK]
  272. EXPORT CAN2_RX1_IRQHandler [WEAK]
  273. EXPORT CAN2_SCE_IRQHandler [WEAK]
  274. EXPORT OTG_FS_IRQHandler [WEAK]
  275. EXPORT DMA2_Stream5_IRQHandler [WEAK]
  276. EXPORT DMA2_Stream6_IRQHandler [WEAK]
  277. EXPORT DMA2_Stream7_IRQHandler [WEAK]
  278. EXPORT USART6_IRQHandler [WEAK]
  279. EXPORT I2C3_EV_IRQHandler [WEAK]
  280. EXPORT I2C3_ER_IRQHandler [WEAK]
  281. EXPORT OTG_HS_EP1_OUT_IRQHandler [WEAK]
  282. EXPORT OTG_HS_EP1_IN_IRQHandler [WEAK]
  283. EXPORT OTG_HS_WKUP_IRQHandler [WEAK]
  284. EXPORT OTG_HS_IRQHandler [WEAK]
  285. EXPORT DCMI_IRQHandler [WEAK]
  286. EXPORT CRYP_IRQHandler [WEAK]
  287. EXPORT HASH_RNG_IRQHandler [WEAK]
  288. WWDG_IRQHandler
  289. PVD_IRQHandler
  290. TAMP_STAMP_IRQHandler
  291. RTC_WKUP_IRQHandler
  292. FLASH_IRQHandler
  293. RCC_IRQHandler
  294. EXTI0_IRQHandler
  295. EXTI1_IRQHandler
  296. EXTI2_IRQHandler
  297. EXTI3_IRQHandler
  298. EXTI4_IRQHandler
  299. DMA1_Stream0_IRQHandler
  300. DMA1_Stream1_IRQHandler
  301. DMA1_Stream2_IRQHandler
  302. DMA1_Stream3_IRQHandler
  303. DMA1_Stream4_IRQHandler
  304. DMA1_Stream5_IRQHandler
  305. DMA1_Stream6_IRQHandler
  306. ADC_IRQHandler
  307. CAN1_TX_IRQHandler
  308. CAN1_RX0_IRQHandler
  309. CAN1_RX1_IRQHandler
  310. CAN1_SCE_IRQHandler
  311. EXTI9_5_IRQHandler
  312. TIM1_BRK_TIM9_IRQHandler
  313. TIM1_UP_TIM10_IRQHandler
  314. TIM1_TRG_COM_TIM11_IRQHandler
  315. TIM1_CC_IRQHandler
  316. TIM2_IRQHandler
  317. TIM3_IRQHandler
  318. TIM4_IRQHandler
  319. I2C1_EV_IRQHandler
  320. I2C1_ER_IRQHandler
  321. I2C2_EV_IRQHandler
  322. I2C2_ER_IRQHandler
  323. SPI1_IRQHandler
  324. SPI2_IRQHandler
  325. USART1_IRQHandler
  326. USART2_IRQHandler
  327. USART3_IRQHandler
  328. EXTI15_10_IRQHandler
  329. RTC_Alarm_IRQHandler
  330. OTG_FS_WKUP_IRQHandler
  331. TIM8_BRK_TIM12_IRQHandler
  332. TIM8_UP_TIM13_IRQHandler
  333. TIM8_TRG_COM_TIM14_IRQHandler
  334. TIM8_CC_IRQHandler
  335. DMA1_Stream7_IRQHandler
  336. FSMC_IRQHandler
  337. SDIO_IRQHandler
  338. TIM5_IRQHandler
  339. SPI3_IRQHandler
  340. UART4_IRQHandler
  341. UART5_IRQHandler
  342. TIM6_DAC_IRQHandler
  343. TIM7_IRQHandler
  344. DMA2_Stream0_IRQHandler
  345. DMA2_Stream1_IRQHandler
  346. DMA2_Stream2_IRQHandler
  347. DMA2_Stream3_IRQHandler
  348. DMA2_Stream4_IRQHandler
  349. ETH_IRQHandler
  350. ETH_WKUP_IRQHandler
  351. CAN2_TX_IRQHandler
  352. CAN2_RX0_IRQHandler
  353. CAN2_RX1_IRQHandler
  354. CAN2_SCE_IRQHandler
  355. OTG_FS_IRQHandler
  356. DMA2_Stream5_IRQHandler
  357. DMA2_Stream6_IRQHandler
  358. DMA2_Stream7_IRQHandler
  359. USART6_IRQHandler
  360. I2C3_EV_IRQHandler
  361. I2C3_ER_IRQHandler
  362. OTG_HS_EP1_OUT_IRQHandler
  363. OTG_HS_EP1_IN_IRQHandler
  364. OTG_HS_WKUP_IRQHandler
  365. OTG_HS_IRQHandler
  366. DCMI_IRQHandler
  367. CRYP_IRQHandler
  368. HASH_RNG_IRQHandler
  369. B .
  370. ENDP
  371. ALIGN
  372. ;*******************************************************************************
  373. ; User Stack and Heap initialization
  374. ;*******************************************************************************
  375. IF :DEF:__MICROLIB
  376. EXPORT __initial_sp
  377. EXPORT __heap_base
  378. EXPORT __heap_limit
  379. ELSE
  380. IMPORT __use_two_region_memory
  381. EXPORT __user_initial_stackheap
  382. __user_initial_stackheap
  383. LDR R0, = Heap_Mem
  384. LDR R1, =(Stack_Mem + Stack_Size)
  385. LDR R2, = (Heap_Mem + Heap_Size)
  386. LDR R3, = Stack_Mem
  387. BX LR
  388. ALIGN
  389. ENDIF
  390. END