Showing results for 
Search instead for 
Did you mean: 

How to reduce the size of build file.

Associate III


I was trying to convert a code written in HAL to baremetal for reducing the size. The code in HAL has 90KB file size when build in Debug mode and has 50KB file size in Release mode. In case of baremetal 73KB and 63KB respectively for Debug and Release modes. How can I reduce the file size of baremetal code than the HAL Release mode.


Perhaps review .MAP​ and .LST​, look at what's eating the most memory.

If there's repetitive stuff that could be a subroutine or otherwise factored.

Compilers are not good with intent or identifying algorithms.

A lot of register code is very inefficient, using a lot of individual RMW code that the compiler can't fold due to the volatile and in-order expectations constraining it. Understand the load-store architecture and use your overview to decide what can be folded and where the order is or is not critical. ​

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..