Measuring Stack Usage
The two stack checking techniques do not meet my needs (assuming I understand them). I’d like to profile my stacks and then adjust them to have a certain amount of margin. If I knew where a task stack begins, its size (the same in our application), and a known pattern is written to them then I can download the memory and analyze it after exercising the system rather than compute anything at run-time.
Any suggested approaches?
Thanks.
Measuring Stack Usage
This is something that is intended for the next release: http://sourceforge.net/p/freertos/feature-requests/95/ not that that helps you immediately.
When a stack is created it is filled with 0xa5 – so there is already a known pattern in the stack.
There is also a function that will return the maximum amount of stack that has ever been consumed since the task was created: http://www.freertos.org/uxTaskGetStackHighWaterMark.html
The pxStack member of the task control block points to the start of a task’s stack. Due to our strict data hiding policy, you cannot access TCB members directly, but you can view them in the debugger. For example, to view the start of the stack for the currently running task you can view pxCurrentTCB->pxStack. Some debuggers will require a case as follows ( ( tskTCB * ) pxCurrentTCB )->pxStack.
Regards.
Measuring Stack Usage
If you are using GNU tools, there is an approach to measure the amount of stack used, see http://mcuoneclipse.com/2015/08/21/gnu-static-stack-usage-analysis/.
Measuring Stack Usage
This is great news. FreeRTOS is on our roadmap for many products to come so we can take advantage of the new feature during the next availalbe product cycle (which happens several times a year for us).
I’m fine with using the debugger. I’m just trying to add stack checking to our checklist for milestones. With 7.0.2 does it fill the stack with the pattern? Can you suggest a modification (to save me time hunting through the source). A product shipping soon has this version. We’ve moved to 8.X for following products.
Thanks,
Kenny
Measuring Stack Usage
Erich: Thank you. Nice write up! We are using GNU and Eclipse for a Cortex-A9 which I am a little new to (IAR for many years before) so I am still learning some of the tricks. I’ll try it right now.