Boss lady
DIIDevHeads IoT Integration Server
•Created by Boss lady on 5/26/2024 in #code-review
Resolving FreeRTOS Application Crashes with S/O Checking, Watchdogs, etc.
Hello @Middleware & OS
My FreeRTOS application experiences sporadic crashes or resets without an obvious cause. What steps can I take, such as enabling stack overflow checking, using watchdog timers, or analyzing core dumps, to investigate and resolve these unexpected system failures? Please provide code examples to help understand these solutions.
// Enabling stack overflow checking
void vApplicationStackOverflowHook(TaskHandle_t xTask, char *pcTaskName) {
// Handle stack overflow
printf("Stack overflow in task: %s\n", pcTaskName);
while(1); // Stay here to help debugging
}
// Using a watchdog timer
void vTaskWithWatchdog(void *pvParameters) {
for(;;) {
// Refresh watchdog
HAL_IWDG_Refresh(&hiwdg);
vTaskDelay(pdMS_TO_TICKS(500));
}
}
void main(void) {
// Initialize watchdog
IWDG_HandleTypeDef hiwdg;
hiwdg.Instance = IWDG;
hiwdg.Init.Prescaler = IWDG_PRESCALER_64;
hiwdg.Init.Reload = 0xFFF;
HAL_IWDG_Init(&hiwdg);
xTaskCreate(vTaskWithWatchdog, "Task With Watchdog", 1000, NULL, 1, NULL);
vTaskStartScheduler();
}
6 replies