From 47610b88c85818a603eb7fb6f830a66aa4c5781e Mon Sep 17 00:00:00 2001 From: Tony Josi Date: Thu, 13 Jul 2023 19:00:11 +0530 Subject: [PATCH 1/8] fix --- .../portable/NetworkInterface/STM32Hxx/NetworkInterface.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c b/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c index 7105ca26a4..ee41e9d5b0 100644 --- a/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c +++ b/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c @@ -412,7 +412,7 @@ static BaseType_t xSTM32H_NetworkInterfaceOutput( NetworkInterface_t * pxInterfa TickType_t xBlockTimeTicks = pdMS_TO_TICKS( 100U ); uint8_t * pucTXBuffer; - if( xGetPhyLinkStatus( pxInterface ) == = pdPASS ) + if( xSTM32H_GetPhyLinkStatus( pxInterface ) == pdPASS ) { #if ( ipconfigZERO_COPY_TX_DRIVER != 0 ) /* Zero-copy method, pass the buffer. */ @@ -870,8 +870,6 @@ void vNetworkInterfaceAllocateRAMToBuffers( NetworkBufferDescriptor_t pxNetworkB } /*-----------------------------------------------------------*/ -#define __NOP() __ASM volatile ( "nop" ) - static void vClearOptionBit( volatile uint32_t * pulValue, uint32_t ulValue ) { @@ -994,7 +992,7 @@ static void prvEMACHandlerTask( void * pvParameters ) * The function xPhyCheckLinkStatus() returns pdTRUE if the * Link Status has changes since it was called the last time. */ - if( xGetPhyLinkStatus( pxMyInterface ) == pdFALSE ) + if( xSTM32H_GetPhyLinkStatus( pxMyInterface ) == pdFALSE ) { /* Stop the DMA transfer. */ HAL_ETH_Stop_IT( &( xEthHandle ) ); From e3f4288d9789cdc8ff10c6e3366531daa4d05915 Mon Sep 17 00:00:00 2001 From: Tony Josi Date: Fri, 14 Jul 2023 01:18:07 +0530 Subject: [PATCH 2/8] MAC filter updated for DAD and IPv6 all nodes multicast --- .../STM32Hxx/NetworkInterface.c | 74 +++++++++++++++++++ 1 file changed, 74 insertions(+) diff --git a/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c b/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c index ee41e9d5b0..58351191d5 100644 --- a/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c +++ b/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c @@ -203,6 +203,30 @@ const PhyProperties_t xPHYProperties = }; /*-----------------------------------------------------------*/ +static void prvMACAddressConfig( ETH_HandleTypeDef * heth, + uint32_t ulIndex, + uint8_t * Addr ) +{ + uint32_t ulTempReg; + uint32_t ulETH_MAC_ADDR_HBASE = (uint32_t) &(heth->Instance->MACA0HR); + uint32_t ulETH_MAC_ADDR_LBASE = (uint32_t) &(heth->Instance->MACA0LR); + + configASSERT(ulIndex >= ETH_MAC_ADDRESS1); + + /* Calculate the selected MAC address high register. */ + ulTempReg = 0xBF000000ul | ( ( uint32_t ) Addr[ 5 ] << 8 ) | ( uint32_t ) Addr[ 4 ]; + + /* Load the selected MAC address high register. */ + ( *( __IO uint32_t * ) ( ( uint32_t ) ( ulETH_MAC_ADDR_HBASE + ulIndex ) ) ) = ulTempReg; + + /* Calculate the selected MAC address low register. */ + ulTempReg = ( ( uint32_t ) Addr[ 3 ] << 24 ) | ( ( uint32_t ) Addr[ 2 ] << 16 ) | ( ( uint32_t ) Addr[ 1 ] << 8 ) | Addr[ 0 ]; + + /* Load the selected MAC address low register */ + ( *( __IO uint32_t * ) ( ( uint32_t ) ( ulETH_MAC_ADDR_LBASE + ulIndex ) ) ) = ulTempReg; +} + +/*-----------------------------------------------------------*/ /******************************************************************************* @@ -232,6 +256,7 @@ static BaseType_t xSTM32H_NetworkInterfaceInitialise( NetworkInterface_t * pxInt NetworkEndPoint_t * pxEndPoint; HAL_StatusTypeDef xHalEthInitStatus; size_t uxIndex = 0; + BaseType_t xMACEntry = ETH_MAC_ADDRESS1; /* ETH_MAC_ADDRESS0 reserved for the primary MAC-address. */ if( xMacInitStatus == eMACInit ) { @@ -304,6 +329,55 @@ static BaseType_t xSTM32H_NetworkInterfaceInitialise( NetworkInterface_t * pxInt HAL_ETH_DescAssignMemory( &( xEthHandle ), uxIndex, pucBuffer, NULL ); } + { + /* The EMAC address of the first end-point has been registered in HAL_ETH_Init(). */ + for( ; + pxEndPoint != NULL; + pxEndPoint = FreeRTOS_NextEndPoint( pxMyInterface, pxEndPoint ) ) + { + #if ( ipconfigUSE_IPv6 != 0 ) + if( pxEndPoint->bits.bIPv6 != pdFALSE_UNSIGNED ) + { + uint8_t ucMACAddress[ 6 ] = { 0x33, 0x33, 0xff, 0, 0, 0 }; + + ucMACAddress[ 3 ] = pxEndPoint->ipv6_settings.xIPAddress.ucBytes[ 13 ]; + ucMACAddress[ 4 ] = pxEndPoint->ipv6_settings.xIPAddress.ucBytes[ 14 ]; + ucMACAddress[ 5 ] = pxEndPoint->ipv6_settings.xIPAddress.ucBytes[ 15 ]; + prvMACAddressConfig( &xEthHandle, xMACEntry, ucMACAddress ); + xMACEntry += 8; + } + else + #else /* if ( ipconfigUSE_IPv6 != 0 ) */ + { + if( xEthHandle.Init.MACAddr != ( uint8_t * ) pxEndPoint->xMACAddress.ucBytes ) + { + prvMACAddressConfig( &xEthHandle, xMACEntry, pxEndPoint->xMACAddress.ucBytes ); + xMACEntry += 8; + } + } + #endif /* if ( ipconfigUSE_IPv6 != 0 ) */ + + if( xMACEntry > ( BaseType_t ) ETH_MAC_ADDRESS3 ) + { + /* No more locations available. */ + break; + } + } + } + + #if ( ipconfigUSE_IPv6 != 0 ) + { + if( xMACEntry <= ( BaseType_t ) ETH_MAC_ADDRESS3 ) + { + /* 33:33:00:00:00:01 */ + uint8_t ucMACAddress[ 6 ] = { 0x33, 0x33, 0, 0, 0, 0x01 }; + + prvMACAddressConfig( &xEthHandle, xMACEntry, ucMACAddress ); + xMACEntry += 8; + } + } + #endif /* ( ipconfigUSE_IPv6 != 0 ) */ + /* Initialize the MACB and set all PHY properties */ prvMACBProbePhy(); From 6a66c1191fba405056c8436c88901b5da027cdae Mon Sep 17 00:00:00 2001 From: tony-josi-aws Date: Fri, 14 Jul 2023 10:37:50 +0530 Subject: [PATCH 3/8] add more comments --- .../STM32Hxx/NetworkInterface.c | 38 ++++++++++++++++++- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c b/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c index 58351191d5..b4a7a7213f 100644 --- a/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c +++ b/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c @@ -205,14 +205,18 @@ const PhyProperties_t xPHYProperties = static void prvMACAddressConfig( ETH_HandleTypeDef * heth, uint32_t ulIndex, - uint8_t * Addr ) + const uint8_t * Addr ) { uint32_t ulTempReg; uint32_t ulETH_MAC_ADDR_HBASE = (uint32_t) &(heth->Instance->MACA0HR); uint32_t ulETH_MAC_ADDR_LBASE = (uint32_t) &(heth->Instance->MACA0LR); + /* ETH_MAC_ADDRESS0 reserved for the primary MAC-address. */ configASSERT(ulIndex >= ETH_MAC_ADDRESS1); + /* ETH_MAC_ADDRESS0 - ETH_MAC_ADDRESS3 */ + configASSERT(ulIndex <= ETH_MAC_ADDRESS3); + /* Calculate the selected MAC address high register. */ ulTempReg = 0xBF000000ul | ( ( uint32_t ) Addr[ 5 ] << 8 ) | ( uint32_t ) Addr[ 4 ]; @@ -329,6 +333,33 @@ static BaseType_t xSTM32H_NetworkInterfaceInitialise( NetworkInterface_t * pxInt HAL_ETH_DescAssignMemory( &( xEthHandle ), uxIndex, pucBuffer, NULL ); } + #if ( ipconfigUSE_MDNS == 1 ) + { + /* Program the MDNS address. */ + prvMACAddressConfig( &xEthHandle, xMACEntry, ( uint8_t * ) xMDNS_MacAdress.ucBytes ); + xMACEntry += 8; + } + #endif + #if ( ( ipconfigUSE_MDNS == 1 ) && ( ipconfigUSE_IPv6 != 0 ) ) + { + prvMACAddressConfig( &xEthHandle, xMACEntry, ( uint8_t * ) xMDNS_MACAdressIPv6.ucBytes ); + xMACEntry += 8; + } + #endif + #if ( ipconfigUSE_LLMNR == 1 ) + { + /* Program the LLMNR address. */ + prvMACAddressConfig( &xEthHandle, xMACEntry, ( uint8_t * ) xLLMNR_MacAdress.ucBytes ); + xMACEntry += 8; + } + #endif + #if ( ( ipconfigUSE_LLMNR == 1 ) && ( ipconfigUSE_IPv6 != 0 ) ) + { + prvMACAddressConfig( &xEthHandle, xMACEntry, ( uint8_t * ) xLLMNR_MacAdressIPv6.ucBytes ); + xMACEntry += 8; + } + #endif + { /* The EMAC address of the first end-point has been registered in HAL_ETH_Init(). */ for( ; @@ -343,6 +374,9 @@ static BaseType_t xSTM32H_NetworkInterfaceInitialise( NetworkInterface_t * pxInt ucMACAddress[ 3 ] = pxEndPoint->ipv6_settings.xIPAddress.ucBytes[ 13 ]; ucMACAddress[ 4 ] = pxEndPoint->ipv6_settings.xIPAddress.ucBytes[ 14 ]; ucMACAddress[ 5 ] = pxEndPoint->ipv6_settings.xIPAddress.ucBytes[ 15 ]; + + /* Allow traffic destined to Solicited-Node multicast address"of this endpoint + for Duplicate Address Detection (DAD) */ prvMACAddressConfig( &xEthHandle, xMACEntry, ucMACAddress ); xMACEntry += 8; } @@ -369,7 +403,7 @@ static BaseType_t xSTM32H_NetworkInterfaceInitialise( NetworkInterface_t * pxInt { if( xMACEntry <= ( BaseType_t ) ETH_MAC_ADDRESS3 ) { - /* 33:33:00:00:00:01 */ + /* Allow traffic destined to IPv6 all nodes multicast MAC 33:33:00:00:00:01 */ uint8_t ucMACAddress[ 6 ] = { 0x33, 0x33, 0, 0, 0, 0x01 }; prvMACAddressConfig( &xEthHandle, xMACEntry, ucMACAddress ); From e020d04c28f1ef962bfc9f6ca1a5aab841c56bec Mon Sep 17 00:00:00 2001 From: tony-josi-aws Date: Fri, 14 Jul 2023 10:39:02 +0530 Subject: [PATCH 4/8] fix formatting --- .../NetworkInterface/STM32Hxx/NetworkInterface.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c b/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c index b4a7a7213f..e39dee7ec6 100644 --- a/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c +++ b/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c @@ -208,14 +208,14 @@ static void prvMACAddressConfig( ETH_HandleTypeDef * heth, const uint8_t * Addr ) { uint32_t ulTempReg; - uint32_t ulETH_MAC_ADDR_HBASE = (uint32_t) &(heth->Instance->MACA0HR); - uint32_t ulETH_MAC_ADDR_LBASE = (uint32_t) &(heth->Instance->MACA0LR); + uint32_t ulETH_MAC_ADDR_HBASE = ( uint32_t ) &( heth->Instance->MACA0HR ); + uint32_t ulETH_MAC_ADDR_LBASE = ( uint32_t ) &( heth->Instance->MACA0LR ); /* ETH_MAC_ADDRESS0 reserved for the primary MAC-address. */ - configASSERT(ulIndex >= ETH_MAC_ADDRESS1); + configASSERT( ulIndex >= ETH_MAC_ADDRESS1 ); /* ETH_MAC_ADDRESS0 - ETH_MAC_ADDRESS3 */ - configASSERT(ulIndex <= ETH_MAC_ADDRESS3); + configASSERT( ulIndex <= ETH_MAC_ADDRESS3 ); /* Calculate the selected MAC address high register. */ ulTempReg = 0xBF000000ul | ( ( uint32_t ) Addr[ 5 ] << 8 ) | ( uint32_t ) Addr[ 4 ]; @@ -363,8 +363,8 @@ static BaseType_t xSTM32H_NetworkInterfaceInitialise( NetworkInterface_t * pxInt { /* The EMAC address of the first end-point has been registered in HAL_ETH_Init(). */ for( ; - pxEndPoint != NULL; - pxEndPoint = FreeRTOS_NextEndPoint( pxMyInterface, pxEndPoint ) ) + pxEndPoint != NULL; + pxEndPoint = FreeRTOS_NextEndPoint( pxMyInterface, pxEndPoint ) ) { #if ( ipconfigUSE_IPv6 != 0 ) if( pxEndPoint->bits.bIPv6 != pdFALSE_UNSIGNED ) @@ -375,8 +375,8 @@ static BaseType_t xSTM32H_NetworkInterfaceInitialise( NetworkInterface_t * pxInt ucMACAddress[ 4 ] = pxEndPoint->ipv6_settings.xIPAddress.ucBytes[ 14 ]; ucMACAddress[ 5 ] = pxEndPoint->ipv6_settings.xIPAddress.ucBytes[ 15 ]; - /* Allow traffic destined to Solicited-Node multicast address"of this endpoint - for Duplicate Address Detection (DAD) */ + /* Allow traffic destined to Solicited-Node multicast address"of this endpoint + * for Duplicate Address Detection (DAD) */ prvMACAddressConfig( &xEthHandle, xMACEntry, ucMACAddress ); xMACEntry += 8; } From 221472e77c8a27c255ea5821d2c3c6400ee30cfa Mon Sep 17 00:00:00 2001 From: tony-josi-aws Date: Fri, 14 Jul 2023 10:46:45 +0530 Subject: [PATCH 5/8] fix comments --- source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c b/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c index e39dee7ec6..d56582dfd2 100644 --- a/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c +++ b/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c @@ -375,7 +375,7 @@ static BaseType_t xSTM32H_NetworkInterfaceInitialise( NetworkInterface_t * pxInt ucMACAddress[ 4 ] = pxEndPoint->ipv6_settings.xIPAddress.ucBytes[ 14 ]; ucMACAddress[ 5 ] = pxEndPoint->ipv6_settings.xIPAddress.ucBytes[ 15 ]; - /* Allow traffic destined to Solicited-Node multicast address"of this endpoint + /* Allow traffic destined to Solicited-Node multicast address of this endpoint * for Duplicate Address Detection (DAD) */ prvMACAddressConfig( &xEthHandle, xMACEntry, ucMACAddress ); xMACEntry += 8; From c463e558c0233114896cebc44c671b35b478676a Mon Sep 17 00:00:00 2001 From: Tony Josi Date: Fri, 14 Jul 2023 11:59:56 +0530 Subject: [PATCH 6/8] fix review comments --- .../STM32Hxx/NetworkInterface.c | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c b/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c index d56582dfd2..8515df855b 100644 --- a/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c +++ b/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c @@ -391,6 +391,40 @@ static BaseType_t xSTM32H_NetworkInterfaceInitialise( NetworkInterface_t * pxInt } #endif /* if ( ipconfigUSE_IPv6 != 0 ) */ + switch( pxEndPoint->bits.bIPv6 ) + { + #if ( ipconfigUSE_IPv4 != 0 ) + case pdFALSE_UNSIGNED: + if( xEthHandle.Init.MACAddr != ( uint8_t * ) pxEndPoint->xMACAddress.ucBytes ) + { + prvMACAddressConfig( &xEthHandle, xMACEntry, pxEndPoint->xMACAddress.ucBytes ); + xMACEntry += 8; + } + break; + #endif /* ( ipconfigUSE_IPv4 != 0 ) */ + + #if ( ipconfigUSE_IPv6 != 0 ) + case pdTRUE_UNSIGNED: + { + uint8_t ucMACAddress[ 6 ] = { 0x33, 0x33, 0xff, 0, 0, 0 }; + + ucMACAddress[ 3 ] = pxEndPoint->ipv6_settings.xIPAddress.ucBytes[ 13 ]; + ucMACAddress[ 4 ] = pxEndPoint->ipv6_settings.xIPAddress.ucBytes[ 14 ]; + ucMACAddress[ 5 ] = pxEndPoint->ipv6_settings.xIPAddress.ucBytes[ 15 ]; + + /* Allow traffic destined to Solicited-Node multicast address of this endpoint + * for Duplicate Address Detection (DAD) */ + prvMACAddressConfig( &xEthHandle, xMACEntry, ucMACAddress ); + xMACEntry += 8; + } + break; + #endif /* ( ipconfigUSE_IPv6 != 0 ) */ + + default: + /* MISRA 16.4 Compliance */ + break; + } + if( xMACEntry > ( BaseType_t ) ETH_MAC_ADDRESS3 ) { /* No more locations available. */ From 38c21352ac2adfa752fe24acfaedde720b14f4c9 Mon Sep 17 00:00:00 2001 From: tony-josi-aws Date: Fri, 14 Jul 2023 12:03:48 +0530 Subject: [PATCH 7/8] fix formatting --- .../STM32Hxx/NetworkInterface.c | 48 +++++-------------- 1 file changed, 12 insertions(+), 36 deletions(-) diff --git a/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c b/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c index 8515df855b..1ac3237781 100644 --- a/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c +++ b/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c @@ -366,35 +366,11 @@ static BaseType_t xSTM32H_NetworkInterfaceInitialise( NetworkInterface_t * pxInt pxEndPoint != NULL; pxEndPoint = FreeRTOS_NextEndPoint( pxMyInterface, pxEndPoint ) ) { - #if ( ipconfigUSE_IPv6 != 0 ) - if( pxEndPoint->bits.bIPv6 != pdFALSE_UNSIGNED ) - { - uint8_t ucMACAddress[ 6 ] = { 0x33, 0x33, 0xff, 0, 0, 0 }; - - ucMACAddress[ 3 ] = pxEndPoint->ipv6_settings.xIPAddress.ucBytes[ 13 ]; - ucMACAddress[ 4 ] = pxEndPoint->ipv6_settings.xIPAddress.ucBytes[ 14 ]; - ucMACAddress[ 5 ] = pxEndPoint->ipv6_settings.xIPAddress.ucBytes[ 15 ]; - - /* Allow traffic destined to Solicited-Node multicast address of this endpoint - * for Duplicate Address Detection (DAD) */ - prvMACAddressConfig( &xEthHandle, xMACEntry, ucMACAddress ); - xMACEntry += 8; - } - else - #else /* if ( ipconfigUSE_IPv6 != 0 ) */ - { - if( xEthHandle.Init.MACAddr != ( uint8_t * ) pxEndPoint->xMACAddress.ucBytes ) - { - prvMACAddressConfig( &xEthHandle, xMACEntry, pxEndPoint->xMACAddress.ucBytes ); - xMACEntry += 8; - } - } - #endif /* if ( ipconfigUSE_IPv6 != 0 ) */ - - switch( pxEndPoint->bits.bIPv6 ) + switch( pxEndPoint->bits.bIPv6 ) { #if ( ipconfigUSE_IPv4 != 0 ) case pdFALSE_UNSIGNED: + if( xEthHandle.Init.MACAddr != ( uint8_t * ) pxEndPoint->xMACAddress.ucBytes ) { prvMACAddressConfig( &xEthHandle, xMACEntry, pxEndPoint->xMACAddress.ucBytes ); @@ -405,19 +381,19 @@ static BaseType_t xSTM32H_NetworkInterfaceInitialise( NetworkInterface_t * pxInt #if ( ipconfigUSE_IPv6 != 0 ) case pdTRUE_UNSIGNED: - { - uint8_t ucMACAddress[ 6 ] = { 0x33, 0x33, 0xff, 0, 0, 0 }; + { + uint8_t ucMACAddress[ 6 ] = { 0x33, 0x33, 0xff, 0, 0, 0 }; - ucMACAddress[ 3 ] = pxEndPoint->ipv6_settings.xIPAddress.ucBytes[ 13 ]; - ucMACAddress[ 4 ] = pxEndPoint->ipv6_settings.xIPAddress.ucBytes[ 14 ]; - ucMACAddress[ 5 ] = pxEndPoint->ipv6_settings.xIPAddress.ucBytes[ 15 ]; + ucMACAddress[ 3 ] = pxEndPoint->ipv6_settings.xIPAddress.ucBytes[ 13 ]; + ucMACAddress[ 4 ] = pxEndPoint->ipv6_settings.xIPAddress.ucBytes[ 14 ]; + ucMACAddress[ 5 ] = pxEndPoint->ipv6_settings.xIPAddress.ucBytes[ 15 ]; - /* Allow traffic destined to Solicited-Node multicast address of this endpoint + /* Allow traffic destined to Solicited-Node multicast address of this endpoint * for Duplicate Address Detection (DAD) */ - prvMACAddressConfig( &xEthHandle, xMACEntry, ucMACAddress ); - xMACEntry += 8; - } - break; + prvMACAddressConfig( &xEthHandle, xMACEntry, ucMACAddress ); + xMACEntry += 8; + } + break; #endif /* ( ipconfigUSE_IPv6 != 0 ) */ default: From 7721d8d2a8da6da51eba75d62bd0382aa44c1aee Mon Sep 17 00:00:00 2001 From: tony-josi-aws Date: Fri, 14 Jul 2023 16:44:12 +0530 Subject: [PATCH 8/8] update review comments --- source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c b/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c index 1ac3237781..6e319a0210 100644 --- a/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c +++ b/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c @@ -214,7 +214,9 @@ static void prvMACAddressConfig( ETH_HandleTypeDef * heth, /* ETH_MAC_ADDRESS0 reserved for the primary MAC-address. */ configASSERT( ulIndex >= ETH_MAC_ADDRESS1 ); - /* ETH_MAC_ADDRESS0 - ETH_MAC_ADDRESS3 */ + /* STM32Hxx devices support 4 MAC address registers + * (ETH_MAC_ADDRESS0 - ETH_MAC_ADDRESS3), make sure ulIndex is not + * more than that. */ configASSERT( ulIndex <= ETH_MAC_ADDRESS3 ); /* Calculate the selected MAC address high register. */