lwIP init sequence in STM32F439 Nucleo Cube
Hi,
I have created an lwIP + FreeRTOS application using CubeIDE for my Nucleo 439 Board. The problem here is that the the init sequence generated by CubeIDE
LWIP/App/lwip.c function
MX_LWIP_Init()
it calls the following function without checking for the actual status of PHY (even when it is possible)
/* We must always bring the network interface up connection or not... */
netif_set_up(&gnetif);
So, even if I don't plug in my LAN cable to the RJ45 of Nucleo board, my network is marked as "UP", while actually its is "DOWN"
I don't understand the need for this. I have seen the the EthLink thread is already testing the status of the actual phy and calling the same function for us. So what is the need to call it in init sequence?
Ethernet Link State (Physical Ethernet Cable connection)
This thread manages the Link state of netif.

The thread's task function is defined in the file LWIP/Target/ethernetif.c
It runs in an infinite loop. With 100ms delay between loops.
In each iteration of the loop it gets the link state using PHY driver function LAN8742_GetLinkState()
The function is the part of BSP (Board Support Package) thus it is present inside the Driver\BSP\Components\lan8742.c
From its return value we can know if
- The jack is connected to a 10 or 100Mbps network.
- Jack is not at all connected. (value eq 1)
- Auto negotiation in progress.
- Error condition (less than 0)
This thread calls the following functions for us to keep the netif state in sync.
netif_set_up(netif); netif_set_link_up(netif); |
