cancel
Showing results for 
Search instead for 
Did you mean: 

Program stucks at ethernet_input function,LWIP ethernet deadlock.

ADank.2
Associate II

Hi, 

I am using FreeRTOS+LWIP on stm32f429zi. All working fine but after some time program control stucks at ethernet_input function. so due to this context switching not happens and other tasks gets affected.

I also tried the below solution obtained from forum, but not working this.

Solution

This code:

  1. if(HAL_ETH_GetReceivedFrame_IT(&EthHandle) != HAL_OK)
  2. return NULL;

Must be replaced with this code:

HAL_StatusTypeDef status;

 LOCK_TCPIP_CORE();

status = HAL_ETH_GetReceivedFrame_IT(&EthHandle);

UNLOCK_TCPIP_CORE();

if (status != HAL_OK) {

return NULL;

}

ethernet_input function is :

0693W00000Hq8QiQAJ.png 

1 REPLY 1
Piranha
Chief II

As can be seen on lines 523 and 533 in your screenshot, ST implemented the lock. They did it in a sub-optimal way, but functionally under typical configuration it works. Use one or the other, not both!

You probably already know:

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

For F1/F2/F4 with RTOS the biggest offenders are ST's link detection and DHCP client code. It breaks lwIP's multi-threading rules and is just completely wrong.