optimising build size

Sysprogs forums Forums VisualGDB optimising build size

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #21098
    Dubbie
    Participant

    hi,

     

    I have a project I am working on for a 32K STM32F0

    Apparently I have run out of space by about 3.5K and I can’t really think of anything meaningful to optimise in order to make the project link.

    This is the error I am getting:

    1>c:/sysgcc/arm-eabi/bin/../lib/gcc/arm-eabi/7.2.0/../../../../arm-eabi/bin/ld.exe: VisualGDB/Debug/indexingCounter section .text' will not fit in regionFLASH'
    1>c:/sysgcc/arm-eabi/bin/../lib/gcc/arm-eabi/7.2.0/../../../../arm-eabi/bin/ld.exe: region `FLASH' overflowed by 3564 bytes

    The code was originally generated by STMCubeMX

    Is there anything I can do to make the project build smaller? It seems like it should easily fit.

    #21099
    Dubbie
    Participant

    Here are the worst offenders from a build that does work (when I comment out a library I wrote)

    Attachments:
    You must be logged in to view attached files.
    #21110
    support
    Keymaster

    Hi,

    One obvious thing to check would be the type of the standard library. Changing it from the regular newlib to newlib-nano (it not already enabled), would normally greatly reduce the binary size.

    You could also try changing the optimization mode to “Optimize for size” via the regular VS Project Properties (not VisualGDB Project Properties).

    Otherwise you would need to inspect the exact functions shown in the memory explorer and see if any of them could be removed/optimized. Enabling reference tracking in the Embedded Memory Explorer (see this tutorial) might help understanding why specific functions are included in the final binary.

    #21117
    Dubbie
    Participant

    Thanks for the tip.

    As you can see from my second screenshot, I did find the embedded memory explorer. Very handy. I am also using the nano lib. Unfortunately, I have to use the float printf support.

     

    I will try the optimise for size flag.

    #21118
    support
    Keymaster

    Hi,

    Great to hear you found the memory explorer useful. There’s not much else to suggest beyond that though – commercial compilers like Keil and IAR are known to produce much smaller code, however they are costly. The only other way to reduce the footprint would be to try optimizing your code.

    #21122
    Dubbie
    Participant

    The optimizing worked great. I now have enough memory to finish my project. It did break my LCD drivers by removing my useless wait loops 😀 However, adding asm (“”) inside the loop made the compiler leave them alone.

    Thanks for the tip.

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.