cancel
Showing results for 
Search instead for 
Did you mean: 

How can we decide how much size stack/heap/ and command line argument will take for a project?

Priyadarshini Solanki
Associate II

I am using #[STM32 MCUs]​ #Cortex-m0​ and IDE i am using is #Iar-embedded-workbench​ 

I want to know, How can I decide how much size #Stack​ / #Heap​ / and #Command-line​ argument will take for my project ?

In *.icf file what size, we supposed to keep?

6 REPLIES 6

I guess it starts by understanding how much you use malloc/free, and the depth of your call trees and the sizes of the local/auto variables in those subroutines.

With the stack you can fill it with a pattern and check the maximal depth​ after heavily loading the application.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
YDann.7
Associate III

IAR has a stack usage analisys tool : https://www.iar.com/support/resources/articles/stack-usage-analysis-for-rx/

You can use it to determine the size of the stack needed.

Priyadarshini Solanki
Associate II

Thanks for the response.

In IAR workbench map file will have STACK USAGE

Call Graph Root Category  Max Use  Total Use

 ------------------------  -------  ---------

 Program entry         228      228

 Uncalled function       220    1 136

For all uncalled function , they have mentioned some bytes. Are those the total bytes stored on stack.

Can we say those bytes are the size of used stack ?

I tried filling the stack with pattern in startup, before calling the main. In one run some section of the stack got written, But at that time there were few functions, which doesn't get called. Those function will get called in specific scenario only .

How we can conclude the size in that case?

sum of the byte mentioned at maximum call chain are the total byte updated on stack. ?

Thanks for the response.

In IAR workbench map file will have STACK USAGE

Call Graph Root Category  Max Use  Total Use

 ------------------------ -------  ---------

 Program entry         228     228

 Uncalled function       220    1 136

For all uncalled function , they have mentioned some bytes. Are those the total bytes stored on stack.

Can we say those bytes are the size of used stack ?

I tried filling the stack with pattern in startup, before calling the main. In one run some section of the stack got written, But at that time there were few functions, which doesn't get called. Those function will get called in specific scenario only .

How we can conclude the size in that case?

S.Ma
Principal

Check the toolchain manual on how the output map file information is being computed. Does it include the ISR? It might not know the ISR priorities and depth between them (interrupt being interrupted).

If you used function pointers, check more deeply. Things could also be different if there are some RAM loaded code or fancy implementation.