In ESP-IDF you can create a task with the xTaskCreate() function:
static BaseType_t xTaskCreate(TaskFunction_t pvTaskCode, const char *constpcName, const uint32_t usStackDepth, void *constpvParameters, UBaseType_t uxPriority, TaskHandle_t *constpvCreatedTask)
and the documentation says:
usStackDepth: The size of the task stack specified as the number of bytes. Note that this differs from vanilla FreeRTOS.
Usually I see examples like this:
void myTask(void *arg);
TaskHandle_t myTaskHandle = NULL;
xTaskCreate(myTask, "myTask", 2048, NULL, 10, &myTaskHandle);
I wondering how to properly select the stack depth (2048 in the example). Since it reserves memory space I bet I cannot just make a blind guess and insert a higher value otherwise I’ll run out of memory space.
Reading though the docs I found this other function uxTaskGetStackHighWaterMark() and looking at the return value it should give me an indication about how close I’am to stack overflow for the specified task.
Hence, the only way is to set a “random” value, then check the high-watermark and adjust the stack size according? Is there a compiler function to help me to select a value without guessing?