2025-03-10 8:31 AM - last edited on 2025-03-11 1:37 AM by Andrew Neil
Originally a reply to this thread:
Split as it seems to be a different issue.
Hi,
I have same issue too
I am using STM32F051R8 with STM32CubeIDE Version: 1.18.0
There is limited Flash memory. So when I am checking the memory I found some library names etc definition strings on my hex file. I tried to change some setting according to topics above but no success at all
Please let me know which settings is this. Also I am using optimization "Optimize for size -s"
Regards
Murat
Solved! Go to Solution.
2025-03-15 5:09 AM
@istepne wrote:if it possible to remove this textures (sic?) from flash makes more space for me.
You mean text ?
As @KnarfB said, the space taken by the text is insignificant - it's the use of floating-point and printf that's really eating the flash space!
@istepne wrote:This is an old project and old electronic board desing.
So why are you adding floating-point at this late stage?
2025-03-10 8:38 AM - edited 2025-03-10 8:46 AM
@istepne wrote:Please let me know which settings is this.
This one:
PS:
It will be in your stm32xxxx_hal_conf.h file:
/* ########################## Assert Selection ############################## */
/**
* @brief Uncomment the line below to expanse the "assert_param" macro in the
* HAL drivers code
*/
/* #define USE_FULL_ASSERT 1U */
As shown above, it is not defined.
2025-03-11 12:13 AM
@Andrew Neilthank you for the answer.
I realized that it comes from the floating library. I need to use printf with floating point operations enabled.
I made a new project and just compiled it, it tooks 2,99 kbyte memory. After than I enabled the floating feature on settings and compiled again (either debug or release mode) . Then it tooks 23,52kbyte (huge increase). I see the texture on the hex file again with a blank project.
I need Flash memory space on this the older board (can not change the MCU).
Is there a way to disable this strings from hex file to get more space?
Or any other solution like lightweight floating point library etc
Regards
Murat
2025-03-11 1:33 AM - edited 2025-03-11 1:39 AM
This doesn't sound like the same problem as the OP - which was solved as described.
Edit: So split to a separate thread.
@istepne wrote:I see the texture on the hex file again with a blank project
What, exactly, do you mean by that? How are you viewing it?
Please give full details of the tools & procedures used, and show what you're seeing.
@istepne wrote:I need (sic?) to use printf with floating point operations enabled.
Do you really need to?
Both Floating Point and printf can use a lot of flash - so, when flash space is limited, maybe try to avoid both?
2025-03-11 1:54 AM
Look into alternative printf implementations like GitHub - charlesnicholson/nanoprintf: The smallest public printf implementation for its feature set. and avoid using the printf provided in newlib.
hth
KnarfB
2025-03-12 8:44 AM - edited 2025-03-12 8:46 AM
@Andrew Neil I was trying to find this topic..
I used ST-LINK Utility to display hex file and as you see there is some link names. Tihs is a complete blank project and compiled with floating feature enabled as shown below pictures.
I also compiled as "debug" and "release" modes, the result is same on the hex file output.
Flash usage also looks like too much
2025-03-13 12:57 AM
I could reproduce this behaviour.
- STM32CubeIDE 1.18.0 clean install on Win 11, no upgrade
- new empty STM32F051R8 project
- added your settings
- release config
- added code in main to force printf inclusion
volatile float x = 3.14159f;
printf("x=%f\n", x);
The created .bin contains "few" strings which are probably from assert statements in newlib:
But, the main contribution to the .bin file size is from the printf floating point support:
hth
KnarfB
2025-03-15 12:24 AM
Dear @Andrew Neil I would like to thank you for your effort and taking time.
This is an old project and old electronic board desing. So we do not want to change the older boards (we consider to just firmware update to them)
As this IC has small flash memory, we are using many features of it, like DAC, ADC channels, EEProm evaulation on it, we need every bytes to recover if it can. So, if it possible to remove this textures from flash makes more space for me.
I will try to use without floating point operations like when 2000s with 8bit controllers :)
As you stated earlier, I will try to remove both printf and floating point usages (in many case, using the printf, just used to put dot point between integer values)
Regards,
Murat
2025-03-15 5:09 AM
@istepne wrote:if it possible to remove this textures (sic?) from flash makes more space for me.
You mean text ?
As @KnarfB said, the space taken by the text is insignificant - it's the use of floating-point and printf that's really eating the flash space!
@istepne wrote:This is an old project and old electronic board desing.
So why are you adding floating-point at this late stage?
2025-03-15 6:19 AM
Try use KEIL for fpu and omit printf float support.