FreeRTOS+IO Zero Copy TX Fails at ioutilsGIVE_ZERO_COPY_MUTEX

kedar1993 wrote on Tuesday, May 07, 2019:

I am trying to use the Zero Copy TX Transfer Mode for Sending Data via UART peripheral but getting an assertion failure at ioutilsGIVE_ZERO_COPY_MUTEX.

In my task, I am calling the the FreeRTOS_write as follows:

const uint8_t text[] = "--------------\r\n";

		xReturned = FreeRTOS_ioctl( xUART0Handle, ioctlOBTAIN_WRITE_MUTEX, (void *)(50UL/portTICK_RATE_MS));
		if( xReturned == pdTRUE )
			xReturned = FreeRTOS_write(xUART0Handle, text, 16);

Within the FreeRTOS_write function, I am calling the ioutilsINITIATE_ZERO_COPY_TX which initiates the transfer. Once the transfer is complete, the ISR for the peripheral is called where I am calling the ioutilsGIVE_ZERO_COPY_MUTEX.

This is where the assertion fails within queue.c -> BaseType_t xQueueGiveFromISR(QueueHandle_t xQueue, BaseType_t *const pxHigherPriorityTaskWoken).

/* Normally a mutex would not be given from an interrupt, especially if
	there is a mutex holder, as priority inheritance makes no sense for an
	interrupts, only tasks. */
	configASSERT(!((pxQueue->uxQueueType == queueQUEUE_IS_MUTEX) && (pxQueue->pxMutexHolder != NULL)));

I am not sure where I am going wrong and would appreciate any help. Thanks!

rtel wrote on Wednesday, May 08, 2019:

I think that is an incompatibility with newer FreeRTOS versions that
changed the way the priority inheritance mechanism worked, preventing
mutexes being used in interrupts. If you change the mutex to a binary
semaphore it should be ok. The only thing you need to do is change the
xSemaphoreCreateMutex() call to xSemaphoreCreateBinary() - the type of
the parameters do not need to change.

kedar1993 wrote on Wednesday, May 08, 2019:

Thank you. I will give it a try and update.