2022-01-14 07:16 AM
Hello,
I used to generate code from STM32CubeMX then edit, compile and flash to board with Keil µVision (default config).
Recently, I followed bootloader tutorial that uses STM32CubeIDE and I must admit it's nice but for exact same source code, the generated code size in way bigger (47k vs 27k) and I need it to fit into 32k...
The Debug / Release configuration is unclear to me as well as compiler directive, isn't it technically possible to configure STM32CubeIDE to generate exact same code as Keil µVision from exact same source files ?
Hope someone can help :)
Have a good day,
Thomas
Solved! Go to Solution.
2022-01-14 12:04 PM
Changing debug level can little modify size , but more priority setings is Optimizing levels. try check and change -O0 to -Os
In Project -> Properties -> C/C++ Build -> Settings - MCU GCC Compiler - Optimization
for C++ too in
In Project -> Properties -> C/C++ Build -> Settings - MCU G++ Compiler - Optimization
And for primary quesstion Keil is comercial compiler ... more money more effective optimizing
2022-01-14 07:22 AM
Dear @Thomas LB ,
It's expected to have different sizes between two different compilers. Moreover even with the same IDE with different version you can have different code size even with the exact same code ..
So the only thing to do is to play with the Optimization of the tool in order to let your code to fit into 32k.
SofLit
2022-01-14 08:47 AM
Thank you for answering,
But I'm pretty sure I'm missing something. When I go in Project -> Properties -> C/C++ Build -> Settings -> and change here the debug level from max (g3) to none and also remove preprocessor instruction DEBUG. The generated code size doesn't changed.
After rebuilding project from scratch from cubeMX, now I can see big difference between Debug and Release version code size (was buggy for some reason).
Effectively removing debug information leads to more reasonable code size :)
2022-01-14 12:04 PM
Changing debug level can little modify size , but more priority setings is Optimizing levels. try check and change -O0 to -Os
In Project -> Properties -> C/C++ Build -> Settings - MCU GCC Compiler - Optimization
for C++ too in
In Project -> Properties -> C/C++ Build -> Settings - MCU G++ Compiler - Optimization
And for primary quesstion Keil is comercial compiler ... more money more effective optimizing
2022-01-21 02:08 AM
Seems the "Build Analyser" view is not well refreshed sometimes (that's why I was confused in the first place)If I rebuild, the Build Analyser data doesn't update. Sometimes it works sometimes not. Havent figured out yet what could be the root cause