The same problem description but seems to be none stack overflows. I’ve read the topic:
And have checked stacks thoroughly. I added monitoring task which gathering all tasks info and checks unused stack remainder. uxTaskGetStackHighWaterMark() is called for every task including Timer and Idle tasks. And there are remainders everywhere. 49 or more stack words are untouched in stacks of every of total six tasks including timer and idle tasks.
FreeRTOS is running on single RISC-V QuingKe4F MCU core. RTOS port was taken from MCU manufacturer with almost none intervention but carefully checked.
Compiler is GCC. IDE is Eclipse.
What next step I need to debug the cause of xStreamBufferReceive task get suspended but not woken-up?
Before first entry, receiving task is in eReady state. After first entry while there are no data in stream buffer yet the state become eSuspended and buffer handle unit xTaskWaitingToReceive is holding receiving task handle.
I’m not sure should be receiving task eBlocked or @Suspended?
Oops! Actually I sure, it should be suspended:
eSuspended, /* The task being queried is in the Suspended state, or is in the Blocked state with an infinite time out. */
which is my case cause I’d asked portMAX_DELAY. So far, so good.
The problem manifests itself as follows:
- Stream buffer receiving task, upon a first entering xStreamBufferReceive() is changing it’s state to eSuspended. OK.
- While exectuting xStreamBufferReceive() first time, xTaskWaitingToReceive unit become set to receiving task handle. OK.
- While first call of sending task xStreamBufferSend() puts more bytes than buffer threshold is set for. So receiving task should wake up. But nope. Receiving task is staying suspended.
- Also after first call of xStreamBufferSend(), xTaskWaitingToReceive in stream buffer handle become NULL.
- Next calls for xStreamBufferSend() just filling the buffer but receiving task remains deadly suspended.
Here is Receiving task code:
void vUART_DMAtx(void *pvParameters) {
(void) pvParameters;
char Buff[xBufferSizeBytes];
for (;;) {
size_t Size = xStreamBufferReceive(xDebugMsgStream, (void* ) Buff, sizeof(Buff), portMAX_DELAY); //Wait for next message
if (Size > 0) { //Sanity check for size of data requested for a transmission
asm volatile ("NOP"); //Never reaching this
//Some data need to be transferred
//Blah Blah Blah
} else {
//Size of request is zero. Do nothing.
}
} //Repeat forever
}
Here is sending function which is called from usual RTOS tasks which are not an interrupts:
__attribute__((used)) int _write(int FileHandle, char *Data, int Size) {
(void) FileHandle;
vTaskSuspendAll();
Size = xStreamBufferSend( xDebugMsgStream, Data, Size, 0 );
( void ) xTaskResumeAll();
return Size;
}
Here is buffer definition:
//FreeRTOS Message buffer
uint8_t pucDbgMsgBufStor[xBufferSizeBytes]; //Debug message buffer storage area
StaticMessageBuffer_t xDbgMsgBufStruct; //Debug message buffer structure
StreamBufferHandle_t xDebugMsgStream; //Debug message buffer handle
There is buffer creation:
xDebugMsgStream = xStreamBufferCreateStatic(xBufferSizeBytes, 1, pucDbgMsgBufStor, &xDbgMsgBufStruct); //Create background debug stream buffer for sending debug messages to UART
Receiving task is created static:
xDebugUART = xTaskCreateStatic(vUART_DMAtx, (const char*) "DebugUART", DebugUART_STK_SIZE, (void*) 1, DebugUART_PRIO, puxDbgUARTstkBuf, &xDebugUART_TCB);
Receiving task should copy data into DMA buffer then initiate DMA transfer with an interrupt upon completion. DMA transfer it’s own is tested separately and is not enabled yet. DMA interrupt is not enabled too for stream buffer wake-up problem debug.
What can I do next to debug.