Hi,
I am able to reproduce problem on latest SDK 2.13 on board MIMXER1060-EVK. So, problem is not fixed on latest SDK.
I foud exact line where memory overflow happened. It is file fsl_enet.c on line 2508:
index = 0;
do
{
newBuff = (uintptr_t)(uint8_t *)handle->rxBuffAlloc(base, handle->userData, ringId);
if (newBuff != 0U)
{
assert((uint64_t)newBuff + handle->rxBuffSizeAlign[ringId] - 1U <= UINT32_MAX);
rxBuffer = &rxFrame->rxBuffArray[index];
For some reason, end condition of do-while loop is not triggered and index value is incremented above size of rxBuffArray, which is 1. Simply, if index is bigger than 0, is it overflowed.
It is happened when there is a lot of packets on input side and processor is too busy at the time to handle them. In my application, it is happened during OTA upgrade when I am writing received data to Hyperflash. But conditions can be simulated by taskENTER_CRITICAL macro and some delay after.
I made a "dirty" FIX like this:
index = 0;
do
{
if(0U == (curBuffDescrip->control & ENET_BUFFDESCRIPTOR_RX_LAST_MASK))
newBuff = NULL;
else
newBuff = handle->rxBuffAlloc(base, handle->userData, ringId);
if (newBuff != NULL)
{
rxBuffer = &rxFrame->rxBuffArray[index];
I am sure this not universal way how to fix it. It is working only on this exact configuration.
Someone responsible for this driver should really look at it.
Regards,
Peter.