In this post, we will review compiler options that we can use to reduce firmware code size. We will focus on
arm-none-eabi-gcc, the GCC compiler used for ARM-based microcontrollers, though most of the compile-time flags we will cover are available in other GCC flavors as well as in Clang.
Every firmware engineer has run out of code space at some point or another. Whether they are trying to cram in another feature, or to make enough space for A/B firmware updates more code space is always better.
In this series of posts, we’ll explore ways to save code space and ways not to do it. We will cover compiler options, coding style, logging, as well as desperate hacks when all you need is another 24 bytes.
But first, let’s talk about measuring code size.