Blackbox device type 'file' (SITL) considered working when file handler is available
[inav.git] / src / main / startup / startup_stm32f40xx.s
blob9e3a33932db82d5b7b2fc52ec3656becd55edafa
1 /**
2 ******************************************************************************
3 * @file startup_stm32f40_41xxx.s
4 * @author MCD Application Team
5 * @version V1.6.1
6 * @date 21-October-2015
7 * @brief STM32F40xxx/41xxx Devices vector table for Atollic TrueSTUDIO toolchain.
8 * Same as startup_stm32f40_41xxx.s and maintained for legacy purpose
9 * This module performs:
10 * - Set the initial SP
11 * - Set the initial PC == Reset_Handler,
12 * - Set the vector table entries with the exceptions ISR address
13 * - Configure the clock system and the external SRAM mounted on
14 * STM324xG-EVAL board to be used as data memory (optional,
15 * to be enabled by user)
16 * - Branches to main in the C library (which eventually
17 * calls main()).
18 * After Reset the Cortex-M4 processor is in Thread mode,
19 * priority is Privileged, and the Stack is set to Main.
20 ******************************************************************************
21 * @attention
23 * <h2><center>&copy; COPYRIGHT 2015 STMicroelectronics</center></h2>
25 * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
26 * You may not use this file except in compliance with the License.
27 * You may obtain a copy of the License at:
29 * http://www.st.com/software_license_agreement_liberty_v2
31 * Unless required by applicable law or agreed to in writing, software
32 * distributed under the License is distributed on an "AS IS" BASIS,
33 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
34 * See the License for the specific language governing permissions and
35 * limitations under the License.
37 ******************************************************************************
40 .syntax unified
41 .cpu cortex-m4
42 .fpu softvfp
43 .thumb
45 .global g_pfnVectors
46 .global Default_Handler
47 .global irq_stack
49 /* start address for the initialization values of the .data section.
50 defined in linker script */
51 .word _sidata
52 /* start address for the .data section. defined in linker script */
53 .word _sdata
54 /* end address for the .data section. defined in linker script */
55 .word _edata
56 /* start address for the .bss section. defined in linker script */
57 .word _sbss
58 /* end address for the .bss section. defined in linker script */
59 .word _ebss
60 /* stack used for SystemInit_ExtMemCtl; always internal RAM used */
62 /**
63 * @brief This is the code that gets called when the processor first
64 * starts execution following a reset event. Only the absolutely
65 * necessary set is performed, after which the application
66 * supplied main() routine is called.
67 * @param None
68 * @retval : None
71 .section .text.Reset_Handler
72 .weak Reset_Handler
73 .type Reset_Handler, %function
74 Reset_Handler:
75 // Enable CCM
76 // RCC->AHB1ENR |= RCC_AHB1ENR_CCMDATARAMEN;
77 ldr r0, =0x40023800 // RCC_BASE
78 ldr r1, [r0, #0x30] // AHB1ENR
79 orr r1, r1, 0x00100000 // RCC_AHB1ENR_CCMDATARAMEN
80 str r1, [r0, #0x30]
81 dsb
83 // Defined in C code
84 bl persistentObjectInit
85 bl checkForBootLoaderRequest
87 /* Copy the data segment initializers from flash to SRAM */
88 movs r1, #0
89 b LoopCopyDataInit
91 CopyDataInit:
92 ldr r3, =_sidata
93 ldr r3, [r3, r1]
94 str r3, [r0, r1]
95 adds r1, r1, #4
97 LoopCopyDataInit:
98 ldr r0, =_sdata
99 ldr r3, =_edata
100 adds r2, r0, r1
101 cmp r2, r3
102 bcc CopyDataInit
103 ldr r2, =_sbss
104 b LoopFillZerobss
105 /* Zero fill the bss segment. */
106 FillZerobss:
107 movs r3, #0
108 str r3, [r2], #4
110 LoopFillZerobss:
111 ldr r3, = _ebss
112 cmp r2, r3
113 bcc FillZerobss
115 /* Zero fill FASTRAM */
116 ldr r2, =__fastram_bss_start__
117 b LoopFillZeroFASTRAM
119 FillZeroFASTRAM:
120 movs r3, #0
121 str r3, [r2], #4
123 LoopFillZeroFASTRAM:
124 ldr r3, = __fastram_bss_end__
125 cmp r2, r3
126 bcc FillZeroFASTRAM
128 /* Mark the heap and stack */
129 ldr r2, =_heap_stack_begin
130 b LoopMarkHeapStack
132 MarkHeapStack:
133 movs r3, 0xa5a5a5a5
134 str r3, [r2], #4
136 LoopMarkHeapStack:
137 ldr r3, = _heap_stack_end
138 cmp r2, r3
139 bcc MarkHeapStack
141 /*FPU settings*/
142 ldr r0, =0xE000ED88 /* Enable CP10,CP11 */
143 ldr r1,[r0]
144 orr r1,r1,#(0xF << 20)
145 str r1,[r0]
147 /* Call the clock system intitialization function.*/
148 bl SystemInit
150 /* Call the application's entry point.*/
151 bl main
152 bx lr
154 LoopForever:
155 b LoopForever
157 .size Reset_Handler, .-Reset_Handler
160 * @brief This is the code that gets called when the processor receives an
161 * unexpected interrupt. This simply enters an infinite loop, preserving
162 * the system state for examination by a debugger.
163 * @param None
164 * @retval None
166 .section .text.Default_Handler,"ax",%progbits
167 Default_Handler:
168 Infinite_Loop:
169 b Infinite_Loop
170 .size Default_Handler, .-Default_Handler
171 /******************************************************************************
173 * The minimal vector table for a Cortex M3. Note that the proper constructs
174 * must be placed on this to ensure that it ends up at physical address
175 * 0x0000.0000.
177 *******************************************************************************/
178 .section .isr_vector,"a",%progbits
179 .type g_pfnVectors, %object
180 .size g_pfnVectors, .-g_pfnVectors
183 g_pfnVectors:
184 .word _estack
185 .word Reset_Handler
187 .word NMI_Handler
188 .word HardFault_Handler
189 .word MemManage_Handler
190 .word BusFault_Handler
191 .word UsageFault_Handler
192 .word 0
193 .word 0
194 .word 0
195 .word 0
196 .word SVC_Handler
197 .word DebugMon_Handler
198 .word 0
199 .word PendSV_Handler
200 .word SysTick_Handler
202 /* External Interrupts */
203 .word WWDG_IRQHandler /* Window WatchDog */
204 .word PVD_IRQHandler /* PVD through EXTI Line detection */
205 .word TAMP_STAMP_IRQHandler /* Tamper and TimeStamps through the EXTI line */
206 .word RTC_WKUP_IRQHandler /* RTC Wakeup through the EXTI line */
207 .word FLASH_IRQHandler /* FLASH */
208 .word RCC_IRQHandler /* RCC */
209 .word EXTI0_IRQHandler /* EXTI Line0 */
210 .word EXTI1_IRQHandler /* EXTI Line1 */
211 .word EXTI2_IRQHandler /* EXTI Line2 */
212 .word EXTI3_IRQHandler /* EXTI Line3 */
213 .word EXTI4_IRQHandler /* EXTI Line4 */
214 .word DMA1_Stream0_IRQHandler /* DMA1 Stream 0 */
215 .word DMA1_Stream1_IRQHandler /* DMA1 Stream 1 */
216 .word DMA1_Stream2_IRQHandler /* DMA1 Stream 2 */
217 .word DMA1_Stream3_IRQHandler /* DMA1 Stream 3 */
218 .word DMA1_Stream4_IRQHandler /* DMA1 Stream 4 */
219 .word DMA1_Stream5_IRQHandler /* DMA1 Stream 5 */
220 .word DMA1_Stream6_IRQHandler /* DMA1 Stream 6 */
221 .word ADC_IRQHandler /* ADC1, ADC2 and ADC3s */
222 .word CAN1_TX_IRQHandler /* CAN1 TX */
223 .word CAN1_RX0_IRQHandler /* CAN1 RX0 */
224 .word CAN1_RX1_IRQHandler /* CAN1 RX1 */
225 .word CAN1_SCE_IRQHandler /* CAN1 SCE */
226 .word EXTI9_5_IRQHandler /* External Line[9:5]s */
227 .word TIM1_BRK_TIM9_IRQHandler /* TIM1 Break and TIM9 */
228 .word TIM1_UP_TIM10_IRQHandler /* TIM1 Update and TIM10 */
229 .word TIM1_TRG_COM_TIM11_IRQHandler /* TIM1 Trigger and Commutation and TIM11 */
230 .word TIM1_CC_IRQHandler /* TIM1 Capture Compare */
231 .word TIM2_IRQHandler /* TIM2 */
232 .word TIM3_IRQHandler /* TIM3 */
233 .word TIM4_IRQHandler /* TIM4 */
234 .word I2C1_EV_IRQHandler /* I2C1 Event */
235 .word I2C1_ER_IRQHandler /* I2C1 Error */
236 .word I2C2_EV_IRQHandler /* I2C2 Event */
237 .word I2C2_ER_IRQHandler /* I2C2 Error */
238 .word SPI1_IRQHandler /* SPI1 */
239 .word SPI2_IRQHandler /* SPI2 */
240 .word USART1_IRQHandler /* USART1 */
241 .word USART2_IRQHandler /* USART2 */
242 .word USART3_IRQHandler /* USART3 */
243 .word EXTI15_10_IRQHandler /* External Line[15:10]s */
244 .word RTC_Alarm_IRQHandler /* RTC Alarm (A and B) through EXTI Line */
245 .word OTG_FS_WKUP_IRQHandler /* USB OTG FS Wakeup through EXTI line */
246 .word TIM8_BRK_TIM12_IRQHandler /* TIM8 Break and TIM12 */
247 .word TIM8_UP_TIM13_IRQHandler /* TIM8 Update and TIM13 */
248 .word TIM8_TRG_COM_TIM14_IRQHandler /* TIM8 Trigger and Commutation and TIM14 */
249 .word TIM8_CC_IRQHandler /* TIM8 Capture Compare */
250 .word DMA1_Stream7_IRQHandler /* DMA1 Stream7 */
251 .word FSMC_IRQHandler /* FSMC */
252 .word SDIO_IRQHandler /* SDIO */
253 .word TIM5_IRQHandler /* TIM5 */
254 .word SPI3_IRQHandler /* SPI3 */
255 .word UART4_IRQHandler /* UART4 */
256 .word UART5_IRQHandler /* UART5 */
257 .word TIM6_DAC_IRQHandler /* TIM6 and DAC1&2 underrun errors */
258 .word TIM7_IRQHandler /* TIM7 */
259 .word DMA2_Stream0_IRQHandler /* DMA2 Stream 0 */
260 .word DMA2_Stream1_IRQHandler /* DMA2 Stream 1 */
261 .word DMA2_Stream2_IRQHandler /* DMA2 Stream 2 */
262 .word DMA2_Stream3_IRQHandler /* DMA2 Stream 3 */
263 .word DMA2_Stream4_IRQHandler /* DMA2 Stream 4 */
264 .word ETH_IRQHandler /* Ethernet */
265 .word ETH_WKUP_IRQHandler /* Ethernet Wakeup through EXTI line */
266 .word CAN2_TX_IRQHandler /* CAN2 TX */
267 .word CAN2_RX0_IRQHandler /* CAN2 RX0 */
268 .word CAN2_RX1_IRQHandler /* CAN2 RX1 */
269 .word CAN2_SCE_IRQHandler /* CAN2 SCE */
270 .word OTG_FS_IRQHandler /* USB OTG FS */
271 .word DMA2_Stream5_IRQHandler /* DMA2 Stream 5 */
272 .word DMA2_Stream6_IRQHandler /* DMA2 Stream 6 */
273 .word DMA2_Stream7_IRQHandler /* DMA2 Stream 7 */
274 .word USART6_IRQHandler /* USART6 */
275 .word I2C3_EV_IRQHandler /* I2C3 event */
276 .word I2C3_ER_IRQHandler /* I2C3 error */
277 .word OTG_HS_EP1_OUT_IRQHandler /* USB OTG HS End Point 1 Out */
278 .word OTG_HS_EP1_IN_IRQHandler /* USB OTG HS End Point 1 In */
279 .word OTG_HS_WKUP_IRQHandler /* USB OTG HS Wakeup through EXTI */
280 .word OTG_HS_IRQHandler /* USB OTG HS */
281 .word DCMI_IRQHandler /* DCMI */
282 .word CRYP_IRQHandler /* CRYP crypto */
283 .word HASH_RNG_IRQHandler /* Hash and Rng */
284 .word FPU_IRQHandler /* FPU */
286 /*******************************************************************************
288 * Provide weak aliases for each Exception handler to the Default_Handler.
289 * As they are weak aliases, any function with the same name will override
290 * this definition.
292 *******************************************************************************/
293 .weak NMI_Handler
294 .thumb_set NMI_Handler,Default_Handler
296 .weak HardFault_Handler
297 .thumb_set HardFault_Handler,Default_Handler
299 .weak MemManage_Handler
300 .thumb_set MemManage_Handler,Default_Handler
302 .weak BusFault_Handler
303 .thumb_set BusFault_Handler,Default_Handler
305 .weak UsageFault_Handler
306 .thumb_set UsageFault_Handler,Default_Handler
308 .weak SVC_Handler
309 .thumb_set SVC_Handler,Default_Handler
311 .weak DebugMon_Handler
312 .thumb_set DebugMon_Handler,Default_Handler
314 .weak PendSV_Handler
315 .thumb_set PendSV_Handler,Default_Handler
317 .weak SysTick_Handler
318 .thumb_set SysTick_Handler,Default_Handler
320 .weak WWDG_IRQHandler
321 .thumb_set WWDG_IRQHandler,Default_Handler
323 .weak PVD_IRQHandler
324 .thumb_set PVD_IRQHandler,Default_Handler
326 .weak TAMP_STAMP_IRQHandler
327 .thumb_set TAMP_STAMP_IRQHandler,Default_Handler
329 .weak RTC_WKUP_IRQHandler
330 .thumb_set RTC_WKUP_IRQHandler,Default_Handler
332 .weak FLASH_IRQHandler
333 .thumb_set FLASH_IRQHandler,Default_Handler
335 .weak RCC_IRQHandler
336 .thumb_set RCC_IRQHandler,Default_Handler
338 .weak EXTI0_IRQHandler
339 .thumb_set EXTI0_IRQHandler,Default_Handler
341 .weak EXTI1_IRQHandler
342 .thumb_set EXTI1_IRQHandler,Default_Handler
344 .weak EXTI2_IRQHandler
345 .thumb_set EXTI2_IRQHandler,Default_Handler
347 .weak EXTI3_IRQHandler
348 .thumb_set EXTI3_IRQHandler,Default_Handler
350 .weak EXTI4_IRQHandler
351 .thumb_set EXTI4_IRQHandler,Default_Handler
353 .weak DMA1_Stream0_IRQHandler
354 .thumb_set DMA1_Stream0_IRQHandler,Default_Handler
356 .weak DMA1_Stream1_IRQHandler
357 .thumb_set DMA1_Stream1_IRQHandler,Default_Handler
359 .weak DMA1_Stream2_IRQHandler
360 .thumb_set DMA1_Stream2_IRQHandler,Default_Handler
362 .weak DMA1_Stream3_IRQHandler
363 .thumb_set DMA1_Stream3_IRQHandler,Default_Handler
365 .weak DMA1_Stream4_IRQHandler
366 .thumb_set DMA1_Stream4_IRQHandler,Default_Handler
368 .weak DMA1_Stream5_IRQHandler
369 .thumb_set DMA1_Stream5_IRQHandler,Default_Handler
371 .weak DMA1_Stream6_IRQHandler
372 .thumb_set DMA1_Stream6_IRQHandler,Default_Handler
374 .weak ADC_IRQHandler
375 .thumb_set ADC_IRQHandler,Default_Handler
377 .weak CAN1_TX_IRQHandler
378 .thumb_set CAN1_TX_IRQHandler,Default_Handler
380 .weak CAN1_RX0_IRQHandler
381 .thumb_set CAN1_RX0_IRQHandler,Default_Handler
383 .weak CAN1_RX1_IRQHandler
384 .thumb_set CAN1_RX1_IRQHandler,Default_Handler
386 .weak CAN1_SCE_IRQHandler
387 .thumb_set CAN1_SCE_IRQHandler,Default_Handler
389 .weak EXTI9_5_IRQHandler
390 .thumb_set EXTI9_5_IRQHandler,Default_Handler
392 .weak TIM1_BRK_TIM9_IRQHandler
393 .thumb_set TIM1_BRK_TIM9_IRQHandler,Default_Handler
395 .weak TIM1_UP_TIM10_IRQHandler
396 .thumb_set TIM1_UP_TIM10_IRQHandler,Default_Handler
398 .weak TIM1_TRG_COM_TIM11_IRQHandler
399 .thumb_set TIM1_TRG_COM_TIM11_IRQHandler,Default_Handler
401 .weak TIM1_CC_IRQHandler
402 .thumb_set TIM1_CC_IRQHandler,Default_Handler
404 .weak TIM2_IRQHandler
405 .thumb_set TIM2_IRQHandler,Default_Handler
407 .weak TIM3_IRQHandler
408 .thumb_set TIM3_IRQHandler,Default_Handler
410 .weak TIM4_IRQHandler
411 .thumb_set TIM4_IRQHandler,Default_Handler
413 .weak I2C1_EV_IRQHandler
414 .thumb_set I2C1_EV_IRQHandler,Default_Handler
416 .weak I2C1_ER_IRQHandler
417 .thumb_set I2C1_ER_IRQHandler,Default_Handler
419 .weak I2C2_EV_IRQHandler
420 .thumb_set I2C2_EV_IRQHandler,Default_Handler
422 .weak I2C2_ER_IRQHandler
423 .thumb_set I2C2_ER_IRQHandler,Default_Handler
425 .weak SPI1_IRQHandler
426 .thumb_set SPI1_IRQHandler,Default_Handler
428 .weak SPI2_IRQHandler
429 .thumb_set SPI2_IRQHandler,Default_Handler
431 .weak USART1_IRQHandler
432 .thumb_set USART1_IRQHandler,Default_Handler
434 .weak USART2_IRQHandler
435 .thumb_set USART2_IRQHandler,Default_Handler
437 .weak USART3_IRQHandler
438 .thumb_set USART3_IRQHandler,Default_Handler
440 .weak EXTI15_10_IRQHandler
441 .thumb_set EXTI15_10_IRQHandler,Default_Handler
443 .weak RTC_Alarm_IRQHandler
444 .thumb_set RTC_Alarm_IRQHandler,Default_Handler
446 .weak OTG_FS_WKUP_IRQHandler
447 .thumb_set OTG_FS_WKUP_IRQHandler,Default_Handler
449 .weak TIM8_BRK_TIM12_IRQHandler
450 .thumb_set TIM8_BRK_TIM12_IRQHandler,Default_Handler
452 .weak TIM8_UP_TIM13_IRQHandler
453 .thumb_set TIM8_UP_TIM13_IRQHandler,Default_Handler
455 .weak TIM8_TRG_COM_TIM14_IRQHandler
456 .thumb_set TIM8_TRG_COM_TIM14_IRQHandler,Default_Handler
458 .weak TIM8_CC_IRQHandler
459 .thumb_set TIM8_CC_IRQHandler,Default_Handler
461 .weak DMA1_Stream7_IRQHandler
462 .thumb_set DMA1_Stream7_IRQHandler,Default_Handler
464 .weak FSMC_IRQHandler
465 .thumb_set FSMC_IRQHandler,Default_Handler
467 .weak SDIO_IRQHandler
468 .thumb_set SDIO_IRQHandler,Default_Handler
470 .weak TIM5_IRQHandler
471 .thumb_set TIM5_IRQHandler,Default_Handler
473 .weak SPI3_IRQHandler
474 .thumb_set SPI3_IRQHandler,Default_Handler
476 .weak UART4_IRQHandler
477 .thumb_set UART4_IRQHandler,Default_Handler
479 .weak UART5_IRQHandler
480 .thumb_set UART5_IRQHandler,Default_Handler
482 .weak TIM6_DAC_IRQHandler
483 .thumb_set TIM6_DAC_IRQHandler,Default_Handler
485 .weak TIM7_IRQHandler
486 .thumb_set TIM7_IRQHandler,Default_Handler
488 .weak DMA2_Stream0_IRQHandler
489 .thumb_set DMA2_Stream0_IRQHandler,Default_Handler
491 .weak DMA2_Stream1_IRQHandler
492 .thumb_set DMA2_Stream1_IRQHandler,Default_Handler
494 .weak DMA2_Stream2_IRQHandler
495 .thumb_set DMA2_Stream2_IRQHandler,Default_Handler
497 .weak DMA2_Stream3_IRQHandler
498 .thumb_set DMA2_Stream3_IRQHandler,Default_Handler
500 .weak DMA2_Stream4_IRQHandler
501 .thumb_set DMA2_Stream4_IRQHandler,Default_Handler
503 .weak ETH_IRQHandler
504 .thumb_set ETH_IRQHandler,Default_Handler
506 .weak ETH_WKUP_IRQHandler
507 .thumb_set ETH_WKUP_IRQHandler,Default_Handler
509 .weak CAN2_TX_IRQHandler
510 .thumb_set CAN2_TX_IRQHandler,Default_Handler
512 .weak CAN2_RX0_IRQHandler
513 .thumb_set CAN2_RX0_IRQHandler,Default_Handler
515 .weak CAN2_RX1_IRQHandler
516 .thumb_set CAN2_RX1_IRQHandler,Default_Handler
518 .weak CAN2_SCE_IRQHandler
519 .thumb_set CAN2_SCE_IRQHandler,Default_Handler
521 .weak OTG_FS_IRQHandler
522 .thumb_set OTG_FS_IRQHandler,Default_Handler
524 .weak DMA2_Stream5_IRQHandler
525 .thumb_set DMA2_Stream5_IRQHandler,Default_Handler
527 .weak DMA2_Stream6_IRQHandler
528 .thumb_set DMA2_Stream6_IRQHandler,Default_Handler
530 .weak DMA2_Stream7_IRQHandler
531 .thumb_set DMA2_Stream7_IRQHandler,Default_Handler
533 .weak USART6_IRQHandler
534 .thumb_set USART6_IRQHandler,Default_Handler
536 .weak I2C3_EV_IRQHandler
537 .thumb_set I2C3_EV_IRQHandler,Default_Handler
539 .weak I2C3_ER_IRQHandler
540 .thumb_set I2C3_ER_IRQHandler,Default_Handler
542 .weak OTG_HS_EP1_OUT_IRQHandler
543 .thumb_set OTG_HS_EP1_OUT_IRQHandler,Default_Handler
545 .weak OTG_HS_EP1_IN_IRQHandler
546 .thumb_set OTG_HS_EP1_IN_IRQHandler,Default_Handler
548 .weak OTG_HS_WKUP_IRQHandler
549 .thumb_set OTG_HS_WKUP_IRQHandler,Default_Handler
551 .weak OTG_HS_IRQHandler
552 .thumb_set OTG_HS_IRQHandler,Default_Handler
554 .weak DCMI_IRQHandler
555 .thumb_set DCMI_IRQHandler,Default_Handler
557 .weak CRYP_IRQHandler
558 .thumb_set CRYP_IRQHandler,Default_Handler
560 .weak HASH_RNG_IRQHandler
561 .thumb_set HASH_RNG_IRQHandler,Default_Handler
563 .weak FPU_IRQHandler
564 .thumb_set FPU_IRQHandler,Default_Handler
566 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/