DISCO-H747I multicast

Firstly, is multicast receiving functional on the DISCO-H747I board? If so, can someone point me to my error? I have the following function:

void rn_event_listener()
SocketAddress mcAddr;
const int MCAST_PORT = 5353;
const char * MCAST_GROUP = “”;
int res;

char rx_buf[256];
int rx_len;
printf("Initializing RN evt Listener...\n");
//loop until the network stack is initialized
while(_net->get_connection_status() != NSAPI_STATUS_GLOBAL_UP){
printf("Network stack ready, continuing RN evt Listener Config\n");
UDPSocket rn_server;

res = rn_server.open(_net);
printf("open: %d\n", res);
res = rn_server.connect(mcAddr);
printf("bind: %d\n", res);

int mcResult = rn_server.join_multicast_group(mcAddr);
if ( mcResult!= 0) {
    printf("Error joining the multicast group\n");
    while (true) {}
SocketAddress client;
    rx_len = rn_server.recvfrom(&client, rx_buf, 256);//   recveFrom(addr, rx_buf, 256);
    printf("\n  RN EVENT(%s):%s\r\n\n",(char *)client.get_ip_address(), rx_buf);

if I change the address/port to something other than a multicast address, this will function as expected. I can send to multicast addresses. I am new to mbed studio so it is likely I am missing something.

Any pointers are appreciated.




I have no Idea, but checking the error could be useful…

if ( mcResult!= 0) {
    printf("Error joining the multicast group: %d\n",mcResult);
    while (true) {}

BR, Jan

That’s the thing. There’s no error here. The code makes it to the .recvfrom(…) function. It’s almost like multicast is being filtered by the mac but I haven’t worked out how to check for that.

It appears that the driver doesn’t enable reception of multicast packets, or I’m not initializing it properly. Who knows: I’ve only been testing out mbed os for a few days. Anyway, If I manually set the Receive All packets bit in the ETH_MACPFR register then multicast packets are fed up to the application. Surely this should be adjusted to allow only the multicast packets I am interested in, but for now I just wanted to show I could receive multicast.

Thanks for your help

Yep, it appears that STMicro did not implement multicast support in their ethernet driver. That would be a good thing to add at some point… mbed-os/stm32xx_emac.cpp at 79abe11c3b24caa31da59ee3a0c146557c2784d6 · mbed-ce/mbed-os · GitHub

have you made some more progress in finding the source of the problem? I see that for other ST families the multicast filter is disabled, e.g.: mbed-os/stm32f4_eth_conf.c at 79abe11c3b24caa31da59ee3a0c146557c2784d6 · mbed-ce/mbed-os · GitHub

I see that H7 emac driver ist rewritten and uses a _V2 implementation, which does not use this eth_conf.c. But why? By using a custom target the settings could be overwritten, how should the configuration set for H7? @jeromecoutant

I have not, actually. I was evaluating other processors while I had a free moment, but alas, duty calls.

it looks like enabling Multicast has moved to this function:

HAL_StatusTypeDef HAL_ETH_SetMACFilterConfig(ETH_HandleTypeDef *heth, ETH_MACFilterConfigTypeDef *pFilterConfig);

for compatibilty, the emac init it should enable multicast by default. I will try to test it. Maybe this function can be called also after emac init, then the filtering could be controlled in the user code.