Skip to main content
Sebastian Fett
Associate
June 23, 2017
Question

Stm32F207 Ethernet Multicast RX

  • June 23, 2017
  • 9 replies
  • 3576 views
Posted on June 23, 2017 at 14:04

Hi!

Currently I'm using lwip + tinymDNS on a stm32f207.

The mDNS needs multicast packets. I activated IGMP in the lwip stack and it works.

mDNS messages were sent as mutlicast packets.

But the one thing that did not work was the reception of multicast packets. 

After some digging I found the ETH configuration in the STM HAL drivers. 

There the multicast frame filtering is set to 'PERFECT'. But no filter MACs are set up.

When I wrote the right MAC into the ETH_MACA1 register manually and activated it by setting the AE bit everything worked. 

I would have expected that when I join a igmp group that the according MAC is set as a filter. Or that at least the multicast frame filtering would be disabled alltogether. But I could not find anything related to that in the code. 

Is that functionality not implemented or am I just blind?

My stm32f2xx_hal_eth.c is v1.1.3 from June 2016. And lwip 1.4.1.

Thanks for any hints and best regards,

Sebastian

    This topic has been closed for replies.

    9 replies

    ST Technical Moderator
    June 23, 2017
    Posted on June 23, 2017 at 15:58

    Hi,

    You may check the last version of STM32CubeF2 firmware package with upgrade the version of LwIP v2.0.0

    Regards

    Imen

    In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. Thanks
    Sebastian Fett
    Associate
    June 26, 2017
    Posted on June 26, 2017 at 10:30

    Hi Imen,

    thanks for the tipp.

    I looked into the new CubeF2 with lwip 2.0.0. The relevant stm32f2xx_hal_eth file is now verison 1.2.1 (was 1.1.3 for me). But there seem to be no changes regarding multicast filtering. Since this is a matter of changing settings in the hardware something should show up in the stm files.

    The MAC filters are set with the function 

       static void ETH_MACAddressConfig(ETH_HandleTypeDef *heth, uint32_t MacAddr, uint8_t *Addr)

    in stm32f2xx_hal_eth.c/.h.

    That function is calles once:

      ETH_MACAddressConfig(heth, ETH_MAC_ADDRESS0, heth->Init.MACAddr);

    Here the own MAC address is set (

    ETH_MAC_ADDRESS0). When looking for ETH_MAC_ADDRESS , so any other use of this constant for any of the four registers (including the three registers 1,2,3 used for filtering), nothing comes up.

    So I still think that this functionality is not implemented. Right?

    Best regards

    Sebastian

    thomas wendtland
    Visitor II
    July 20, 2017
    Posted on July 20, 2017 at 15:57

    Hi Sebastian,

    I had a similar problem on the F7. I was able to receive multicast packages by enabling the promiscuous mode for the ETH controller, like so:

    ETH_MACInitTypeDef conf = {0};

    conf.PromiscuousMode = ETH_PROMISCUOUS_MODE_ENABLE;

    HAL_ETH_ConfigMAC(&eth_handle, &conf);

    Using this after a call to 'HAL_ETH_Init' worked for me.

    Thomas

    Sebastian Fett
    Associate
    July 25, 2017
    Posted on July 25, 2017 at 09:05

    Hi Thomas,

    Thank you for the advice. So I guess it is a lack of functionality in the drivers.

    I'm a bit hesitant to switch to promiscuous mode. In the past I had bad experience with device being overwhelmed by mcast traffic that wasn't even relevant for them.

    My solution at the moment is a hack in the driver to set the MAC filter 1 for the mDNS mcast address.

    What I did is:

    in stm32f2xx_hal_eth.h

    typedef struct

    {

        ...

      uint8_t             *MACAddr;                   /*!< MAC Address of used Hardware: must be pointer on an array of 6 bytes */

      uint8_t             *MACFilter;                   /*!< MAC Address of used Hardware: must be pointer on an array of 6 bytes */

     

      uint32_t             RxMode;                    /*!< Selects the Ethernet Rx mode: Polling mode, Interrupt mode.

                                                               This parameter can be a value of @ref ETH_Rx_Mode */

        ...

    } ETH_InitTypeDef;

    in stm32f2xx_hal_eth.c

    static void ETH_MACDMAConfig(ETH_HandleTypeDef *heth, uint32_t err)

    {

        ...

         /* Initialize MAC address in ethernet MAC */

         ETH_MACAddressConfig(heth, ETH_MAC_ADDRESS0, heth->Init.MACAddr);

         ETH_MACAddressConfig(heth, ETH_MAC_ADDRESS1, heth->Init.MACFilter);

    }

    static void ETH_MACAddressConfig(ETH_HandleTypeDef *heth, uint32_t MacAddr, uint8_t *Addr)

    {

        ...

        

      /* Load the selected MAC address high register */

       // BIG BAD HACK TO ENABLE MAC FILTERS

      (*(__IO uint32_t *)((uint32_t)(ETH_MAC_ADDR_HBASE + MacAddr))) = tmpreg1 | 0x80000000;  // enable MAC as Filter, for MAC0 this bit is always 1 anyway

     

      ...

    }

    I will probably not take the time to properly build it into the driver.

    But maybe above code is helpful for somebody.

    Too bad STM did not implement it properly.

    Best regards,

    Sebastian

    Adalgiso
    Associate III
    April 25, 2018
    Posted on April 25, 2018 at 17:13

    Hi,

    I have the same issue, with an STM32F207, the latest version of lwip (2.0.3) and ST driver (1.7).

    Would be great to get some feedback from ST team.

    In the driver hack, how is the MACFilter set?

    Best regards,

    Ang
    Visitor II
    August 15, 2018

    Hi,

    I have similar problem of able to transmit but not receiving anything. I tried the various suggestions listed in this thread but all failed.

    Kamil, do you have any luck in your development that can share?

    Thanks.

    Ang