Skip to content

Commit

Permalink
Fix assertion failure when disconnecting the Ethernet cable (NXP1060 …
Browse files Browse the repository at this point in the history
…- NetworkInterface.c) (#1002)

* Update NetworkInterface.c

The changes that I'm proposing are to make the driver to work in case of cable disconnection. 

In prvEMACHandlerTask, when xSendEventStructToIPTask, we have to pass network interface or it will fail the assertion in xSendEventStructToIPTask "configASSERT( pxInterface != NULL )".

In pxNXP1064_NetworkInterfaceInitialise, if xWaitPHY fails (for instance, the cable is not connected), the switch case will break without doing nothing and the prvEMACHandlerTask will be blocked waiting for the notification. We have to unblock it to try again in case of failure in xEMAC_WaitPHY.

* Update NetworkInterface.c

uncrustify code

* Update NetworkInterface.c

Correct indentation

* Update NetworkInterface.c

Correct indentation

* Update NetworkInterface.c

fix indentation... again

* Update source/portable/NetworkInterface/NXP1060/NetworkInterface.c

Co-authored-by: ActoryOu <jay2002824@gmail.com>

* Update source/portable/NetworkInterface/NXP1060/NetworkInterface.c

Co-authored-by: ActoryOu <jay2002824@gmail.com>

---------

Co-authored-by: ActoryOu <jay2002824@gmail.com>
  • Loading branch information
microcris and ActoryOu authored Aug 22, 2023
1 parent 20d30d9 commit 0c59e71
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions source/portable/NetworkInterface/NXP1060/NetworkInterface.c
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,11 @@ static BaseType_t prvNXP1060_NetworkInterfaceInitialise( NetworkInterface_t * px

if( xStatus != kStatus_Success )
{
if( !xFirstCall )
{
xTaskNotify( receiveTaskHandle, DRIVER_READY, eSetValueWithOverwrite );
}

break;
}
else
Expand All @@ -370,7 +375,7 @@ static BaseType_t prvNXP1060_NetworkInterfaceInitialise( NetworkInterface_t * px
xTaskCreated = xTaskCreate( prvEMACHandlerTask,
"EMAC-Handler",
configMINIMAL_STACK_SIZE * 3,
NULL,
pxInterface,
configMAX_PRIORITIES - 1,
&receiveTaskHandle );

Expand Down Expand Up @@ -505,7 +510,7 @@ static void prvEMACHandlerTask( void * parameter )
if( ulTaskNotifyTake( pdTRUE, pdMS_TO_TICKS( 500 ) ) == pdFALSE )
{
/* No RX packets for a bit so check for a link. */
const IPStackEvent_t xNetworkEventDown = { .eEventType = eNetworkDownEvent, .pvData = NULL };
const IPStackEvent_t xNetworkEventDown = { .eEventType = eNetworkDownEvent, .pvData = parameter };

do
{
Expand Down Expand Up @@ -568,13 +573,13 @@ static void prvEMACHandlerTask( void * parameter )
break;

case kStatus_ENET_RxFrameError: /* Received an error frame. Read & drop it */
PRINTF( "RX Receive Error\n" );
FreeRTOS_printf( ( "RX Receive Error\n" ) );
ENET_ReadFrame( ethernetifLocal->base, &( ethernetifLocal->handle ), NULL, 0, 0, NULL );
/* Not sure if a trace is required. The MAC had an error and needed to dump bytes */
break;

default:
PRINTF( "RX Receive default" );
FreeRTOS_printf( ( "RX Receive default" ) );
break;
}
}
Expand Down

0 comments on commit 0c59e71

Please sign in to comment.