Processor: STM32F405
FreeRtos: 10.5.1
If I set configCHECK_FOR_STACK_OVERFLOW to 2 then it places special values on 16 bytes of the task stack and I believe then checks them and if corrupted calls vApplicationStackOverflowHook() This I have working and is a great ability.
I have made a custom check based on usage of uxTaskGetStackHighWaterMark() which returns WORDS for high water. This works well which works and am wondering about the following:
-
is uxTaskGetStackHighWaterMark() a very low overhead call based on task stack pointer registers or does is use similar stack special values used by configCHECK_FOR_STACK_OVERFLOW where the code walks through and checks all words?
-
I am thinking of usage of configCHECK_FOR_STACK_OVERFLOW set to 1 combined with custom code to check for some high water threshold I choose and this custom routine uses uxTaskGetStackHighWaterMark() . Is this a lower runtime hit vs configCHECK_FOR_STACK_OVERFLOW set to 2 due to use of task stack pointer registers
-
If it really is best to use configCHECK_FOR_STACK_OVERFLOW set to 2 then is there a way to change the number of bytes with custom pattern to a larger number such as 32 or 64?
The core of my custom checker is as follows:
UBaseType_t uxHighWaterMark;
uxHighWaterMark = uxTaskGetStackHighWaterMark( NULL );
while (uxHighWaterMark <= TASK_STACK_HIGH_WATER_MIN) { // This can be 32
static uint32_t g_procStackPointer; // Show task SP for deeper debug if in debugger
__asm volatile ( "mrs %0, psp" : "=r" ( g_procStackPointer ) );
vTaskDelay(5); // Keep this task here forever if we hit this limit
}
Thank you for your thoughts.