joehinkle wrote on Thursday, August 11, 2016:
I have a web server that is transferring jquery.js (256000+ bytes) to the web browser.
My MTU is 700 bytes.
After a random number of packets being sent I get a cpu “HardFault”
Within BufferAllocation_1.c there is a function pxGetNetworkBufferWithDescriptor();
pxReturn is assigned a value from listGET_OWNER_OF_HEAD_ENTRY
The pxReturn get a value of 0xa5a5a5a5; bIsValidNetworkDescriptor() uses that pointer and causes the fault.
Looking at the xFreeBuffersList node in question, both pvOwnser and pvContainer are set to 0xa5a5a5a5.
I enable configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES to check the list and try to detect when the corruption.
The stack calls TCPSendRepeated() which delivers the network buffer to my xNetworkInterfaceOutput().
I can’t see how my xNetworkInterfaceOutput is corrupting it.
BaseType_t xNetworkInterfaceOutput( NetworkBufferDescriptor_t * const pxNetworkBuffer, BaseType_t xReleaseAfterSend )
{
byte *B;
BaseType_t r;
if(LinkStatus == 0) // link down;
{
goto bye;
}
xSemaphoreTake(Xmit_GateSemaphore, portMAX_DELAY); // only let one in
XmitRingDescr[0].Status |= ETX_R;
B = pxNetworkBuffer->pucEthernetBuffer;
B -= 2;
B = (byte*)FlipEndianDW((dword)(B));
XmitRingDescr[0].BuffPtr = B;
XmitRingDescr[0].EnhancedStatus1 = E1TX_PINS | E1TX_IINS | E1TX_INT; // set PINS and IINS --- insert Protocol and IP checksum
XmitRingDescr[0].DataLength = FlipEndianW(pxNetworkBuffer->xDataLength + 2); // need to include the 2 extra byte for alignment
ENET_TDAR = ENET_TDAR_TDAR_MASK; // tell mac one ring full - xmit it
r = xSemaphoreTake(Xmit_ReleaseSemaphore, 5); // we can't let go unto buff can be released or TCP port issues
xSemaphoreGive(Xmit_GateSemaphore);
bye:
vReleaseNetworkBufferAndDescriptor( pxNetworkBuffer );
return pdTRUE;
}
The Xmit_ReleaseSemaphore is used in the XMIT_ISR
Since I’m using BufferAllocation_1, I look at all the networkbuffer to see if any over-run occurred but found none.
I find it interesting that the corrupt values are multiple 0xa5.
Not sure how to debug this. If you have any suggestion please let me know.
Thanks.
Joe