cancel
Showing results for 
Search instead for 
Did you mean: 

_Min_Heap_Size and _Min_Stack_Size

EŞimş.1
Associate II

Hi ,

Default values of the _Min_Heap_Size and _Min_Stack_Size is setting according to What? I changed these variables from 0x200 , 0x400 to 0x00 and 0x00 resprectively ,end then no problem,no error .I guess that Static and dynamic variables in RAM are in the RAM Base Addr + (_Min_Heap_Size or _Min_Stack_Size ) . Why are they 512 byte and 1K byte as default?

0693W00000Bb7WbQAJ.png 

Best regards,

Enes.

10 REPLIES 10
TDK
Guru

> Why are they 512 byte and 1K byte as default?

Why anything? They are what they are, change them to what you need. Those are the defaults in the linker template file. The code generator doesn't do any sort of smart evaluation of your project needs and set them according to that, if that's what you're curious about.

Note that these just ensure the space is there. Setting them to a value that clearly won't work (i.e. stack size of 0) won't throw an error.

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

I wonna to focus this problem again, why this is implementded like this? If i change for example stack location to CCRAM, linker will still check if stack size will fit into RAM.

Please change this.

"again, why this is implementded like this?"

Again, why not?

They are just defaults - the whole point of defaults is that you change them if they don't fit your requirements.

"Please change this."

Change it to what, exactly?

Don't forget to keep your cross-post updated:

https://community.arm.com/developer/ip-products/processors/f/cortex-m-forum/49564/_min_heap_size-and-_min_stack_size

Radosław
Senior II

Why? in this implemetation, memory reservation for stack is independent to it's location.

TDK
Guru

> why this is implementded like this?

Because it works for the default configuration. If you want something else, you need to own the liker code and modify it accordingly. CubeMX implements a subset of the virtually infinite possible configurations.

Keep in mind the capabilities of the linker are limited to the 1980s technology/syntax from when it was developed.

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

Your explanation can't be accepted.

How hard is to remove this line:

_estack = ORIGIN(RAM) + LENGTH(RAM);   /* end of "RAM" Ram type memory */

and after stack input section add

 _estack = .;

Then initial stack pointer will points to proper reserved location.

Before any reply, plaase check linker and startup files templates in CMSIS5.

EŞimş.1
Associate II

Hi,

I can't understand what these (_Min_Heap_Size and _Min_Stack_Size) default values are respect to. The Values of an another ST MCU which has a different RAM size are different others, for example instead of this:

_Min_Heap_Size = 0x200 ; /* required amount of heap */

_Min_Stack_Size = 0x400 ; /* required amount of stack */

like this:

_Min_Heap_Size = 0x100 ; /* required amount of heap */

_Min_Stack_Size = 0x200 ; /* required amount of stack */

If I need to ask for you more clearly , Are These DEFAULT values chosen randomly or else is there a special reason?

TDK
Guru

> How hard is to remove this line:

> _estack = ORIGIN(RAM) + LENGTH(RAM);   /* end of "RAM" Ram type memory */

> and after stack input section add

> _estack = .;

That would do something different. It would place it at the end of the used space, but not at the end of RAM (unless you were using 100% of RAM). But if that's what you want, do it.

> Are These DEFAULT values chosen randomly or else is there a special reason?

Neither.

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

Hi @TDK​  ,

Neither.

Thanks a lot for that your fabuluos explanatory answer.

Best Regards.