5. 4.4 Debugging avec vTaskList et stack high-water mark
Activer dans idf.py menuconfig :
Component config → FreeRTOS → Enable FreeRTOS trace facility: YES
Component config → FreeRTOS → Enable statistics formatting functions: YES
void task_debug_monitor(void *pv)
{
char stats_buf[512];
uint32_t cycle = 0;
while (1) {
cycle++;
vTaskList(stats_buf);
ESP_LOGI("DEBUG", "[Cycle %" PRIu32 "] Task states:\n"
"Name State Prio Stack Num\n%s",
cycle, stats_buf);
// Stack high-water mark pour les tâches connues
ESP_LOGI("DEBUG", "Sensor stack HWM: %" PRIu32 " words",
(uint32_t)uxTaskGetStackHighWaterMark(NULL)); // propre tâche
vTaskDelay(pdMS_TO_TICKS(10000));
}
vTaskDelete(NULL);
}
Lecture de la sortie vTaskList :
Name State Prio Stack Num
sensor R 5 1823 3 <- Running, 1823 words restants
display B 3 2011 4 <- Blocked (attend queue)
wifi_reporter B 1 1456 5 <- Blocked (attend notification)
Tmr Svc B 1 1234 2 <- Timer daemon
IDLE0 R 0 748 0
IDLE1 R 0 751 1
Seuil d'alerte : si Stack HWM < 200 words, augmenter usStackDepth de 1024.