Skip to main content
Associate III
July 2, 2024
Solved

Ethernet Lwip Problem STM32H735

 

 /* add the network interface (IPv4/IPv6) with RTOS */
 netif_add(&gnetif, &ipaddr, &netmask, &gw, NULL, &ethernetif_init, &tcpip_input);
 while(1){
 /* Registers the default network interface */
 netif_set_default(&gnetif);

 if (netif_is_link_up(&gnetif))
 {
 /* When the netif is fully configured this function must be called */
 netif_set_up(&gnetif);
 break;
 }
 else
 {
 /* When the netif link is down this function must be called */
 netif_set_down(&gnetif);
 }

 /* Set the link callback function, this function is called on change of link status*/


 netif_set_link_callback(&gnetif, ethernet_link_status_updated);
 }

 

I am trying to get link up in the if statement but in first time run i usually get set down. To fix that i included all to a while statement but it gets stuck in else statement. I am using stm32h735. 

This topic has been closed for replies.
Pavel A.
Pavel A.Best answer
July 2, 2024

The link up/down APIs in the examples are not used correctly  (sorry don't remember details). For a start, ensure that the cable is connected  and wait in while loop before line 7, until the PHY reports link up.   Something like:

 while (!netif_is_link_up(&gnetif)) {}
 netif_set_up(&gnetif);

 Later look up the original LwIP examples on their website and implement dynamic changes in link state.

3 replies

Pavel A.
Pavel A.Best answer
July 2, 2024

The link up/down APIs in the examples are not used correctly  (sorry don't remember details). For a start, ensure that the cable is connected  and wait in while loop before line 7, until the PHY reports link up.   Something like:

 while (!netif_is_link_up(&gnetif)) {}
 netif_set_up(&gnetif);

 Later look up the original LwIP examples on their website and implement dynamic changes in link state.

KuttayAuthor
Associate III
July 3, 2024

Thanks a lot deleting while 1 loop and adding what you said is solved the issue.