cancel
Showing results for 
Search instead for 
Did you mean: 

Can't ping STM32H743 with LwIP and FreeRTOS

PBOGR.1
Associate

Hi,

SETUP

I am currently working on an STM32H743XIHx integrated in a custom board. I am using the FW package STM32Cube_FW_H7_V1.8.0 and STM32CubeIDE V1.5.1 with STM32CubeMX V6.1.1.

Software side, I am using LwIP and FreeRTOS middlewares, with a static IPv4 adress (no DHCP). Hardware side, I am using a PHY integrated on my custom board, not the PHY embedded in the STM32H743 (LAN8742).

In STM32CubeMX, I enable FreeRTOS and LwIP in RMII. The configuration is the default one for both, except:

  • For LwIP, in the "General Settings" tab, I disable DHCP and configure a static IPv4 adress.
  • For LwIP, in the "Platform Settings" tab, I disable the use of the PHY LAN8742 by selecting "Undefined" under the "Found Solutions" option (which generates a warning during code compilation). Again, this is because I am using my own PHY.

And that's all. The code is then generated, and I do not modify the LwIP or FreeRTOS generated code. I can see that the function MX_LWP_Init() in the task StartDefaultTask() initializes everything.

After seeing the Demo LwIP RTOS code in the STM32Cube package, I also added the necessary memory region configuration in MPU_Config(), and in the linker files STM32H743XI_FLASH.ld and STM32H743XI_RAM.ld (following this Ethernet not working on STM32H7x3).

ISSUE

Everything runs fine on the STM32H743, but I can't ping it. My frame analyzer PC side does send the first ARP request, but it is never answered. After some debugging STM32 side, I found out that the LwIP tcip_thread never receives any message: it is just waiting for one.

COMPARISON

A while ago I did exactly the same thing with an older version of the STM32CubeIDE and of the STM32Cube package (it was STM32Cube_FW_H7_V1.2.0), and the ping WORKED.

I did exactly the same modifications to the LwIP default configuration (DHCP off, static IPv4 and undefined PHY), and no modification to the generated code. This was on the same custom board, with the same everything EXCEPT for the LwIP middleware version, which went from 2.0.3 with the STM32Cube_FW_H7_V1.2.0 package to 2.1.2 with the STM32Cube_FW_H7_V1.8.0 package (as seen in the "General Settings" LwIP tab on STM32CubeMX).

Ping works with this older version, and debug STM32 side clearly shows that the LWIP tcip_thread regularly receives new messages (contrary to what I have in the new version).

TEST

I tried to copy exactly the same code as the working older version, and to report exactly the same settings and configuration in STM32CubeMX LwIP and in the headers file. It is still not working with the newer version (can't ping, not receiving messages)...

I tried to add at the end of the low_level_init() function in ethernetif.c :

netif_set_up(netif);
netif_set_link_up(netif);
HAL_ETH_Start_IT(&heth);

but doesn't work. I can see with the netif structure flags that it is up and initialized, but still not receiving any messages in tcip_thread or tcpip_input (where as I do with the older version where ping works).

QUESTION

So now it seems to me that the only difference between my versions is this LwIP version. But it seems to be enough for it to stop functioning all together...

Is there any difference in the version that could explain that ? Is it a known issue ?

Any help would be really appreciated.

Thanks in advance,

Pierre

2 REPLIES 2
Pavel A.
Evangelist III

Instead of LwIP try FreeRTOS+ TCP:

https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/portable/NetworkInterface/STM32Hxx/NetworkInterface.c

They also modified the STM32 ETH driver, though that work looks incomplete.

Make sure to NOT enable hardware ARP offload - it is broken.

--pa

Thank you Pavel, I will look into that. It might indeed come from the ETH driver rather than LwIP.