Sysprogs forums › Forums › VisualGDB › optimising build size
- This topic has 5 replies, 2 voices, and was last updated 8 years ago by
Dubbie.
-
AuthorPosts
-
June 14, 2018 at 06:37 #21098
Dubbie
Participanthi,
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 bytesThe 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.
June 14, 2018 at 09:23 #21099Dubbie
ParticipantHere 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.June 14, 2018 at 23:45 #21110support
KeymasterHi,
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.
June 15, 2018 at 02:22 #21117Dubbie
ParticipantThanks 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.
June 15, 2018 at 03:08 #21118support
KeymasterHi,
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.
June 15, 2018 at 09:07 #21122Dubbie
ParticipantThe 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.
-
AuthorPosts
- You must be logged in to reply to this topic.