HardFault after receiver task read some mails


I have a STM32F407VET6 with FreeRTOS continuously receiving data, normally 250-300 characters every 4[ms], by UART+DMA, when it receives a ‘\n’ and idle-line sends the data received to a mailbox(8 mails length). Then a receiver task get one mail from the mailbox and sends the data by USB.

The problem is that after 3-5 minutes operating I get a HardFault error and the STM32 stucks. The UART+DMA should be OK, I have tested it before and the when I disable the receiver tasks no HardFault error occurs. So, I think the receiver tasks is the problem, but what can be reason of this HardFault? Is the heap size? stack size? memory allocation?

Thank you!

It is hard to guess a reason with the amount of information shared but have you tried normal debugging techniques:

You can also try to find the faulting instruction and see if that provides some hint - Debugging and diagnosing hard faults on ARM Cortex-M CPUs


FreeRTOS doesn’t have something called a mailbox - is this a hardware or software feature?