Saturday, April 19, 2014

Reducing code size for embedded ARM processors

There are a few options that make the code size smaller when using GCC for embedded ARM processors.

The newlib has a nano version which is optimized for small embedded processor. To activate newlib-nano, add the option -specs=nano.specs to the linker.  The newlib-nano printf does not print floating number format.

Another linker option --gc-sections removes unused sections.  To facilitate gc-section, compile each function and data item into its own section by passing `-ffunction-sections' and -fdata-sections

The optimizer can be specified to generate smaller code with the -Os option.

Keil ARM compiler consistently produces much smaller code, often 50% smaller.   Especially the math library is not only much smaller but also much high performance.

No comments:

Post a Comment