UDP Server failing on GenericQueueSend() in queue.c when building lwIP as static library

I have a “FreeRTOS lwIP Perf Server” application template modified as a UDP echo server running on a KCU105 Microblaze in the Xilinx SDK 2019.1, with freertos10_v1_3 and lwip211_v1_0 building from the BSP. However, when building lwIP 2.1.2 from source as a static library, the server fails (pxQueue equals 0) on configAssert( pxQueue ); in file queue.c, in functions xQueueGenericSend() and xQueueGenericSendFromISR().
The application sends and receives UDP packets successfully when using lwIP in the BSP, but eventhough the lwIP library builds from source and produces the .a library file, it fails on Queue Send functions.

Any input regarding this will be helpful. Thanks.

Below is the serial output, where queue.c line 753 is xQueueGenericSend()
and queue.c line 963 is xQueueGenericSend()

-----lwIP Socket Mode UDP Server Application------
Start PHY autonegotiation 
Waiting for PHY to  complete autonegotiation 
Autonegotiation complete 
Waiting for Link to be up; Polling for SGMII core Reg 
auto-negotiated link speed: 1000
Configuring default IP 192.168.1.10 
Board IP:       192.Assert failed in file queue.c, line 753

-----lwIP Socket Mode UDP Server Application------
Start PHY autonegotiation 
Waiting for PHY to  complete autonegotiation 
Autonegotiation complete 
Waiting for Link to be up; Polling for SGMII core Reg 
auto-negotiated link speed: 1000
Configuring default IP 192.168.1.10 
Assert failed in file queue.c, line 963

Here is an screenshot of the function call stack as well:
udp_callstack

Where is the pxQueue variable declared? Within the lwIP code? Is that code? If so I would guess there is a startup code or linker issues - but it sounds like you are getting all your code and tools from Xilinx so I would suggest asking on their forum.

Hi Richard,

pxQueue is declared in FreeRTOS file queue.c, in both the xQueueGenericSend() and xQueueGenericSendFromISR() functions, and gets set to the xQueue parameter as seen in the code block below.

BaseType_t xQueueGenericSend( QueueHandle_t xQueue, const void * const pvItemToQueue, TickType_t xTicksToWait, const BaseType_t xCopyPosition )
{
BaseType_t xEntryTimeSet = pdFALSE, xYieldRequired;
TimeOut_t xTimeOut;
Queue_t * const pxQueue = xQueue;

	configASSERT( pxQueue );

.
.
.
}

BaseType_t xQueueGenericSendFromISR( QueueHandle_t xQueue, const void * const pvItemToQueue, BaseType_t * const pxHigherPriorityTaskWoken, const BaseType_t xCopyPosition )
{
BaseType_t xReturn;
UBaseType_t uxSavedInterruptStatus;
Queue_t * const pxQueue = xQueue;

	configASSERT( pxQueue );

.
.
.
}

xQueueGenericSend() is called from within the lwIP function sys_mbox_trypost() in the lwIP file sys_arch.c.
sys_mbox_trypost() calls xReturn = xQueueSend( *pxMailBox, &pxMessageToPost, ( portTickType ) 0 ); and xQueueSend() is defined as xQueueGenericSend() in queue.h in FreeRTOS.

Thanks

In which case my question is really where is pxMailBox declared, as it seems *pxMailBox is NULL.

Richard,

sys_mbox_trypost() is called from the lwIP function tcpip_try_callback() in the file tcpip.c (functions are below). This function passes &tcpip_mbox which is declared in tcpip.c as a global variable: static sys_mbox_t tcpip_mbox;

tcpip_try_callback()

tcpip_try_callback(tcpip_callback_fn function, void *ctx)
{
  struct tcpip_msg *msg;

      LWIP_ASSERT("Invalid mbox", sys_mbox_valid_val(tcpip_mbox));

      msg = (struct tcpip_msg *)memp_malloc(MEMP_TCPIP_MSG_API);
      if (msg == NULL) {
        return ERR_MEM;
      }

      msg->type = TCPIP_MSG_CALLBACK;
      msg->msg.cb.function = function;
      msg->msg.cb.ctx = ctx;

      if (sys_mbox_trypost(&tcpip_mbox, msg) != ERR_OK) {
        memp_free(MEMP_TCPIP_MSG_API, msg);
        return ERR_MEM;
      }
      return ERR_OK;
 }

sys_mbox_trypost()

    err_t sys_mbox_trypost( sys_mbox_t *pxMailBox, void *pxMessageToPost )
    {
    err_t xReturn;
    portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;

    	if( xInsideISR != pdFALSE )
    	{
    		xReturn = xQueueSendFromISR( *pxMailBox, &pxMessageToPost, &xHigherPriorityTaskWoken );
    		if (xHigherPriorityTaskWoken == pdTRUE) {
    			portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
    		}
    	}
    	else
    	{
    		xReturn = xQueueSend( *pxMailBox, &pxMessageToPost, ( portTickType ) 0 );
    	}
      .
      .
      .
     }

Did you successfully call tcpip_init which also initializes tcpip_mbox ?
Since the FreeRTOS queue handle is NULL either the call is missing or something went wrong.
Did you enable lwIP asserts and FreeRTOS asserts including other debug checks like stack overflow checking ?