cancel
Showing results for 
Search instead for 
Did you mean: 

STM32CUBEM MX generated HAL code size is more

Hi, I am using STM32F746 discovery board and I generated code using STM32CUBEM MX. I just enabled external crystal as clock and UART. My .text session code size is 10188 bytes which is like 10KB. I wanted to add this code as bootloader but I feel 10KB size just for HAL library initialization is too much.

Does generally STM HAL take this much size or I made any mistake? This is for my bootloader code so I don't want to give so much space to it.

0693W000004IQGWQA4.png

Thanks

3 REPLIES 3
TDK
Guru

Sounds about right. The convenience of HAL comes at a cost. You could examine the map file and see what's taking the majority of space to try to cut it down. Ensure optimization is set to max and don't output any debug information.

If you feel a post has answered your question, please click "Accept as Solution".

I updated optimization to (-O3) but still its 9816 means 9.5Kb. Still I think its too much.

Piranha
Chief II

Actually O3 significantly increases code size to gain speed. O2 generally is the most balanced level. Os is similar to O2 but favors small code size instead of speed.

https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html

P.S. No optimization can change the fact that the HAL is a broken bloatware...