cancel
Showing results for 
Search instead for 
Did you mean: 

Save flash when using printf and floating-point on STM32F0

istepne
Associate III

Originally a reply to this thread:

https://community.st.com/t5/stm32-mcus-embedded-software/how-generate-hex-file-without-link-files-hal-drivers/td-p/723141

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

4 REPLIES 4

@istepne wrote:

Please let me know which settings is this. 


This one:

https://community.st.com/t5/stm32-mcus-embedded-software/how-generate-hex-file-without-link-files-hal-drivers/m-p/723990/highlight/true#M55354

 

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.

@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

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?

KnarfB
Principal III

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