Skip to main content
Explorer
April 30, 2024
Question

STMCube IDE -u_printf_float taking upto 15KB Flash space on STM32F103C6T6

  • April 30, 2024
  • 3 replies
  • 1716 views

Hi,

I am having stm32F103C6T6 Development Board. When i enable -u_printf_float flag for Float printing on 16x2 LCD it takes upto 15KB of total space .

Please guide. what else can be done ?

 

-u_printf_float Enabled :

asking_0-1714469899847.png

 

Without Flag for Float

asking_1-1714470454610.jpeg

 

 

 

    This topic has been closed for replies.

    3 replies

    Super User
    April 30, 2024

    The stm32F103C6T6 has no hardware floating point, so it all has to be done in software - which uses up flash space.

     


    @asking wrote:

    what else can be done ?


    Don't use floating point!

     

    Graduate II
    April 30, 2024

    The math can be done without printing, and the printing portion probably isn't going to get markedly smaller on a library using an FPU, faster perhaps. The defaults for printf() is typically the double, so you'd be into the bigger CM7 FPU-D implementations for them to assist with the math. 

    If floating point can be removed that would save the most space. Say an appropriately chosen fixed point or scaled integer?

    Graduate
    April 30, 2024

    Try to set compiler optimization for code space.

    Super User
    April 30, 2024

    Not sure how much that will help, as the software floating point and the printf stuff are in binary libraries...

    :thinking_face:

    Graduate II
    April 30, 2024

    >>Please guide. What else can be done ?

    You could learn or read about things more deeply, so you can think through the situation, rather than be guided at every step?

    Perhaps use your own, lighter weight, application specific variants?

    Could you convert and break down the float values into integer sub-components that you could print with the classic integer formatting methods. ie "%d.%03u"

    Things like dtoa() are quite heavy, probably a large portion of the cost here.

    As Andrew said, the ideal situation might be to not use floating-point. Can your number ranges be accommodated by a fixed point solution using integers?

    You could use a more capable part? One where the 15KB library burden is less onerous to the total available space, and to the application. Some of the newer parts have physically smaller die, but larger memories. Yield per wafer tending to be the driver of cost. Is the 15 year old device the best choice here? You might need to think more deeply here so you can expand your comfort-zone.