cancel
Showing results for 
Search instead for 
Did you mean: 

CubeMX generated project -> Ethernet link change detection not working

PTiha
Senior

I ask the question here too, maybe more people see it. Sorry for the duplicated topic!

I generated a basic LWIP project for NUCLEO-F429ZI board.

I implemented the void ethernetif_notify_conn_changed(struct netif *netif) -function in main.c.

LWIP_NETIF_STATUS_CALLBACK and LWIP_NETIF_LINK_CALLBACK are 1.

The "__weak void ethernetif_notify_conn_changed(struct netif *netif)" implementation in ethernetif.c are commented out.

When I start the project, I can ping the board. But when I disconnect and reconnect the ethernet cable, the link change not detected.

The "ethernetif_notify_conn_changed" function never executed.

Maybe I miss something important?

Can anyone help me?

Thanks!

2 REPLIES 2
Piranha
Chief II

You're missing the fact that almost all ST's code is a non-working bloatware. Look at this:

https://community.st.com/s/question/0D50X0000BOtfhnSQB/how-to-make-ethernet-and-lwip-working-on-stm32

Your issues are the consequences of flaws described in "lwIP API related" section and probably wrong PHY link status register address/bits.

Pavel A.
Evangelist III

Check for link change should be done as a periodic task, or by interrupt from your PHY.

A periodic check once in 100..500 ms often is enough (see examples).

LwiP does not check link state periodically on its own.

ethernetif_notify_conn_changed is a callback from LwIP if some custom action is needed on interface state changed.

For example if you want to shutdown ETH when interface goes down and start ETH when interface goes up.

-- pa