I want to recommend you fix the freertos source code about CLI
When I used the ‘FreeRTOS Plus CLI’ source code, ‘UARTCommandConsole.c’ to compile. After Linking and download to STM32 platfrom. A fatal error ocured.
When I reset the STM32, the welcome information was shown normally via the serial port. However, when I send something to the STM32 via ‘XSHELL’, the STM32 has not any response. Then I pause the debug, I found my program point is always jump to ‘HardFault_Handler’. Many tries, I found that, at the first beginning, the program is run normally, and once sending something, it was halt!
Then I check the source code, I found that, at the function ‘
static void prvUARTCommandConsoleTask( void pvParameters )’, there is a call ‘
xSemaphoreTake( xTxMutex, cmdMAXMUTEX_WAIT )’, the error is there.
Because the mutex semaphore ‘
xTxMutex’ is though defined, it was not created before taking and giving. So it’s the fatal error to cause the OS halt. If you want to fix it, just add a line
'xTxMutex = xSemaphoreCreateMutex();'. And Don’t forget change the definetion ‘
#define configUSE_MUTEXES 1’ in ‘FreeRTOS.h’