2021-08-30 02:14 AM
I'm trying to get a STM32Cube project compiled using arm-none-eabi-gcc and a Makefile. The FW builds without problems.but when I boot the MCU i get stuck in Hard Fault. Any ideas what could be wrong?
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
CopyDataInit:
ldr r4, [r2, r3]
str r4, [r0, r3]
adds r3, r3, #4
LoopCopyDataInit:
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
FillZerobss:
str r3, [r2]
adds r2, r2, #4
LoopFillZerobss:
cmp r2, r4
bcc FillZerobss
/* Call the clock system initialization function.*/
bl SystemInit
/* Call static constructors */
bl __libc_init_array
Solved! Go to Solution.
2021-08-31 04:25 AM
I am use stlink v3 mini debugger so i am got this error. After i am use stlink v2 debugger, program loaded successfully in my target board without any problem
2021-08-30 10:45 AM
Examine the SCB registers for the reason behind the hard fault.
2021-08-30 11:28 AM
>>Any ideas what could be wrong?
Your constructors are touching memory that you haven't properly initialized in SystemInit() ?
ie External Memories (peripherals, pins, clocks, etc)
Are you using C++ ? If not then you probably don't need to be calling __libc_init_array
Look at the .MAP, check where the constructors are being placed, and the settings for those sections in the linker script (.LD)
2021-08-31 04:25 AM
I am use stlink v3 mini debugger so i am got this error. After i am use stlink v2 debugger, program loaded successfully in my target board without any problem