2022-12-07 04:17 AM
Hello!
i am working with the STM32H747, i have a cubeMX generated project which uses LWIP for ETH connection and managment.
I've encountered an issue - i have a LWIP tcp server, which connect clients and runs properly. when i disconnect the ethernet cable with out disconnecting rom client first i am not able to recover connection after the cable is reconnected. the only thing that works is restating and this is not an option.
Please advise on possible ways to resolve this issue :)
thanks
2022-12-07 08:38 AM
There should be a function called something like "Ethernet_Link_Periodic_Handle", where the PHY link status is checked on a regular basis.
There you can re-initialize the netif and lwip stuff if link is down.
I think the Cube version doesn't work, that is something I yet have to take care of, so I can't help you anymore.
But there should be a thread somewhere, maybe start here:
2022-12-07 04:21 PM
Rather than relying on Cube generated stuff, check more recent ETH examples here: https://github.com/stm32-hotspot/STM32H7-LwIP-Examples
2022-12-07 06:00 PM
Please check the version of HAL Library.
If you use v1.10.0, it included bug in link callback function.
(it is possible to improve using updated HAL Library as v1.11.0)
You should enable for Link Callback in LwIP Key Options.
Check the code of the ethernet_link_thread() function in the ethernetif.c file
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_IT(&heth);
netif_set_up(netif);
netif_set_link_up(netif);
}
You need to change the initialization function to _IT() as shown below.
HAL_ETH_Start(&heth); -> HAL_ETH_Start_IT(&heth);
Best regards.