Even after building code with optimization level -0s. There is no change in size, it just get adjusted with .text and .data.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-05-10 8:10 AM
I am facing issue of memory with Stm32L432xx, So i tried option of increase optimization level from -01 to -0s.
But observe no change it just reduce in .text section... but it increased in .data segment. ultimately value is same and issue is continue
Before optimization i.e -01
text data bss dec hex filename
117760 11264 30064 159088 26d70 build/app-firmware.elf
After optimization level set -0s
text data bss dec hex filename
117480 11544 30064 159088 26d70 build/app-firmware.elf
Solved! Go to Solution.
- Labels:
-
STM32CubeIDE
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-05-10 8:42 AM
Optimisation affects the code generated. The .text section is where the generated code goes - so that's where you'd expect to see any changes!
-Os optimises for the size of generated code - smaller code might require extra RAM.
Optimisation documentation:
https://gcc.gnu.org/onlinedocs/gcc-4.1.2/gnat_ugn_unw/Optimization-Levels.html
https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html
The main "consumer" of RAM is variables declared by your code, So, to reduce RAM usage, you're going to have to review your code for what is using memory, and think how you can reduce that.
The linker map file should help you with that.
Also the nm utility: https://sourceware.org/binutils/docs/binutils/nm.html
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-05-10 8:42 AM
Optimisation affects the code generated. The .text section is where the generated code goes - so that's where you'd expect to see any changes!
-Os optimises for the size of generated code - smaller code might require extra RAM.
Optimisation documentation:
https://gcc.gnu.org/onlinedocs/gcc-4.1.2/gnat_ugn_unw/Optimization-Levels.html
https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html
The main "consumer" of RAM is variables declared by your code, So, to reduce RAM usage, you're going to have to review your code for what is using memory, and think how you can reduce that.
The linker map file should help you with that.
Also the nm utility: https://sourceware.org/binutils/docs/binutils/nm.html
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-05-11 2:30 AM
To add to what Andrew mentioned, to see what consumes the most memory of your application you can use the Build Analyzer inside STM32CubeIDE. Choose "Show Byte" and sort by the "Size" column as shown in the screenshot below:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-05-11 3:02 AM
Although @PSola.1​ seems to be concerned about RAM - not Flash?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-05-11 4:04 AM
Or that the 128KB FLASH of the L432RB is all consumed. Same die used for the RC device.
​
Optimization can't fix algorithmic issues, or compress data structures.
​
Will need to make things more efficient, use subroutines for repetitive code, use of structures and tables, compress or encode data better, determine scope of buffers, don't make everything global, especially stuff used once at initailization.
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-05-16 9:02 AM
Thanks for help @Andrew Neil (Community Member), I have re organize linker file by keeping 127k for flash and 1k for NV data
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-05-16 9:52 AM
and does that help?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-06-13 11:15 AM
Ironically the screenshot also clearly shows how bloated the HAL is - the clock initialization with HAL_RCC_***() and some companion functions wastes 2 KB of flash.
