Assert failed in port.c

Hi,
I’m bring up my system with AMD Zynq UltraScale+ MPSoC and freeRTOS kernel. At the moment I will get

Assert failed in file port.c, line 602

I try to debug this error

How can I find out at what point did the error occur?

Thank you for your help.
BR
martin

Can’t you just lookup the assert statement in the code ? See the call stack or (usually) the arguments of your assert function.

tasks.c line 4931

That’s one of purposes of those asserts.

tasks.c line 4931:

#if ( configUSE_TASK_NOTIFICATIONS == 1 )

    BaseType_t xTaskGenericNotify( TaskHandle_t xTaskToNotify,
                                   UBaseType_t uxIndexToNotify,
                                   uint32_t ulValue,
                                   eNotifyAction eAction,
                                   uint32_t * pulPreviousNotificationValue )
    {
        TCB_t * pxTCB;
        BaseType_t xReturn = pdPASS;
        uint8_t ucOriginalNotifyState;

        configASSERT( uxIndexToNotify < configTASK_NOTIFICATION_ARRAY_ENTRIES );
        configASSERT( xTaskToNotify );
        pxTCB = xTaskToNotify;

        taskENTER_CRITICAL();
        {
            if( pulPreviousNotificationValue != NULL )
            {
                *pulPreviousNotificationValue = pxTCB->ulNotifiedValue[ uxIndexToNotify ];
            }

            ucOriginalNotifyState = pxTCB->ucNotifyState[ uxIndexToNotify ];

is the taskENTER_CRITICAL() function.

taskENTER_CRITICAL calls vPortEnterCritical:

	/* This is not the interrupt safe version of the enter critical function so
	assert() if it is being called from an interrupt context.  Only API
	functions that end in "FromISR" can be used in an interrupt.  Only assert if
	the critical nesting count is 1 to protect against recursive calls if the
	assert function also uses a critical section. */
	if ( ullCriticalNesting == 1ULL ) {
		configASSERT( ullPortInterruptNesting == 0 );
	}

is that the cause? I call taskNotify from an ISR?

You should follow up the call stack to find out where the asserting xTaskGenericNotify is called to answer your question or to find out what’s going wrong.

Ok. With the debugging of the xTaskNotify I could the function with the wrong call. In an ISR I called xTaskNotify, after I changed I to xTaskNotifyFromISR the application will run.

BR
martin

1 Like

Great that you found it (and reported back) and got more familiar with the FreRTOS debug/development features.
You see - those configASSERTs are incredibly useful :slight_smile: and got improved with every FreeRTOS version up to now.
Using them might also help with your own application development, too.

1 Like