2025-05-09 7:45 AM
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!
2025-05-09 3:37 PM - edited 2025-05-09 3:38 PM
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.