|
| 1 | +/** |
| 2 | + *************** (C) COPYRIGHT 2017 STMicroelectronics ************************ |
| 3 | + * @file startup_stm32f101xe.s |
| 4 | + * @author MCD Application Team |
| 5 | + * @brief STM32F101xE Value Line 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 | + * <h2><center>© Copyright (c) 2017 STMicroelectronics. |
| 19 | + * All rights reserved.</center></h2> |
| 20 | + * |
| 21 | + * This software component is licensed by ST under BSD 3-Clause license, |
| 22 | + * the "License"; You may not use this file except in compliance with the |
| 23 | + * License. You may obtain a copy of the License at: |
| 24 | + * opensource.org/licenses/BSD-3-Clause |
| 25 | + * |
| 26 | + ****************************************************************************** |
| 27 | + */ |
| 28 | + |
| 29 | + .syntax unified |
| 30 | + .cpu cortex-m3 |
| 31 | + .fpu softvfp |
| 32 | + .thumb |
| 33 | + |
| 34 | +.global g_pfnVectors |
| 35 | +.global Default_Handler |
| 36 | + |
| 37 | +/* start address for the initialization values of the .data section. |
| 38 | +defined in linker script */ |
| 39 | +.word _sidata |
| 40 | +/* start address for the .data section. defined in linker script */ |
| 41 | +.word _sdata |
| 42 | +/* end address for the .data section. defined in linker script */ |
| 43 | +.word _edata |
| 44 | +/* start address for the .bss section. defined in linker script */ |
| 45 | +.word _sbss |
| 46 | +/* end address for the .bss section. defined in linker script */ |
| 47 | +.word _ebss |
| 48 | + |
| 49 | +.equ BootRAM, 0xF1E0F85F |
| 50 | +/** |
| 51 | + * @brief This is the code that gets called when the processor first |
| 52 | + * starts execution following a reset event. Only the absolutely |
| 53 | + * necessary set is performed, after which the application |
| 54 | + * supplied main() routine is called. |
| 55 | + * @param None |
| 56 | + * @retval : None |
| 57 | +*/ |
| 58 | + |
| 59 | + .section .text.Reset_Handler |
| 60 | + .weak Reset_Handler |
| 61 | + .type Reset_Handler, %function |
| 62 | +Reset_Handler: |
| 63 | + |
| 64 | + /* Disable SysTick interrupt (was enabled by jg aurora bootloader) */ |
| 65 | + ldr r2,SysTick |
| 66 | + movs r1, #0 |
| 67 | + str r1, [r2] |
| 68 | + /* Copy the data segment initializers from flash to SRAM */ |
| 69 | + b LoopCopyDataInit |
| 70 | +SysTick: |
| 71 | + .word 0xE000E010 |
| 72 | +CopyDataInit: |
| 73 | + ldr r3, =_sidata |
| 74 | + ldr r3, [r3, r1] |
| 75 | + str r3, [r0, r1] |
| 76 | + adds r1, r1, #4 |
| 77 | + |
| 78 | +LoopCopyDataInit: |
| 79 | + ldr r0, =_sdata |
| 80 | + ldr r3, =_edata |
| 81 | + adds r2, r0, r1 |
| 82 | + cmp r2, r3 |
| 83 | + bcc CopyDataInit |
| 84 | + ldr r2, =_sbss |
| 85 | + b LoopFillZerobss |
| 86 | +/* Zero fill the bss segment. */ |
| 87 | +FillZerobss: |
| 88 | + movs r3, #0 |
| 89 | + str r3, [r2], #4 |
| 90 | + |
| 91 | +LoopFillZerobss: |
| 92 | + ldr r3, = _ebss |
| 93 | + cmp r2, r3 |
| 94 | + bcc FillZerobss |
| 95 | + |
| 96 | +/* Call the clock system intitialization function.*/ |
| 97 | + bl SystemInit |
| 98 | +/* Call static constructors */ |
| 99 | + bl __libc_init_array |
| 100 | +/* Call the application's entry point.*/ |
| 101 | + bl main |
| 102 | + bx lr |
| 103 | + |
| 104 | +.size Reset_Handler, .-Reset_Handler |
0 commit comments