Jan 012009
 
GCC and Small Code

Compiling even small code results in a large amount of extra code added by gcc itself: the library routines to divide 32 bit numbers for example. Usually nothing to worry about, but if you program for a LPC2103 with 32kByte FLASH, and FreeRTOS already takes up a seizable bunch, then you start to wonder how to get rid of those extra and unused library functions.

Found at embeddedrelated.com

You need to do a “garbage collected build” using gcc options:

-ffunction-sections
-fdata-sections

and ld options:

–gc-sections

The difference for a the lamp control program is 73kByte before and 48kByte after adding those options.

Update: While the code is small, it does not load via lpc21isp (address out of range it says). So the LPC2103 with 32kByte FLASH needs to wait a bit longer until I can use it.

Update: The LPC2106 Demo code in FreeRTOS v5.1.0 compiles into 21kByte code. For now that’ll do as it leaves about 10kByte space for user programs on an LPC2103.