(xQueueGenericReceive)- assert failed! -Issues after upgrading to latest toolchain version.

Async_Awayt
Posts: 14
Joined: Sun Feb 19, 2017 8:04 pm

(xQueueGenericReceive)- assert failed! -Issues after upgrading to latest toolchain version.

Postby Async_Awayt » Fri Sep 08, 2017 5:20 am

Just upgraded to the latest toolchain version and am facing several issues.
For instance I am getting:

Code: Select all

(xQueueGenericReceive)- assert failed!
This is the code that I believe is causing the issue:

Code: Select all

...

static xQueueHandle DRDY_evt_queue = NULL;
static void IRAM_ATTR gpio_isr_handler(void *arg)
{
	gpio_num_t gpio_num = (gpio_num_t) arg;
	xQueueSendFromISR(DRDY_evt_queue, &gpio_num, NULL);
}

...

while(1)
	{

		if(xQueueReceive(DRDY_evt_queue, &io_num, portMAX_DELAY))
		{
			antal++;
			voltage = Measure(spi2);
			ave_voltage += (voltage - ave_voltage)/antal;
			printf("Volt = %.7f     Ave = %.7f\n", voltage, ave_voltage);
		}
	}
It used to work fine on the older version of the toolchain.
Does anybody know what changes I have to make to get it working on the new version?

permal
Posts: 279
Joined: Sun May 14, 2017 5:36 pm

Re: (xQueueGenericReceive)- assert failed! -Issues after upgrading to latest toolchain version.

Postby permal » Fri Sep 08, 2017 7:04 am

Check what the assert actually complains about.

Based on the code you provided your DRDY_evt_queue is NULL, but since you have left out parts it might be something else.

Async_Awayt
Posts: 14
Joined: Sun Feb 19, 2017 8:04 pm

Re: (xQueueGenericReceive)- assert failed! -Issues after upgrading to latest toolchain version.

Postby Async_Awayt » Fri Sep 08, 2017 10:57 am

permal wrote:Check what the assert actually complains about.
I am not sure how to check what the assert complains about. Do you mean by "core dumping"?
permal wrote:Based on the code you provided your DRDY_evt_queue is NULL, but since you have left out parts it might be something else.
Here are the lines associated with the interrupt:

Code: Select all

...
// Set IO direction for pins used
	gpio_set_direction(PIN_NUM_DRDY, GPIO_MODE_INPUT);
	gpio_set_intr_type(PIN_NUM_DRDY, GPIO_INTR_NEGEDGE);
// Create the queue that will handle the interrupt when DRDY goes low.
	DRDY_evt_queue = xQueueCreate(1, sizeof(uint32_t));
// Install the ISR service
	gpio_install_isr_service(0);
// Declare queue handle
	static xQueueHandle DRDY_evt_queue = NULL;
// Define isr handoing routine
	static void IRAM_ATTR gpio_isr_handler(void *arg)
	{
	   gpio_num_t gpio_num = (gpio_num_t) arg;
	   xQueueSendFromISR(DRDY_evt_queue, &gpio_num, NULL);
	}
...
// Read voltage from the device via SPI when DRDY goes low.
	while(1)
	{
		if(xQueueReceive(DRDY_evt_queue, &io_num, portMAX_DELAY))
   	   	{
     	    		antal++;
     	    		voltage = Measure(spi2);
         		ave_voltage += (voltage - ave_voltage)/antal;
         		printf("Volt = %.7f     Ave = %.7f\n", voltage, ave_voltage);
      		}
   	}
...

permal
Posts: 279
Joined: Sun May 14, 2017 5:36 pm

Re: (xQueueGenericReceive)- assert failed! -Issues after upgrading to latest toolchain version.

Postby permal » Fri Sep 08, 2017 11:03 am

Async_Awayt wrote:
permal wrote:Check what the assert actually complains about.
I am not sure how to check what the assert complains about. Do you mean by "core dumping"?
No, open the source for xQueueReceive/xQueueGenericReceive. It will show you what the asserts are checking.

Async_Awayt
Posts: 14
Joined: Sun Feb 19, 2017 8:04 pm

Re: (xQueueGenericReceive)- assert failed! -Issues after upgrading to latest toolchain version.

Postby Async_Awayt » Fri Sep 08, 2017 11:41 am

permal wrote:
Async_Awayt wrote:
permal wrote:Check what the assert actually complains about.
I am not sure how to check what the assert complains about. Do you mean by "core dumping"?
No, open the source for xQueueReceive/xQueueGenericReceive. It will show you what the asserts are checking.
The exception originates from the standard queue.c file. See the failed assert line below:

Code: Select all

BaseType_t xQueueGenericReceive( QueueHandle_t xQueue, void * const pvBuffer, TickType_t xTicksToWait, const BaseType_t xJustPeeking )									
{									
BaseType_t xEntryTimeSet = pdFALSE;									
TimeOut_t xTimeOut;									
int8_t *pcOriginalReadPosition;									
Queue_t * const pxQueue = ( Queue_t * ) xQueue;									
									
									
	configASSERT( pxQueue );	 // THIS IS WHERE THE EXECUTION STOPS!	//	
	
			
	configASSERT( !( ( pvBuffer == NULL ) && ( pxQueue->uxItemSize != ( UBaseType_t ) 0U ) ) );								
	#if ( ( INCLUDE_xTaskGetSchedulerState == 1 ) || ( configUSE_TIMERS == 1 ) )								
	{								
		configASSERT( !( ( xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED ) && ( xTicksToWait != 0 ) ) );							
	}								
	#endif

permal
Posts: 279
Joined: Sun May 14, 2017 5:36 pm

Re: (xQueueGenericReceive)- assert failed! -Issues after upgrading to latest toolchain version.

Postby permal » Fri Sep 08, 2017 11:46 am

Then your queue pointer is in all likelihood NULL. Recheck your code.

Async_Awayt
Posts: 14
Joined: Sun Feb 19, 2017 8:04 pm

Re: (xQueueGenericReceive)- assert failed! -Issues after upgrading to latest toolchain version.

Postby Async_Awayt » Fri Sep 08, 2017 1:54 pm

permal wrote:Then your queue pointer is in all likelihood NULL. Recheck your code.
You are right! I rearranged my code so it is all inside a single source file and now it working.
I used to have it divided into:
esp32_spi.h
esp32_spi.c
main.c
So I could reuse the SPI later.

Isn't it odd that the same code used to work fine before the toolchain upgrade?
Granted, I had to correct the SPI device and transaction configurations to correct the workarounds needed to get the old SPI driver to work correctly, but I made no changes to the rest of the code.. :?

Thanks!

Return to “ESP32 IDF”

Who is online

Users browsing this forum: No registered users and 13 guests