2025-12-05 9:55 PM - last edited on 2025-12-06 1:23 AM by Andrew Neil
Hi there!
Im currently learning STM32 MCUs using Nucleo-F446RE
I wrote two 'Blinky' firmwares:
*One using HAL and CubeMX (.ioc file)
*A second one using just HAL (NO CubeMX)
What does the FW does?: It just uses the user button on the nucleo, reads the state and "mirrors" that state on the user LED on the nucleo
In the project using CubeMX the firmware works in debug mode and in run mode (directly running on the board)
But in the project that doesnt use CubeMX the firmware works fine in debug mode but it doesnt in run mode
Both projects compile with 0 errors and 0 warnings for both, debug and release
I have read the RM and the HAL documentation but i dont have a clue where is the problem
I tried all the solutions from chatGPT and still it doesnt work
Can you help me please?
What am i doing wrong?
I let you the link to my projects if you need to check something
Maybe the STM32CubeF4 version? (weird because both projects use the same version)
Thanks in advance!
Projects link: https://drive.google.com/drive/folders/1xs8ck-L0GyELmdG6uNVZT-bSjg4GwUFW?hl=es-419
2025-12-05 11:05 PM
Just HAL is what? FYI generated project isnt only main.c , exist startup asm and c parts. How you handle this...
2025-12-06 1:38 AM
@Cblue_X wrote:in the project that doesnt use CubeMX the firmware works fine in debug mode but it doesnt in run mode
What, exactly, does happen in "run" mode ?
Are you running the exact same binary, or are you rebuilding for Debug/Release ?
Note that you can connect to a running (or "stuck"/"crashed") system without having to reset & do a download:
It sounds like something is wrong/missing in your startup/configuration - so carefully compare & contrast the working & non-working case...
2025-12-07 10:55 AM
Well, i used the startup and other sources directly from STTM32CubeF4 but with no modifications, maybe was my mistake to think that it will work
2025-12-07 11:59 AM - edited 2025-12-07 12:33 PM
Nothing happens, i just wrote a HAL_Write at the beggining of the program and nothing happens
I Build the project with CubeMX, for debug and it works, then for release and it works too
Then i build the project without CubeMX neither one works
Was that what you saked me @Andrew Neil ?
"Are you running the exact same binary, or are you rebuilding for Debug/Release ?"
I use the automatically generated startup file for the empty project (NO cubemx)
TBH i do know how to code the startup file
I tried to use the startup from the cubemx project in the NO cubeMX project but still didnt work
Any sugestions?
Or i must dive into the startup file? Because, i worte a program for STM32F429ZI bare metal no hal, no cubemx, using the startup from STM32CubeF4 for this particular MCU and it worked fine for debug and run
2025-12-07 1:04 PM
@Cblue_X wrote:But in the project that doesnt use CubeMX the firmware works fine in debug mode but it doesnt in run mode
What do you mean "use CubeMX"? The project doesn't "use" CubeMX. CubeMX merely generates code.
You can use comparison tools such as winmerge or diffmerge to compare the source folders of both projects and see if there is a difference.
What do you mean "debug mode". Do you mean flashing the binary from the Debug build? Or do you mean starting a debug session in the IDE? What do you mean it doesn't work? If you step through the program does it work? Are you on a breakpoint?
Have you tried flashing with STM32CubeProgrammer?
2025-12-07 1:31 PM - edited 2025-12-07 1:35 PM
When i say 'using cubemx' i mean that is a STM32 project of type 'STM32Cube', and when a project 'without CubeMX' i mean a STM32 project of type 'Empty'
Sorry for the wrong terms
What do you mean "debug mode"
I mean starting a debug session in the IDE, here both projects work as expected, using a breakpoint in the infinite loop (the line that read the state of the user button)
What do you mean it doesn't work?
I mean that when i flash the firmware on the nucleo board (click run in the stm32cubeide) the project of type 'empty' juts do nothing, the Error_Handler function never gets called and for some simple debugging i made i noticed that is like the main function never gets executed
I would give it a try with winmerge but, idk if is worth at this moment because first of all i dont know how to program the startup file
Second, i changed the startup from the empty project (autogenerated by the IDE) with the startup from the project of type STM32Cube and still didnt work when the firmware is flashed
I tried also changing the autogenerated startup to the startup code from the STM32CubeF4 package for the 446re and still didnt worked
A few weeks ago i wrote a blinky firmware for nucle-F429ZI bare metal, using the startup from STM32CubeF4 package and the firmware worked when it was flashed to the nucleo board, so im wondering why now it isnt working
2025-12-08 12:24 AM
You definitely need to make sure there is some startup code being called - it's responsible for a lot of things, including setting up the stack, configuring the clock tree and memory timings, and initialising the C runtime environment before making a call to main(). If that doesn't happen, then I wouldn't expect anything else to work (but it might, depending on what the default values are),
2025-12-08 1:13 AM
@Cblue_X wrote:
What do you mean it doesn't work?
I mean that when i flash the firmware on the nucleo board (click run in the stm32cubeide) the project of type 'empty' juts do nothing, the Error_Handler function never gets called and for some simple debugging i made i noticed that is like the main function never gets executed
Sometimes you need to reset the board before it starts running.