Other Parts Discussed in Thread: C2000WARE
Tool/software:
I initially posted this information here, but never got a reply, so I'm posting it again as a new thread.
I am experiencing the problems with double freeing of LwIP buffers. I've been trying to power through it, but I think there is some fundamental error with the LwIP examples even with the 5.4.0.0 C2000ware. I am using the TMS320F28388S processor.
Turning on the LWIP_STATS and MEM_STATS defines show the illegal count being incremented for double free operations. Is there a fix available that properly handles the buffer allocations?
I have traced part of the problem to the loop in f2838xif_process_transmit from f2838xif.c that is freeing a chain of packet descriptors.
do
{
pktDescPtrShadow = pktDescPtr->nextPacketDesc;
mem_free(pktDescPtr);
pktDescPtr = pktDescPtrShadow;
}
while(pktDescPtr != 0);
This code can be traced back to being called from Ethernet_removePacketsFromTxQueue [driverlib_cm/ethernet.c] which is popping packets one at a time off of the descQueue using Ethernet_performPopOnPacketQueue and calling the pfcbFreePacket function on them.
static Ethernet_Pkt_Desc *Ethernet_performPopOnPacketQueue(
Ethernet_PKT_Queue_T *pktQueuePtr)
{
Ethernet_Pkt_Desc *pktDescHdrPtr;
pktDescHdrPtr = pktQueuePtr->head;
if(0U != pktDescHdrPtr)
{
pktQueuePtr->head = pktDescHdrPtr->nextPacketDesc;
pktQueuePtr->count--;
}
return(pktDescHdrPtr);
}
pktQueuePtr->head keeps a pointer to pktDescHdrPtr->nextPacketDesc which is getting freed in f2838xif_process_transmit. The problem can get particularly tough if there are more packets getting processed that reuse these buffers and cause circular references in the descriptor nextPacketDesc links.
One of my attempts to work through this was to only free one item at a time in f2838xif_process_transmit, but that led to memory leaks and ultimately running out of available memory.
My latest attempt to fix the issue is to add a loop to Ethernet_removePacketsFromTxQueue that calls Ethernet_performPopOnPacketQueue until a NULL is returned - making the logic match what the pfcbFreePacket call would free. This has worked better, but still appears to have issues when there are several packets being sent at a time.
Please let me know if there is a fix available or any further information that you may need.