cancel
Showing results for 
Search instead for 
Did you mean: 

ETH LWIP with RTOS | bug in ethernetif.c: HAL_ETH_Start_IT

PeterH
Associate II

Setup

STM32CubeIde 1.10.1

STM32CubeMX 6.6.1.202207061420

Regarding

STM32F4/F7/H7 projects (maybe also exends to others) with Ethernet, LwIP and RTOS features activated.

Especially when the WITH_RTOS flag is set in LwIP>General settings.

Symptoms

Ethernet link reconnection fails, initial connection fails if disconnected at startup.

The ethernetif.c files that are created with the configuration as explained above are falsely generated with HAL_ETH_Start(&heth) non-interupt function call in ethernet_link_thread:

// Part of void ethernet_link_thread(void* argument) in ethernetif.c around line 797
 
    if(linkchanged)
    {
      /* Get MAC Config MAC */
      HAL_ETH_GetMACConfig(&heth, &MACConf);
      MACConf.DuplexMode = duplex;
      MACConf.Speed = speed;
      HAL_ETH_SetMACConfig(&heth, &MACConf);
      HAL_ETH_Start(&heth);
      netif_set_up(netif);
      netif_set_link_up(netif);
    }

Call must instead be HAL_ETH_Start_IT(&heth) for WITH_RTOS configuration.

Bug details

The ethernetif.c file templates (ethernetif_f4.ftl, ethernetif_f7.ftl and ethernetif_h7.ftl) in db/templates are missing an if evalution for this line for the WITH_RTOS flag.

Solution for ethernetif_f4.ftl (differerent line numbers in other .ftl files)

Replace

      HAL_ETH_Start(&heth);

in line 891 by

[#if with_rtos == 1]
      HAL_ETH_Start_IT(&heth);
[#else]
      HAL_ETH_Start(&heth);
[/#if][#-- endif with_rtos --]

like done for the HAL_ETH_Stop_IT(&heth) call in line 848.

1 ACCEPTED SOLUTION

Accepted Solutions
KDJEM.1
ST Employee

Hello @PeterH,

This issue is fixed in STM32CubeMX 6.7.0 and in STM32CubeIDE1.11.0.

Please, try to use the last version of STM32CubeMx.6.7.0.

When your question is answered, please close this topic by choosing Select as Best. This will help other users find that answer faster.

Thank you

Kaouthar

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

View solution in original post

2 REPLIES 2
PeterH
Associate II

Just found out, that this issue was also reported on github FW_packages, but only the example projects got fixed, not the CubeMX templates and issue got closed anyway:

https://github.com/STMicroelectronics/STM32CubeF4/issues/120

Also mentioned here:

https://github.com/STMicroelectronics/STM32CubeH7/issues/224

KDJEM.1
ST Employee

Hello @PeterH,

This issue is fixed in STM32CubeMX 6.7.0 and in STM32CubeIDE1.11.0.

Please, try to use the last version of STM32CubeMx.6.7.0.

When your question is answered, please close this topic by choosing Select as Best. This will help other users find that answer faster.

Thank you

Kaouthar

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.