# Assert failed in port.c

**URL:** <https://forums.freertos.org/t/assert-failed-in-port-c/20791>\
**Category:** Kernel\
**Created:** [June 21, 2024, 6:24am UTC](https://forums.freertos.org/t/assert-failed-in-port-c/20791 "2024-06-21T06:24:52Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![msauerpb](https://avatars.discourse-cdn.com/v4/letter/m/5f9b8f/32.png) [@msauerpb](https://forums.freertos.org/u/msauerpb)\
**Post date:** [June 21, 2024, 6:24am UTC](https://forums.freertos.org/t/assert-failed-in-port-c/20791/1 "2024-06-21T06:24:55Z")

</div>

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

 ![image](https://d2v6vdsk2p900z.cloudfront.net/original/2X/c/c51972f6638684700cc062561aaea50cd58834a7.png)

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

Thank you for your help.  
BR  
martin

---

<div class="post-metadata">

**Author:** ![hs2](https://avatars.discourse-cdn.com/v4/letter/h/a4c791/32.png) [@hs2](https://forums.freertos.org/u/hs2)\
**Post date:** [June 21, 2024, 6:33am UTC](https://forums.freertos.org/t/assert-failed-in-port-c/20791/2 "2024-06-21T06:33:48Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![msauerpb](https://avatars.discourse-cdn.com/v4/letter/m/5f9b8f/32.png) [@msauerpb](https://forums.freertos.org/u/msauerpb)\
**Post date:** [June 21, 2024, 7:09am UTC](https://forums.freertos.org/t/assert-failed-in-port-c/20791/3 "2024-06-21T07:09:44Z")

</div>

tasks.c line 4931:

```auto
#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:

```auto
	/* 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?

---

<div class="post-metadata">

**Author:** ![hs2](https://avatars.discourse-cdn.com/v4/letter/h/a4c791/32.png) [@hs2](https://forums.freertos.org/u/hs2)\
**Post date:** [June 21, 2024, 7:24am UTC](https://forums.freertos.org/t/assert-failed-in-port-c/20791/4 "2024-06-21T07:24:49Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![msauerpb](https://avatars.discourse-cdn.com/v4/letter/m/5f9b8f/32.png) [@msauerpb](https://forums.freertos.org/u/msauerpb)\
**Post date:** [June 21, 2024, 7:35am UTC](https://forums.freertos.org/t/assert-failed-in-port-c/20791/5 "2024-06-21T07:35:36Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![hs2](https://avatars.discourse-cdn.com/v4/letter/h/a4c791/32.png) [@hs2](https://forums.freertos.org/u/hs2)\
**Post date:** [June 21, 2024, 8:57am UTC](https://forums.freertos.org/t/assert-failed-in-port-c/20791/6 "2024-06-21T08:57:39Z")

</div>

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 🙂 and got improved with every FreeRTOS version up to now.  
Using them might also help with your own application development, too.
