I’m currently working on integrating mbedTLS with FreeRTOS in my project, using STM32CubeIDE as my development environment. However, I keep running into a HardFault error when trying to parse a private key using mbedTLS.
Here’s what I’ve observed:
When I use mbedTLS without FreeRTOS, everything works perfectly.
The issue arises only when FreeRTOS is included in the setup.
I suspect the issue could be related to one of the following:
Task stack size?
Heap management (e.g., memory allocation issues)?
Any specific thread-safety considerations with mbedTLS?
I’ve attached a screenshot of the function call stack to provide more context. Please take a look—any guidance or suggestions would be greatly appreciated!
When you use MbedTLS with FreeRTOS, you need to enable threading support in MbedTLS (by defining MBEDTLS_THREADING_C in mbedtls config file) and supply some platform functions. You can refer to the following -