Skip to main content
HMüll.4
Senior
August 26, 2025
Solved

lwip on STM32H7 does not transmit anything due to timeout

  • August 26, 2025
  • 1 reply
  • 645 views

Hi,

I'm running a (custom) board that makes use of an STM32H723VET and a LAN8742. A project is set up in CubeMX that makes use of lwIP together with this LAN-chip (there is an issue in CubeMX which deselects the LAN8742 on loading the CubeMX file, but this is something I have already catched). lwIP is configured to make use of a static IP.

Now when I run my code in CubeIDE, I can see the interface is set up properly and it detects a 100 MBit duplex connection.

Unfortunately that's all what works. In call of netif_set_link_up(), an ARP-request is tried to be transmitted. Some layers deeper, within the HAL-functions, this ARP-request can not be sent. Function HAL_ETH_Transmit() ends up in an timeout while waiting for these ARP-data being transmitted.

That lets me assume, something wents wrong with the hardware initialisation. However, functions HAL_ETH_Init() and LAN8742_Init() go through without any error and function LAN8742_GetLinkState() returns a proper link state LAN8742_STATUS_100MBITS_FULLDUPLEX.

So...what could be the reason for the transmission timeout? Any idea where to look/what to check?

Thanks!

Edited by ST moderator to put accurate Labels to the post.

Best answer by HMüll.4

Finally I found it: my static IP came out of an internal data structure, so the CubeMX-generated code was not used. For lwIP it has to be byte converted with htonl() prior to handing it over to lwIP:

 

 ipaddr.addr = htonl(globalConfig.ip.addr);
 netmask.addr = htonl(globalConfig.nm.addr);
 gw.addr = htonl(globalConfig.gw.addr);

 /* add the network interface (IPv4/IPv6) without RTOS */
 netif_add(&gnetif, &ipaddr, &netmask, &gw, NULL, &ethernetif_init, &ethernet_input);

1 reply

HMüll.4
HMüll.4Author
Senior
August 27, 2025

OK; I'm a bit closer: the post from https://community.st.com/t5/stm32-mcus/how-to-create-a-project-for-stm32h7-with-ethernet-and-lwip-stack/ta-p/49308 solved the transmission issue mentioned above. In my case, the whole memory mapping stuff was missing.

Now the transmission works, the link-status-update callback is used properly when connecting/disconnecting the network cable, but that's all.

No ping is replied. there is a call to MX_LWIP_Process() in my main loop, but that does not seem to be the trick. It handles some ARP-stuff, but nothing more, no higher-level messages such as the ICMP.

Any idea what could be missing?

Thanks!

 

HMüll.4
HMüll.4AuthorBest answer
Senior
August 27, 2025

Finally I found it: my static IP came out of an internal data structure, so the CubeMX-generated code was not used. For lwIP it has to be byte converted with htonl() prior to handing it over to lwIP:

 

 ipaddr.addr = htonl(globalConfig.ip.addr);
 netmask.addr = htonl(globalConfig.nm.addr);
 gw.addr = htonl(globalConfig.gw.addr);

 /* add the network interface (IPv4/IPv6) without RTOS */
 netif_add(&gnetif, &ipaddr, &netmask, &gw, NULL, &ethernetif_init, &ethernet_input);