From e4ac1a31cae0e328fe5be33bbfdbf580de6c7416 Mon Sep 17 00:00:00 2001 From: james <1943357252@qq.com> Date: Sun, 4 Aug 2024 14:44:37 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9S=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Templates/gcc/startup_stm32f407xx.s | 67 +++++++++++++------ 1 file changed, 47 insertions(+), 20 deletions(-) diff --git a/libraries/STM32F4xx_HAL/CMSIS/Device/ST/STM32F4xx/Source/Templates/gcc/startup_stm32f407xx.s b/libraries/STM32F4xx_HAL/CMSIS/Device/ST/STM32F4xx/Source/Templates/gcc/startup_stm32f407xx.s index 85c0618..0539dcf 100644 --- a/libraries/STM32F4xx_HAL/CMSIS/Device/ST/STM32F4xx/Source/Templates/gcc/startup_stm32f407xx.s +++ b/libraries/STM32F4xx_HAL/CMSIS/Device/ST/STM32F4xx/Source/Templates/gcc/startup_stm32f407xx.s @@ -62,40 +62,67 @@ Reset_Handler: ldr sp, =_estack /* set stack pointer */ /* Copy the data segment initializers from flash to SRAM */ - ldr r0, =_sdata - ldr r1, =_edata - ldr r2, =_sidata - movs r3, #0 - b LoopCopyDataInit + 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 + +/* Copy from flash to CCMRAM */ + ldr r0, =_sccmdata + ldr r1, =_eccmdata + ldr r2, =_siccmdata + movs r3, #0 + b LoopCopyCcmInit +CopyCcmInit: ldr r4, [r2, r3] str r4, [r0, r3] adds r3, r3, #4 - -LoopCopyDataInit: +LoopCopyCcmInit: adds r4, r0, r3 cmp r4, r1 - bcc CopyDataInit - -/* Zero fill the bss segment. */ - ldr r2, =_sbss - ldr r4, =_ebss - movs r3, #0 - b LoopFillZerobss + bcc CopyCcmInit +/* End of copy to CCMRAM */ + ldr r2, =_sccm_bss + b LoopFillZeroCcm +/* Zero fill the ccm bss segment. */ +FillZeroCcm: + movs r3, #0 + str r3, [r2], #4 + +LoopFillZeroCcm: + ldr r3, = _eccm_bss + cmp r2, r3 + bcc FillZeroCcm +/* End of zero fill to CCMRAM */ + + ldr r2, =_sbss + b LoopFillZerobss +/* Zero fill the bss segment. */ FillZerobss: - str r3, [r2] - adds r2, r2, #4 - + movs r3, #0 + str r3, [r2], #4 + LoopFillZerobss: - cmp r2, r4 - bcc FillZerobss + ldr r3, = _ebss + cmp r2, r3 + bcc FillZerobss /* Call the clock system intitialization function.*/ bl SystemInit /* Call static constructors */ - bl __libc_init_array +/* bl __libc_init_array */ /* Call the application's entry point.*/ bl entry bx lr