cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L151C8T6 launches STM32CubeMX generated code into Hardfault

David Koster
Associate II

Hey all! I'm working on a project with the STM32L151C8T6. However, my STM32CubeMX generated project (For STM32CubeIDE) launches straight into a hardfault. Any idea what could cause this or what I could debug to get this to work? I've already generated a new empty MX project that doesn't have anything configured - same problem. Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions

Check the linker script, and where it is placing things like the stack.

Off the top of my head this part should have at least 64KB FLASH and 16KB RAM on-die

Check the .MAP file.

If there is an option to uncheck "run to main()" use that and walk it in.

Check constructor initialization in startup.s, and if you need that (.cpp) , comment out if not

/* Call the clock system intitialization function.*/

 bl SystemInit

/* Call static constructors */

/*  bl __libc_init_array */

/* Call the application's entry point.*/

 bl main

Oddly a NRND, but free-stock..

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

View solution in original post

2 REPLIES 2

Check the linker script, and where it is placing things like the stack.

Off the top of my head this part should have at least 64KB FLASH and 16KB RAM on-die

Check the .MAP file.

If there is an option to uncheck "run to main()" use that and walk it in.

Check constructor initialization in startup.s, and if you need that (.cpp) , comment out if not

/* Call the clock system intitialization function.*/

 bl SystemInit

/* Call static constructors */

/*  bl __libc_init_array */

/* Call the application's entry point.*/

 bl main

Oddly a NRND, but free-stock..

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
David Koster
Associate II

You're my man! Turns out I had accidentally generated the project for the STM32L151C8T6A, the not NRND version of the chip that has 32KB RAM. That properly messed things up.

Have a nice week,

David