cancel
Showing results for 
Search instead for 
Did you mean: 

Ethernet Lwip Problem STM32H735

Kuttay
Associate III

 

 /* 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. 

1 ACCEPTED SOLUTION

Accepted Solutions
Pavel A.
Evangelist III

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.

View solution in original post

3 REPLIES 3
Pavel A.
Evangelist III

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.

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

Thanks so  much for your answer. I do get connected more frequently than before but Sometimes I just have to restart the power to get connected. Is there any other step that you recommend for better connectivity for ethernet part?