gcc_startup.s 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /**
  2. *************** (C) COPYRIGHT 2017 STMicroelectronics ************************
  3. * @file gcc_startup.s
  4. * @author MCD Application Team
  5. * @version V4.2.0
  6. * @date 31-March-2017
  7. * @brief Based on STM32F103xE's startup file.
  8. * This module performs:
  9. * - Set the initial SP
  10. * - Set the initial PC == Reset_Handler,
  11. * - Set the vector table entries with the exceptions ISR address
  12. * - Configure the clock system
  13. * - Configure external SRAM mounted on STM3210E-EVAL board
  14. * to be used as data memory (optional, to be enabled by user)
  15. * - Branches to entry in the C library (which eventually
  16. * calls main(), but entry() in RT-Thread).
  17. * After Reset the Cortex-M3 processor is in Thread mode,
  18. * priority is Privileged, and the Stack is set to Main.
  19. ******************************************************************************
  20. *
  21. * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
  22. *
  23. * Redistribution and use in source and binary forms, with or without modification,
  24. * are permitted provided that the following conditions are met:
  25. * 1. Redistributions of source code must retain the above copyright notice,
  26. * this list of conditions and the following disclaimer.
  27. * 2. Redistributions in binary form must reproduce the above copyright notice,
  28. * this list of conditions and the following disclaimer in the documentation
  29. * and/or other materials provided with the distribution.
  30. * 3. Neither the name of STMicroelectronics nor the names of its contributors
  31. * may be used to endorse or promote products derived from this software
  32. * without specific prior written permission.
  33. *
  34. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  35. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  36. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  37. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  38. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  39. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  40. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  41. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  42. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  43. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  44. *
  45. ******************************************************************************
  46. */
  47. .syntax unified
  48. .cpu cortex-m3
  49. .fpu softvfp
  50. .thumb
  51. /**
  52. * @brief This is the code that gets called when the processor first
  53. * starts execution following a reset event. Only the absolutely
  54. * necessary set is performed, after which the application
  55. * supplied main() routine is called.
  56. * @param None
  57. * @retval : None
  58. */
  59. .global Reset_Handler
  60. .section .text.Reset_Handler
  61. .type Reset_Handler, %function
  62. Reset_Handler:
  63. /* Copy the data segment initializers from flash to SRAM */
  64. movs r1, #0
  65. b LoopCopyDataInit
  66. CopyDataInit:
  67. ldr r3, =_sidata
  68. ldr r3, [r3, r1]
  69. str r3, [r0, r1]
  70. adds r1, r1, #4
  71. LoopCopyDataInit:
  72. ldr r0, =_sdata
  73. ldr r3, =_edata
  74. adds r2, r0, r1
  75. cmp r2, r3
  76. bcc CopyDataInit
  77. ldr r2, =_sbss
  78. b LoopFillZerobss
  79. /* Zero fill the bss segment. */
  80. FillZerobss:
  81. movs r3, #0
  82. str r3, [r2], #4
  83. LoopFillZerobss:
  84. ldr r3, = _ebss
  85. cmp r2, r3
  86. bcc FillZerobss
  87. /* Call the clock system intitialization function.*/
  88. bl SystemInit
  89. /* Call static constructors */
  90. bl __libc_init_array
  91. /* Call the application's entry point.*/
  92. bl entry
  93. bx lr
  94. .size Reset_Handler, .-Reset_Handler