cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H7 Ethernet - RX frame filtering issue

LDroz.2
Associate II

Hello,

As part of my internship, I have to develop a custom driver for the STM32H7's ETH interface. My company is aware that one already exists within the STM32Cube package, but they specifically want me to write my own.

My issue is that the interface does not receive frames directed to my interface, only broadcast frames, unless I either set the interface in "receive all" or promiscuous mode.

I programmed the board's MAC address in the MACA0HR and MACA0LR registers. I did not modify the other MAC address registers. I did the rest of the initialization following what is done in STM32Cube for my board (NUCLEO H743ZI).

I checked the state of the MACA0HR and MACA0LR registers with a debugger and it seems OK. I also use source address replacement for TX, and the correct MAC address is inserted by the interface before transmitting frames.

Is there anything else I need to make filtering work? Basically, I want the interface to accept broadcast frames, and frames with dest MAC addr == my board's interface MAC addr.

Regards.

6 REPLIES 6
Pavel A.
Evangelist III

Hello, thank you for your reply.

I have compared both this fork and the original ST driver against my implementation, and all 3 perform the same modifications to registers MACPFR, MACA0LR, MACA0HR, MACA1LR, MACA1HR, MACA2LR, MACA2HR, MACA3LR, MACA3HR.

MACPFR is left to its reset value, meaning its HUC bit will be reset, thus using perfect filtering, as per the STM32H7 Ethernet documentation.

MACA1LR, MACA1HR, MACA2LR, MACA2HR, MACA3LR, MACA3HR are also left to their reset value, meaning their AE (address enable) is reset, thus disabling these additional addresses for filtering.

My interface's MAC address (00:00:00:00:00:02) is programmed in the MACA0LR and MACA0HR registers. This address is the same as the one used in the FreeRTOS + LwIP example for NUCLEO H743ZI from STM32Cube, which works correctly. I have checked with a debugger the state of these registers in both my implementation, and the STM32Cube example. They are an exact match.

As I understand the STM32H7 documentation and examples, there does not seem to be any other configuration required for link-layer destination address perfect filtering. I have also kept VLAN and Layer 3-4 filtering disabled. Am I missing anything?

Regards.

Do you use interrupts or polling? If the latter do you check for error conditions, such as RX DMA stopped? ST examples lack this.

I use interrupts. The only interrupts I receive are Receive Complete and Receive Buffer Unavailable, which I both expect and handle.

Ptrep.1
Associate

@Loïc Droz​ I know it's late, but I need an answer about Promiscuous mode : how do you set that on your STM32H7 ETH interface ? Do you use the function "HAL_ETH_SetMACFilterConfig" ?

I use a switch which is configured in port mirroring , so my STM32H7 will received copies of packets originally destinated for another MAC addres. My STM32 don't see the packets coming from the switch so I have to enable promiscuous mode. Could you tell me where do you activate this mode ?

I'm sorry, I don't know the answer to your question but you are the only one who deals with promiscuous mode on a STM32H7 board.

Best regards,

No worries. I didn't use the STM32 HAL myself, but yes I believe you can use HAL_ETH_SetMACFilterConfig() to set promiscuous mode. Try something like:

pFilterConfig->PromiscuousMode = ENABLE;
HAL_ETH_SetMACFilterConfig(heth, pFilterConfig);

Which should enable promiscuous mode by setting one bit in the ETH_MACPFR_PR register, which is what I did.