-
Notifications
You must be signed in to change notification settings - Fork 15
MeasuringStackUsage
Simon Wright edited this page Sep 25, 2018
·
1 revision
Stack usage is very important in smaller-memory embedded processing. Get it too small and you have mysterious crashes; get it too large and you may run out of memory.
You can control stack sizes, but first you need to know what your programs's stack needs are. This page discusses a tool to measure the amount of unused stack for each task; knowing the original allocated amount, you can work out how much it's safe to reduce it by.
The tool is a Python script, run inside arm-eabi-gdb
. Find it in the distribution at python/stacks.py
.
-
FreeRTOSConfig.h
must contain one or more of-
configCHECK_FOR_STACK_OVERFLOW
> 1 -
configUSE_TRACE_FACILITY
== 1 -
INCLUDE_uxTaskGetStackHighWaterMark
== 1
-
- The RTS must be compiled for debugging (
-XBUILD=Debug
, the default)
(gdb) source /where/ever/stacks.py
(gdb) stacks
min free: 2880 , tag: 0x2000a9dc <ada.real_time.timing_events.timer+4>
min free: 1304 , tag: 0x2000ad9c <environment_task.environment_tcb>
where
- 'min free' is the minimum free stack ever used by the task
- 'tag' indicates the task (it's the address of the procedure created by the compiler to initiate the task)