cancel
Showing results for 
Search instead for 
Did you mean: 

when I build the project, it is showing the error of 1. .text' will not fit in region `FLASH' 2. `FLASH' overflowed by 12480 bytes

RKUMA.2
Associate II

Hello everyone,

I am working with stm32f070c6 , I am developing an application of USB_CDC , When I build the project it is showing the error of 

1. .text' will not fit in region `FLASH'

2. `FLASH' overflowed by 12480 bytes

actually I had increase the heap size to 0x400 and stack size 0x400, In my program I am using a buffer size of 64 bytes,

can you please help me out how to overcome flash overflow error.

1 ACCEPTED SOLUTION

Accepted Solutions
Antypas.Peter
Senior

A few things I do with every ARM Cortex:

  • Compile with the link time optimizer (-flto)
  • For release builds, unless I absolutely need speed optimizations, I optimize for size (-Os)
  • Let the linker remove unused sections (--gc-sections)
  • Link with newlib-nano (--specs=nano.specs)
  • Never use syscalls (--specs=nosys.specs)

If none of these do the trick, then there must be something in your project that allocates large chunks of FLASH. Any large static const arrays, by any chance?

View solution in original post

6 REPLIES 6
TDK
Guru

Options:

  • Reduce the size of your program. One easy way to do this is to compile in Release mode.
  • Switch to a different chip with more memory.
If you feel a post has answered your question, please click "Accept as Solution".

Perhaps review what exactly you have sucking up all the resources, is it code, or static data?

You can perhaps tell the linker it has more memory to work with so it can get closure, and then inspect the .MAP to determine the resource hogs.

Bitmaps? Data Tables?

Are you using a lot of heap space? How much stack is actually being utilized?

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

Thanks for your reply @TDK is there any alternatives to overcome that flash overflow error, I reduced the static variables in my program but the problem is remains same

Can’t use more memory than you have on the chip. Pretty simple concept.
If you feel a post has answered your question, please click "Accept as Solution".
Antypas.Peter
Senior

A few things I do with every ARM Cortex:

  • Compile with the link time optimizer (-flto)
  • For release builds, unless I absolutely need speed optimizations, I optimize for size (-Os)
  • Let the linker remove unused sections (--gc-sections)
  • Link with newlib-nano (--specs=nano.specs)
  • Never use syscalls (--specs=nosys.specs)

If none of these do the trick, then there must be something in your project that allocates large chunks of FLASH. Any large static const arrays, by any chance?

Can you elaborate on how to make these changes? I'm a newbie to CubeIDE. Thanks!