cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L011G4U6TR build Error: Flash Overflow

Shiv09
Associate III

Hello All,

 

I am using STM32L011G4U6TR for one of my application development.

 

I have written a code where I am using,11 GPIO, 1 UART and Internat EEProm.

When I am building the code in I am getting below Error and not able to load the Application on STM32L011G4U6TR board.

If someone could guide how to resolve it, would be helpful. (Have removed the unnecessary arrays variables and using minimum variables to optimized ).

 

Description Resource Path Location Type
IPL_Handpiece_Control_Board_Firmware.elf section `.text' will not fit in region `FLASH' IPL_Handpiece_Control_Board_Firmware C/C++ Problem
make: *** [makefile:64: IPL_Handpiece_Control_Board_Firmware.elf] Error 1 IPL_Handpiece_Control_Board_Firmware C/C++ Problem
region `FLASH' overflowed by 568 bytes IPL_Handpiece_Control_Board_Firmware C/C++ Problem

Shiv09_0-1752586521299.png

 

Note when I am commenting some part of needed code then, I am able to load it and debug, but I need all the GPIO, UART, EEprom working together. Will do as per suggestions.

 

Regards,

SMD

 

1 ACCEPTED SOLUTION

Accepted Solutions

Try sorting the list by size, and look at the largest things ...

 

Have you tried increasing optimisation yet?

One key optimisation is that unused functions don't get included in the final image ...

GCC Optimisation levels are documented here;

https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html

"-Og should be the optimization level of choice for the standard edit-compile-debug cycle, offering a reasonable blend of optimization, fast compilation and debugging experience" - see here.

 

PS:

AndrewNeil_0-1752659344850.png

 

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.

View solution in original post

7 REPLIES 7
TDK
Super User

Your program is limited to the amount of FLASH available.

To reduce program size, you can do a few things:

  • Comment out unnecessary code or otherwise streamline code.
  • Use the Release Configuration rather than Debug Configuration.
  • Compile with higher optimization settings.
If you feel a post has answered your question, please click "Accept as Solution".
Andrew Neil
Super User

@Shiv09 wrote:

I am using STM32L011G4U6TR


So it has only 16K of Flash.

The message tells you that you are 568 bytes over that:

IPL_Handpiece_Control_Board_Firmware C/C++ Problem
region `FLASH' overflowed by 568 bytes IPL_Handpiece_Control_Board_Firmware C/C++ Problem

 


@Shiv09 wrote:

Have removed the unnecessary arrays variables and using minimum variables to optimized


That would reduce RAM use, but it's Flash that's overflowing - not RAM.

You need to reduce the code size.

Use the CubeIDE Build Analyser to see what, exactly, is using up all the space.

common space hogs include

  • floating-point
  • printf
  • possibly HAL

As @TDK suggested, try a higher optimisation setting.

 

PS:

AndrewNeil_0-1752587644153.png

https://www.st.com/resource/en/user_manual/um2609-stm32cubeide-user-guide-stmicroelectronics.pdf#page=129

 

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.

Hello @Andrew Neil 

Thanks for the reply, Yes tried to go as per your suggestions, I can see the HAL functions and some Implemented functions (these having lower size), so any best possible way to optimize more and use the code ?

Shiv09_0-1752658809126.png

Try sorting the list by size, and look at the largest things ...

 

Have you tried increasing optimisation yet?

One key optimisation is that unused functions don't get included in the final image ...

GCC Optimisation levels are documented here;

https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html

"-Og should be the optimization level of choice for the standard edit-compile-debug cycle, offering a reasonable blend of optimization, fast compilation and debugging experience" - see here.

 

PS:

AndrewNeil_0-1752659344850.png

 

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.

Hello @Andrew Neil ,

 

Thanks for sharing the information, Yes it did worked well, have saved now 4kb memory.

 

Regards,

SMD 


@Shiv09 wrote:

have saved now 4kb memory.


That's good.

For the benefit of future readers in the same situation, how did you do that?

Just by changing optimisation, or (also) by removing stuff?

If by removing stuff - what stuff?

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.

Hello @Andrew Neil,

Yes Sure,

For me I have removed some additional wrapper functions (Which were created for STM32H series Application, used in other project for some additional check and validation), now I have used simple HAL functions which are created during code generation.

Disabled and removed the I2C from .ioc , (which is not going to be used any more).

Then tried to Optimize from Properties settings to "Optimize More for size (-Oz)", 

This worked well without any trouble in firmware operation.

 

 

Shiv09_0-1752833384956.png