freertos task hardfaults after a few minutes, stack overflow?
STM32F103, FreeRTOS 10.5.1, three tasks - sensor read, UART logging, and a control loop. After 5-15 minutes the system hardfaults (HardFault_Handler). I enabled configCHECK_FOR_STACK_OVERFLOW = 2 and defined vApplicationStackOverflowHook, but the hook never fires - it just hardfaults. Tasks have 256-512 word stacks. Heap is 8KB. Could it be heap fragmentation from malloc in the UART task? I use sprintf into a local char[128] buffer in the logging task. Any way to catch this before it hardfaults?
4 replies