2024-07-23 09:10 AM
... leads to "funny" results:
STM32L011 with 16 kB of flash, HAL inits and LED toggle in main, DEBUG, no optimization:
93% of flash used
I had not expected it to be that bad! :grinning_face_with_sweat:
Okay, I will probably not use too much HAL, will use Release version with optimization,
but I better select an L01 in the next bigger QFN package (4x4) to get 32 kB of flash.
2024-07-23 09:37 AM
Your screenshot show many peripherals , then maybe your LED toggle count bitcoins too ...
2024-07-23 09:44 AM
Show the results with "Optimise for Debug" (-Og).
You should also take a look at the map file - is it actually HAL that's using all that space ... ?
:thinking_face:
2024-07-23 10:59 AM
The Memory Details tab gives you more insights.
hth
KnarfB
2024-07-23 10:37 PM
Yes, luckily I know all that - it was just a bad surprise and might deter some complete STM32 beginners.
So, this wasn't actually a call for help, just ... being "amazed" at how things are. Until now I only worked with "bigger" STM32 (G4, F7, H7), and occasionally using HAL or at project start wasn't a problem.
The list file showed mostly the "bloated" HAL inits - I actually forgot about the "Memory Details", thanks @KnarfB .
With release / optimization to size, it drops to 56%.
Record holder is HAL_RCC_Config with 1.15 kB, together with HAL_RCC_ClockConfig and HAL_RCCEx_PeriphCLKConfig taking up even more than 10% of the 16 kB.
These are the HAL setup functions I always use - I guess I have to overcome my laziness in that area.
BTW - RAM: the default CubeMx settings for heap and stack also took up ~90% :D
2024-07-24 06:27 AM
In MX you can very easy switch some parts to LL
2024-07-24 10:01 PM
If this MCU will be used in a product, I will probably throw out the HAL stuff anyway (I don't like the LL either, so direct register settings for me).
I was just really shocked that a basically empty project - except for the inits - with all defaults from CubeMX leads to this memory usage: > 90% for flash and RAM.
2024-07-25 02:40 AM
@LCE wrote:I was just really shocked that a basically empty project - except for the inits.
Probably, the inits are where 90% of the code lies!
So what do you get if you don't init any peripherals?
And then there's the C runtime support - how much did that amount to?
2024-07-25 07:54 AM
> Probably, the inits are where 90% of the code lies!
Definitely!
I just switched to its next big brother with 32 kB SRAM, switched all to LL instead of HAL.
Release with no Opt: 9.57 kB flash
Release with Opt for size: 4.14 kB flash <- I hadn't expected that with LL
> And then there's the C runtime support - how much did that amount to?
Erm... where's that? Isn't that for memory allocation and stuff like that - which I don't use?
2024-07-25 08:01 AM
@LCE wrote:Erm... where's that? Isn't that for memory allocation and stuff like that - which I don't use?
There's a lot more to it than that!