diff --git a/bsp/stm32f10x-HAL/Libraries/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/startup_stm32f100xb.s b/bsp/stm32f10x-HAL/Libraries/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/startup_stm32f100xb.s index 87d2d6d28aa97af2f863027b396c62be116bdd1b..5c2b0196c44fbe54b847ec3c451571140ecf9355 100644 --- a/bsp/stm32f10x-HAL/Libraries/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/startup_stm32f100xb.s +++ b/bsp/stm32f10x-HAL/Libraries/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/startup_stm32f100xb.s @@ -111,7 +111,7 @@ LoopFillZerobss: /* Call static constructors */ bl __libc_init_array /* Call the application's entry point.*/ - bl entry + bl main bx lr .size Reset_Handler, .-Reset_Handler diff --git a/bsp/stm32f10x-HAL/Libraries/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/startup_stm32f100xe.s b/bsp/stm32f10x-HAL/Libraries/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/startup_stm32f100xe.s index 3f27c3c89ba2c95dd1e68410a73b1082f1b17754..9f4351af59f52705c76951ffd52190e3fe60f2d6 100644 --- a/bsp/stm32f10x-HAL/Libraries/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/startup_stm32f100xe.s +++ b/bsp/stm32f10x-HAL/Libraries/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/startup_stm32f100xe.s @@ -111,7 +111,7 @@ LoopFillZerobss: /* Call static constructors */ bl __libc_init_array /* Call the application's entry point.*/ - bl entry + bl main bx lr .size Reset_Handler, .-Reset_Handler diff --git a/bsp/stm32f10x-HAL/Libraries/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/startup_stm32f101x6.s b/bsp/stm32f10x-HAL/Libraries/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/startup_stm32f101x6.s index 4a76fac80fe11c3d694497a3cb4552ae93321893..aa5222ea87775768fb57adcfad88a77e8a527710 100644 --- a/bsp/stm32f10x-HAL/Libraries/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/startup_stm32f101x6.s +++ b/bsp/stm32f10x-HAL/Libraries/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/startup_stm32f101x6.s @@ -111,7 +111,7 @@ LoopFillZerobss: /* Call static constructors */ bl __libc_init_array /* Call the application's entry point.*/ - bl entry + bl main bx lr .size Reset_Handler, .-Reset_Handler diff --git a/bsp/stm32f10x-HAL/Libraries/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/startup_stm32f101xb.s b/bsp/stm32f10x-HAL/Libraries/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/startup_stm32f101xb.s index 019236ac9ec4b4c2c5d8396c45e15699404a2a46..eff8b458ecb23a35393e3e03150aacb7b770eb4d 100644 --- a/bsp/stm32f10x-HAL/Libraries/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/startup_stm32f101xb.s +++ b/bsp/stm32f10x-HAL/Libraries/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/startup_stm32f101xb.s @@ -111,7 +111,7 @@ LoopFillZerobss: /* Call static constructors */ bl __libc_init_array /* Call the application's entry point.*/ - bl entry + bl main bx lr .size Reset_Handler, .-Reset_Handler diff --git a/bsp/stm32f10x-HAL/Libraries/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/startup_stm32f101xe.s b/bsp/stm32f10x-HAL/Libraries/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/startup_stm32f101xe.s index f7290ab2781ec22690d97e5a74d58bc9412c3d2f..4d8265b533c99a91845f83bd8a2580443ccffab2 100644 --- a/bsp/stm32f10x-HAL/Libraries/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/startup_stm32f101xe.s +++ b/bsp/stm32f10x-HAL/Libraries/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/startup_stm32f101xe.s @@ -111,7 +111,7 @@ LoopFillZerobss: /* Call static constructors */ bl __libc_init_array /* Call the application's entry point.*/ - bl entry + bl main bx lr .size Reset_Handler, .-Reset_Handler diff --git a/bsp/stm32f10x-HAL/Libraries/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/startup_stm32f101xg.s b/bsp/stm32f10x-HAL/Libraries/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/startup_stm32f101xg.s index c73ee4ce1d5ae0648f653693299c47ebaf9ceeb6..51dfe85e5c4fcf2e5d64cc9088b7f08908bbe5da 100644 --- a/bsp/stm32f10x-HAL/Libraries/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/startup_stm32f101xg.s +++ b/bsp/stm32f10x-HAL/Libraries/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/startup_stm32f101xg.s @@ -111,7 +111,7 @@ LoopFillZerobss: /* Call static constructors */ bl __libc_init_array /* Call the application's entry point.*/ - bl entry + bl main bx lr .size Reset_Handler, .-Reset_Handler diff --git a/bsp/stm32f10x-HAL/Libraries/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/startup_stm32f102x6.s b/bsp/stm32f10x-HAL/Libraries/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/startup_stm32f102x6.s index 076e8aca2a1a0571fd4321ec79b46ecb7dd65894..a156b24cc9c2fa5f548c26dada0e6c2d49e2da51 100644 --- a/bsp/stm32f10x-HAL/Libraries/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/startup_stm32f102x6.s +++ b/bsp/stm32f10x-HAL/Libraries/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/startup_stm32f102x6.s @@ -111,7 +111,7 @@ LoopFillZerobss: /* Call static constructors */ bl __libc_init_array /* Call the application's entry point.*/ - bl entry + bl main bx lr .size Reset_Handler, .-Reset_Handler diff --git a/bsp/stm32f10x-HAL/Libraries/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/startup_stm32f102xb.s b/bsp/stm32f10x-HAL/Libraries/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/startup_stm32f102xb.s index 0ca2a21e3b8fdc672dc35a5151e482f974e801ad..fe3d21745ee4cc9275342d604b9c052a314bb4b0 100644 --- a/bsp/stm32f10x-HAL/Libraries/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/startup_stm32f102xb.s +++ b/bsp/stm32f10x-HAL/Libraries/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/startup_stm32f102xb.s @@ -111,7 +111,7 @@ LoopFillZerobss: /* Call static constructors */ bl __libc_init_array /* Call the application's entry point.*/ - bl entry + bl main bx lr .size Reset_Handler, .-Reset_Handler diff --git a/bsp/stm32f10x-HAL/Libraries/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/startup_stm32f103x6.s b/bsp/stm32f10x-HAL/Libraries/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/startup_stm32f103x6.s index 89771dc207d1d1d56cd853d372ca8c96c288ab3d..3b9a953155c2feab0e80e501b33e9c61376c5fc6 100644 --- a/bsp/stm32f10x-HAL/Libraries/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/startup_stm32f103x6.s +++ b/bsp/stm32f10x-HAL/Libraries/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/startup_stm32f103x6.s @@ -111,7 +111,7 @@ LoopFillZerobss: /* Call static constructors */ bl __libc_init_array /* Call the application's entry point.*/ - bl entry + bl main bx lr .size Reset_Handler, .-Reset_Handler diff --git a/bsp/stm32f10x-HAL/Libraries/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/startup_stm32f103xb.s b/bsp/stm32f10x-HAL/Libraries/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/startup_stm32f103xb.s index d19565353d4f0b4ef58de017061bad2822a8efbd..3a0a3b97756bbf09cebaf31f9c9a0744e21b4f16 100644 --- a/bsp/stm32f10x-HAL/Libraries/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/startup_stm32f103xb.s +++ b/bsp/stm32f10x-HAL/Libraries/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/startup_stm32f103xb.s @@ -111,7 +111,7 @@ LoopFillZerobss: /* Call static constructors */ bl __libc_init_array /* Call the application's entry point.*/ - bl entry + bl main bx lr .size Reset_Handler, .-Reset_Handler diff --git a/bsp/stm32f10x-HAL/Libraries/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/startup_stm32f103xe.s b/bsp/stm32f10x-HAL/Libraries/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/startup_stm32f103xe.s index 4811ae6e5c7f0d9c018736d471ee3762012886a7..2491c488effe4b69cf43168c940365908eb3e085 100644 --- a/bsp/stm32f10x-HAL/Libraries/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/startup_stm32f103xe.s +++ b/bsp/stm32f10x-HAL/Libraries/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/startup_stm32f103xe.s @@ -113,7 +113,7 @@ LoopFillZerobss: /* Call static constructors */ bl __libc_init_array /* Call the application's entry point.*/ - bl entry + bl main bx lr .size Reset_Handler, .-Reset_Handler diff --git a/bsp/stm32f10x-HAL/Libraries/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/startup_stm32f103xg.s b/bsp/stm32f10x-HAL/Libraries/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/startup_stm32f103xg.s index cb848cff718a6c103f07a12e3320f84d4015c009..5c0b2d75569741525cca6979767479e5a49857e2 100644 --- a/bsp/stm32f10x-HAL/Libraries/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/startup_stm32f103xg.s +++ b/bsp/stm32f10x-HAL/Libraries/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/startup_stm32f103xg.s @@ -112,7 +112,7 @@ LoopFillZerobss: /* Call static constructors */ bl __libc_init_array /* Call the application's entry point.*/ - bl entry + bl main bx lr .size Reset_Handler, .-Reset_Handler diff --git a/bsp/stm32f10x-HAL/Libraries/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/startup_stm32f105xc.s b/bsp/stm32f10x-HAL/Libraries/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/startup_stm32f105xc.s index b858438a46fdc461ceb508e58e8824b692294fd9..d869206adeed6ca01833d963d92e0deb49d46e2d 100644 --- a/bsp/stm32f10x-HAL/Libraries/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/startup_stm32f105xc.s +++ b/bsp/stm32f10x-HAL/Libraries/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/startup_stm32f105xc.s @@ -109,7 +109,7 @@ LoopFillZerobss: /* Call the clock system intitialization function.*/ bl SystemInit /* Call the application's entry point.*/ - bl entry + bl main bx lr .size Reset_Handler, .-Reset_Handler diff --git a/bsp/stm32f10x-HAL/Libraries/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/startup_stm32f107xc.s b/bsp/stm32f10x-HAL/Libraries/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/startup_stm32f107xc.s index 7f6a1fc8ef1fd1e9bd366c4ad23742e988adbb4a..bf87f072a56e5eca2dd628711a6c7f26251bd6bd 100644 --- a/bsp/stm32f10x-HAL/Libraries/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/startup_stm32f107xc.s +++ b/bsp/stm32f10x-HAL/Libraries/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/startup_stm32f107xc.s @@ -112,7 +112,7 @@ LoopFillZerobss: /* Call static constructors */ bl __libc_init_array /* Call the application's entry point.*/ - bl entry + bl main bx lr .size Reset_Handler, .-Reset_Handler diff --git a/bsp/stm32f10x-HAL/drivers/SConscript b/bsp/stm32f10x-HAL/drivers/SConscript index 586b566952bb149b4c1cdef3fc76bd0c4c7e9bed..3568c9a89b9d99a35733c86cef7f877ae8b95876 100644 --- a/bsp/stm32f10x-HAL/drivers/SConscript +++ b/bsp/stm32f10x-HAL/drivers/SConscript @@ -20,6 +20,9 @@ if GetDepend(['RT_USING_USB_DEVICE']): src += ['drv_usb.c'] if GetDepend(['RT_USING_SDCARD']): src += ['drv_sdcard.c'] + +if rtconfig.CROSS_TOOL == 'gcc': + src += ['gcc_startup.s'] CPPPATH = [cwd] diff --git a/bsp/stm32f10x-HAL/drivers/gcc_startup.s b/bsp/stm32f10x-HAL/drivers/gcc_startup.s new file mode 100644 index 0000000000000000000000000000000000000000..ee7a673f074e4c226e8a0dc843eb8d8d3bf8fd11 --- /dev/null +++ b/bsp/stm32f10x-HAL/drivers/gcc_startup.s @@ -0,0 +1,104 @@ +/** + *************** (C) COPYRIGHT 2017 STMicroelectronics ************************ + * @file gcc_startup.s + * @author MCD Application Team + * @version V4.2.0 + * @date 31-March-2017 + * @brief Based on STM32F103xE's startup file. + * This module performs: + * - Set the initial SP + * - Set the initial PC == Reset_Handler, + * - Set the vector table entries with the exceptions ISR address + * - Configure the clock system + * - Configure external SRAM mounted on STM3210E-EVAL board + * to be used as data memory (optional, to be enabled by user) + * - Branches to entry in the C library (which eventually + * calls main(), but entry() in RT-Thread). + * After Reset the Cortex-M3 processor is in Thread mode, + * priority is Privileged, and the Stack is set to Main. + ****************************************************************************** + * + *

© COPYRIGHT(c) 2017 STMicroelectronics

+ * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************** + */ + + .syntax unified + .cpu cortex-m3 + .fpu softvfp + .thumb + +/** + * @brief This is the code that gets called when the processor first + * starts execution following a reset event. Only the absolutely + * necessary set is performed, after which the application + * supplied main() routine is called. + * @param None + * @retval : None +*/ + + .global Reset_Handler + + .section .text.Reset_Handler + .type Reset_Handler, %function +Reset_Handler: + +/* Copy the data segment initializers from flash to SRAM */ + movs r1, #0 + b LoopCopyDataInit + +CopyDataInit: + ldr r3, =_sidata + ldr r3, [r3, r1] + str r3, [r0, r1] + adds r1, r1, #4 + +LoopCopyDataInit: + ldr r0, =_sdata + ldr r3, =_edata + adds r2, r0, r1 + cmp r2, r3 + bcc CopyDataInit + ldr r2, =_sbss + b LoopFillZerobss +/* Zero fill the bss segment. */ +FillZerobss: + movs r3, #0 + str r3, [r2], #4 + +LoopFillZerobss: + ldr r3, = _ebss + cmp r2, r3 + bcc FillZerobss + +/* Call the clock system intitialization function.*/ + bl SystemInit +/* Call static constructors */ + bl __libc_init_array +/* Call the application's entry point.*/ + bl entry + bx lr +.size Reset_Handler, .-Reset_Handler + diff --git a/bsp/stm32f10x/rtconfig.py b/bsp/stm32f10x/rtconfig.py index 4ebbb68aab2dc4be6306185cbd6e20cb435c81ab..973b3a696de5052e88f778cf31441caa49b16d0b 100644 --- a/bsp/stm32f10x/rtconfig.py +++ b/bsp/stm32f10x/rtconfig.py @@ -3,7 +3,7 @@ import os # toolchains options ARCH='arm' CPU='cortex-m3' -CROSS_TOOL='keil' +CROSS_TOOL='gcc' if os.getenv('RTT_CC'): CROSS_TOOL = os.getenv('RTT_CC')