Skip to content

Commit 0c59e71

Browse files
microcrisActoryOu
andauthored
Fix assertion failure when disconnecting the Ethernet cable (NXP1060 - 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 <[email protected]> * Update source/portable/NetworkInterface/NXP1060/NetworkInterface.c Co-authored-by: ActoryOu <[email protected]> --------- Co-authored-by: ActoryOu <[email protected]>
1 parent 20d30d9 commit 0c59e71

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

source/portable/NetworkInterface/NXP1060/NetworkInterface.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,11 @@ static BaseType_t prvNXP1060_NetworkInterfaceInitialise( NetworkInterface_t * px
347347

348348
if( xStatus != kStatus_Success )
349349
{
350+
if( !xFirstCall )
351+
{
352+
xTaskNotify( receiveTaskHandle, DRIVER_READY, eSetValueWithOverwrite );
353+
}
354+
350355
break;
351356
}
352357
else
@@ -370,7 +375,7 @@ static BaseType_t prvNXP1060_NetworkInterfaceInitialise( NetworkInterface_t * px
370375
xTaskCreated = xTaskCreate( prvEMACHandlerTask,
371376
"EMAC-Handler",
372377
configMINIMAL_STACK_SIZE * 3,
373-
NULL,
378+
pxInterface,
374379
configMAX_PRIORITIES - 1,
375380
&receiveTaskHandle );
376381

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

510515
do
511516
{
@@ -568,13 +573,13 @@ static void prvEMACHandlerTask( void * parameter )
568573
break;
569574

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

576581
default:
577-
PRINTF( "RX Receive default" );
582+
FreeRTOS_printf( ( "RX Receive default" ) );
578583
break;
579584
}
580585
}

0 commit comments

Comments
 (0)