cancel
Showing results for 
Search instead for 
Did you mean: 

Deleting of ".elf" file in MacOS sequoia 15.2

Tunahan
Associate

 

Hi everyone,

 

I’m using a MacBook with an Apple M1 chip running macOS Sequoia 15.2. I recently updated STM32CubeIDE to version 1.18.1.

 

My target board is a Nucleo-32 STM32L031K6T6. Initially, I created a new project using STM32CubeIDE and, without modifying anything, successfully debugged the automatically generated code. I noticed that the .elf file was correctly generated in the Debug folder.

 

Then, I added a very simple code snippet to send a value over the serial port, just to test functionality. However, when I ran the code, I got the following error:

 

/Applications/STM32CubeIDE.app/.../ld: oc4.elf section `.text' will not fit in region `FLASH'
/Applications/STM32CubeIDE.app/.../ld: region `FLASH' overflowed by 6884 bytes
collect2: error: ld returned 1 exit status
make: *** [makefile:64: oc4.elf] Error 1

 

After this error, the .elf file disappeared from the Debug folder. It seems that STM32CubeIDE generates the .elf file initially but deletes it after.

 

Has anyone experienced this issue before?  How can I solve this problem?

 

Thanks in advance!

1 ACCEPTED SOLUTION

Accepted Solutions
TDK
Super User

If your program is too large to fit into flash, compilation will not complete and the ELF will not be generated.

You will need to reduce the code size in order to compile the program. One way to do this is to switch to the Release configuration, although this makes the code harder to debug as things are optimized away.

 

The STM32L031K6T6 only has 32 kB of flash, which is rather restrictive. The HAL library wasn't really set up with this amount of limited resources in mind.

If you feel a post has answered your question, please click "Accept as Solution".

View solution in original post

5 REPLIES 5
TDK
Super User

If your program is too large to fit into flash, compilation will not complete and the ELF will not be generated.

You will need to reduce the code size in order to compile the program. One way to do this is to switch to the Release configuration, although this makes the code harder to debug as things are optimized away.

 

The STM32L031K6T6 only has 32 kB of flash, which is rather restrictive. The HAL library wasn't really set up with this amount of limited resources in mind.

If you feel a post has answered your question, please click "Accept as Solution".
AScha.3
Super User

To reduce the program size, try: set optimizer -O2 , then compile.

If you feel a post has answered your question, please click "Accept as Solution".
ahsrabrifat
Senior II

Sometimes, STM32CubeIDE defaults to incorrect settings. Check the following:

  • Open .ioc file

  • Go to Project Manager → Project Settings → MCU Settings

  • Make sure the selected device is: STM32L031K6Tx and the memory size is 32 KB Flash, 8 KB RAM

 


@AScha.3 wrote:

To reduce the program size, try: set optimizer -O2 , then compile.


@Tunahan  Before that, I'd try 'Optimise for Debug (-Og)'

AndrewNeil_0-1747066043312.png

This should give you the best compromise between optimisation & "debuggability"

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

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.

@TDK wrote:

If your program is too large to fit into flash, compilation will not complete and the ELF will not be generated.


^^ This! ^^


@TDK wrote:

You will need to reduce the code size in order to compile the program. One way to do this is to switch to the Release configuration, although this makes the code harder to debug as things are optimized away.


@Tunahan  Or set your Debug configuration to use -Og - see my earlier reply.

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.