**** Advance Notice ****

This site will be closed on 31 December 2015,

Important Information for users of NXP LPCXpresso

This site is for users of Code Red branded products.

NXP LPCXpresso users should visit the LPCXpresso FAQ's for up-to-date information relevant to that product.

Debug build too big to fit into flash

Sometimes as you are developing your application, you may reach the point where the Debug build of your application becomes too big to fit into the flash on your MCU, even though a Release build will still fit into the flash. In such cases you will see a link error similar to the following:

ld.exe: myapp.axf section .text will not fit in region MFlash8
ld.exe: region MFlash8 overflowed by 356 bytes
collect2: ld returned 1 exit status
make: *** [myapp.axf] Error 1

However switching over to developing using the Release build may not be suitable, due to the constraints this may put onto the debug view you then get of your code, as discussed in the FAQ on Compiler Optimization.

However, it may be possible to build certain parts of your application at a higher level of optimization, whilst keeping the areas that you actually need to actively debug being built for -O0.

One way to do this may be to switch any library projects that you application uses so that they build at a higher optimisation level. One good example of this is the CMSIS library project. In most cases you will not need to actively be debugging the code within this, so you could change the optimization used by the Debug build of this from -O0 to -Os.

If this still does not produce the code size reduction required, then you could try changing the optimization level used for compiling various files within your main application project. For example you could change the default optimization level for the project from -O0 to -Os, and then change the optimization level of files or groups of files that you are actively going to debug back to -O0.

For more information, please see the FAQs on

DebugBuildTooBig (last edited 2010-11-07 20:44:05 by CrSupportAb)