STM32FreeRTOS vTaskDelay() not returning

There is a problem with the linking process. FreeRTOS needs to hook the weak SVC_Handler (supervisor-call interrupt) in order to be able to execute a task switch. However the way PIO builds the firmware, it builds the Arduino framework first and creates an .a archive. When this happens the FreeRTOS code hasn’t been looked at yet but the SVC_Handler gets its default empty function. Then the FreeRTOS code is compiled an archived and both archives are linked together, however FreeRTOS doesn’t get the SVC_Handler call then because it’s already occupied.

This is prevented by using the lib_archive = no option (docs) which does not create archives but links all objects file together, and then linking works and FreeRTOS’s SVC_Handler is called.

You can go into your project’s platformio.ini and add

lib_archive = no

which makes the blinky project work.

The library.json of the FreeRTOS library tries to use the exact same setting but it isn’t applied somehow.

I’ll check why.