Hallo
I wonder if there are any good methodes of calculating the stack size for ex user or IRQ stack size? Is there any "best practice"?
Or is it just add up the size of data structures and/ot ISR's??
/Thomas
Seems to be an error in that description.
The fill pattern 0xDEADDEAD is a 32-bit number, so it will consume four bytes. You should multiply with 4 and not with 8.
I think the multiply-with-8 comes from the fact that you should align and grow the stack in 8-byte steps for your ARM processor.
The number of overwritten fill patterns will indicate the high watermark of the stack usage. Note that it can be very hard to get your program to run down all alternatives, so you will either need a debugger, profiler or similar that can keep track of code coverage, or you will manually have to keep track of what input data it takes to activate different call branches.
When you have figured out the amount of stack your program is proven to _at_least_ consume, you will then have to figure out how much safety margin you will need. And depending on processor architecture or way the program is written, you may then have to add extra space for interrupt routines.
And what is the proper setting for stack space? 200 bytes, or 200*3 bytes, or 200*8 bytes, or something else?
Could someone please teach me? Many Thanks.
Sorry for that I don't understand Step-5. http://www.keil.com/support/man/docs/armcc/armcc_cjaiidcg.htm
4. Examine, after your application has finished executing, the stack area of memory to see how many of the known values (zeros or 0xDEADDEAD) have been overwritten. The stack shows garbage in the part of the stack that has been used and zeros or 0xDEADDEAD values in the remainder.
5. Count the number of known entries and multiply by eight. This shows how far the stack has grown in memory in bytes.
If, after Step-4, I find that, it uses 200 Bytes stack space;
and my application is very simple as below.
void main(void) { while(1) { func1(); func2(); func3(); } } void func1(void) { int var; // dummy; } void func2(void) { int var; // dummy; } void func3(void) { int var; // dummy; }
What is the value of "the number of known entries"? 3 (3 functions) or 200 (200 Bytes Stack Space).
And why should multiply by eight? Why not 2 or 4 or 10?
eg, http://www.keil.com/support/man/docs/armcc/armcc_cjaiidcg.htm
some libraries require a minimum (RL-ARM, for example). generally, the best you can do is: * calculate exactly what the stack usage of every function is and all possible paths to it. better automate this, and you can make us of the statistics generated by the tool-chain. * use pre-inserted markers in the stacks themselves to follow stack usage overtime. * catch stack overflows by monitoring. * more...?
View all questions in Keil forum