Skip to main content
Graduate II
July 29, 2024
Question

Ethernet comm stucks after several reconnection

  • July 29, 2024
  • 1 reply
  • 2833 views

Hi Team,

I am using STM32F7 nucleo board, CUBEMX version 6.10, FREERTOS CMSIS V2, LAN8742 Eth driver. I am working with LWIP stack  FULLDUPLEX 100Mbps configuration.

configured MCU as a server and re-establish communication in LWIP default thread.

1. case 1: Ethernet communication is working fine if I communicate every 50msec. (transmitting/receiving  250 bytes)

2. case 2: i. If I transmit and receive every 10msec, after several reconnection(removing ethernet cable and               connecting it again) ethernet communication got lost, but all other functionalities are working(other threads).

ii. In this case tried ethernet cable plug out and plug in Link up and link down is detecting but communication not established, Ethernet communication re-established only after MCU reset. 

iii. I tried debugging..but i didn't got any soln 

 So anyone can help me and give me some tips to solve this problem.

@STea 

    This topic has been closed for replies.

    1 reply

    ST Employee
    July 31, 2024

    Hello @lavanya ,

    Ensure that the LwIP configuration is optimized for your use case. For example, increasing the memory size reserved for RX_PBUF in ethernetif.c can help in handling mass UDP data using LWIP_MEMPOOL_DECLARE() for example. 

    Make sure to populate the callback for handling the link down status ethernet_link_status_updated()
    and add it using  netif_set_link_callback() function for proper handling of link down scenario. 
    also make sure that you check for the link before proceeding as shown below in MX Lwip init :

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

    Also make sure to allocate the proper stack size for the thread handling the communication with Ethernet and dynamically freeing the poll after each transmission maybe make it 2048 or more rather thant the default 1024 stack size.
    Regards


     

     

    lavanyaAuthor
    Graduate II
    August 2, 2024

    Hi, @STea  thank you for response,

    I tried above changes but it's not working.

    case 1: Whenever I unplug and replug again Eth default thread(where we init LWIP),is getting callled,

    here i called lwip accept to accept new connection and close previous one.

    this case Eth communication working properly.

    But after 5,6 times plug in and plug out Eth default thread is not called and connection lost.

    I am new to this topic,

    May I know how eth default thread will get trigged.?  ..as far as i only know it will get called if new connection req came.

     

     

    ST Employee
    August 5, 2024

    Hello @lavanya ,

    could you check the status of the link and a dump of PHY registers to check the link status after this problem occurs?
    check the following regs:

    MACCR, MACMIIAR, MACMIIDR, DMASR, DMACHTDR, DMACHRDR, DMACHTBAR, DMACHRBAR, MMCTGFCR


    check the result of this function when the problem occurs:

      PHYLinkState = LAN8742_GetLinkState();
    Also, it will be helpful if you can share with us the ethernetif.c file.
    it could be that after timeout connection, the device gets static address.
    You might then change the application behavior to use only dynamic address or to use only static address or to switch differently from dynamic to static.
    Regards