Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT Training


Measuring Stack Usage

Posted by razed11 on November 13, 2015

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?


Measuring Stack Usage

Posted by rtel on November 13, 2015

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.


Measuring Stack Usage

Posted by xz8987f on November 13, 2015

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

Posted by razed11 on November 13, 2015

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.



Measuring Stack Usage

Posted by razed11 on November 13, 2015

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.

[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]

Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.

Free TCP/IP and file system demos for the RTOS

Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑

FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists