cancel
Showing results for 
Search instead for 
Did you mean: 

What limits stack size?

CYesi.1
Associate II

Hello 

I am working on STM32L072 series MCU. I am using Stm32cubeide

My project is using %94 of RAM. I need more stack on my project. I tried to increase stack in linker file, but i get error. I think, there is enough area in my ram. Additionally, I can increase Heap size. But, IDE doesnt allow to increase stack size.

Is there any ram area allocated for heap? Or, why can not I use my free memory for stack?

Thank you

4 REPLIES 4
Nikita91
Lead II

To know exactly how the RAM is used have a look to the Debug/xx.map file (xx is the project name).

CYesi.1
Associate II

Thanks for your answer.

I have one more question. I moved a project from uVision to Stm32CubeIde. There is a difference between Ram usages. Same project compiling with STM32CubeIde use more Ram space. Do you know what is the reason?

Pavel A.
Evangelist III

> Is there any ram area allocated for heap? Or, why can not I use my free memory for stack?

With a normal GNU-style linker script and library (newlib/nano) heap and stack share the same space.

Stack and heap sizes are defined as two separate constants, but actually it is single area with size = sum of two.

If your program does not use heap (malloc or sbrk), the whole space is available for stack.

If you have a custom link script, all bets are off.

> Same project compiling with STM32CubeIde use more Ram space. Do you know what is the reason?

Keil compiler and libraries are more frugal? At 94% of capacity this becomes noticeable.

-- pa

Cartu38 OpenDev
Lead II

Takes care too to your compiler optimization settings. Default build configuration is debug oriented one not promoting best binary memory footprint. Some release configuration is avaible too. Then up to you to perfom proper tuning.​