cancel
Showing results for 
Search instead for 
Did you mean: 

Bug in MAC filter configuration - stm32f7xx_hal_eth.c

hunkonrad
Associate

In my last project, I needed to receive all the multicast packets. In order to achieve it, I used the ETH_MACFilterConfigTypeDef built-in structure with the HAL_ETH_SetMACFilterConfig built-in function. After that, I got all the multicast packets, but I couldn't ping the board. At first, I thought there was a problem with the ARP or ICMP settings, but I didn't find anything there. Then I checked the HAL function:

 

 

HAL_StatusTypeDef HAL_ETH_SetMACFilterConfig(ETH_HandleTypeDef *heth, ETH_MACFilterConfigTypeDef *pFilterConfig)
{
  uint32_t filterconfig;
  uint32_t tmpreg1;

  if (pFilterConfig == NULL)
  {
    return HAL_ERROR;
  }

  filterconfig = ((uint32_t)pFilterConfig->PromiscuousMode |
                  ((uint32_t)pFilterConfig->HashUnicast << 1) |
                  ((uint32_t)pFilterConfig->HashMulticast << 2)  |
                  ((uint32_t)pFilterConfig->DestAddrInverseFiltering << 3) |
                  ((uint32_t)pFilterConfig->PassAllMulticast << 4) |
                  ((uint32_t)((pFilterConfig->BroadcastFilter == DISABLE) ? 1U : 0U) << 5) |
                  ((uint32_t)pFilterConfig->SrcAddrInverseFiltering <<  |
                  ((uint32_t)pFilterConfig->SrcAddrFiltering << 9) |
                  ((uint32_t)pFilterConfig->HachOrPerfectFilter << 10) |
                  ((uint32_t)pFilterConfig->ReceiveAllMode << 31) |
                  pFilterConfig->ControlPacketsFilter);

  MODIFY_REG(heth->Instance->MACFFR, ETH_MACFFR_MASK, filterconfig);

  /* Wait until the write operation will be taken into account :
  at least four TX_CLK/RX_CLK clock cycles */
  tmpreg1 = (heth->Instance)->MACFFR;
  HAL_Delay(ETH_REG_WRITE_DELAY);
  (heth->Instance)->MACFFR = tmpreg1;

  return HAL_OK;
}

 

 

In the line 16, there is an inverting logic, which shouldn't be there.

It is not a problem as long as you don't need to change the MACFFR register, because the default value is 0. After you call this function with your custom settings, the function blocks the broadcast packets. If you set "enable" for broadcast filtering, then everythig works fine, you can ping the board.

STM32F746VE

STM32CubeIDE 1.11.0

1 REPLY 1
ASEHST
ST Employee

Hello @hunkonrad,

Thank you for your report. You are absolutely right; bit 5 should be set to 0 when the BroadcastFilter is disabled.

This issue will be fixed in the upcoming release.

Internal ticket number: 185895

With regards,

If your question is answered, please close this topic by clicking "Accept as Solution".