Skip to main content
RKUMA.2
Associate III
December 3, 2021
Question

Hello, I AM working on the stm32f070c6 i have write a firmware of it , but it is showing heap and stack overflow ,i just put heap and stack 400, please help me how can i overcome this error please give suggestions thanks in advance.

  • December 3, 2021
  • 3 replies
  • 1705 views

..

This topic has been closed for replies.

3 replies

Mike_ST
Technical Moderator
December 3, 2021

Hello,

Have you tried greater values ?

In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. 
Tesla DeLorean
Guru
December 3, 2021

Without the exact error, build log and context it is hard to know.

My guess is that this is occurring at the Linker level and already using too much memory, so making bigger won't help.

How large is the code being built?​

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
TDK
Super User
December 3, 2021

Use higher optimization settings. Maybe buy a bigger chip.

"If you feel a post has answered your question, please click ""Accept as Solution""."
RKUMA.2
RKUMA.2Author
Associate III
December 4, 2021

thanks for your reply @TDK​ , in the past also i got the same error , but it was removed by make some change in Stm cube IDE >> properties and made some settings so that the error was gone, recently i update stmcube ide , so the same problem occurring. I am using stm32f070c6t6 and heap=400 and stack =400,how can i remove this error. i am not finding the previous suggested pages in the forum.

the error details in consolr as below.

c:\st\stm32cubeide_1.3.0\stm32cubeide\plugins\com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.9-2020-q2-update.win32_1.5.0.202011040924\tools\arm-none-eabi\bin\ld.exe: LLUSBCDC.elf section `._user_heap_stack' will not fit in region `RAM'

c:\st\stm32cubeide_1.3.0\stm32cubeide\plugins\com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.9-2020-q2-update.win32_1.5.0.202011040924\tools\arm-none-eabi\bin\ld.exe: region `RAM' overflowed by 1408 bytes

collect2.exe: error: ld returned 1 exit status

make: *** [makefile:69: LLUSBCDC.elf] Error 1

"make -j2 all" terminated with exit code 2. Build might be incomplete.

Tesla DeLorean
Guru
December 4, 2021

Already too big.

How much heap does it actually use? ie via malloc()/free() used anywhere in your code, or the library/example code.

What it eating up the memory? You could perhaps expand the RAM in the linker script, allowing completion/closure, and then reviewing/auditing the .MAP file,

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
TDK
Super User
December 4, 2021

This is a very conceptually simple problem. You can't fit more information into RAM than the chip has space for. You'll need to cut down on your RAM usage by reducing stack and/or heap size, or reducing use of global variables. There is no magic solution that you can enable that allows you to use more memory than the chip has.

You may also want to verify that the size of the RAM in your linker script correctly matches the size of the RAM given in the datasheet.

High optimization settings tend to help with this problem. Project -> Build Config -> Set Active -> Release.

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