cancel
Showing results for 
Search instead for 
Did you mean: 

NUCLEO-H723ZG + LwIP + FreeRTOS: ping works; no TCP connect

THommer
Associate II

Hello everyone,

I’m looking for some help getting an Ethernet TCP server running using LwIP with FreeRTOS on an STM32.

Current status:

  • Hardware: NUCLEO-H723ZG

  • Stack: LwIP + FreeRTOS

  • Development Environment: STM32CubeMX and STM32CubeIDE
  • TCP client/monitor: Hercules v3.2.8

  • I can ping the board successfully every time (with Windows terminal and Hercules)

  • However, I cannot establish a TCP connection when FreeRTOS is enabled

What’s confusing me is that:

  • If I disable FreeRTOS, I can successfully establish a TCP connection using the CubeMX example LwIP_TCP_Echo_Server

  • Once FreeRTOS is enabled, the TCP connection attempt from Hercules fails (no connection established)

What I’ve tried so far:

  • Multiple CubeMX LwIP + FreeRTOS example configurations

  • Both Netconn and Socket-style APIs

  • Adjusting task priorities and stack sizes

  • Verifying IP address, subnet, gateway, and port settings

  • Confirmed Ethernet link is up and LwIP responds to ping

At this point, it feels like I’m missing something fundamental about:

  • LwIP threading model with FreeRTOS

  • Proper placement of TCP server code (tcpip thread vs user task)

  • FreeRTOS task priorities or blocking behavior affecting LwIP

I’m still fairly new to STM32 development and the STM32Cube/HAL/LwIP ecosystem, so any guidance or common pitfalls would be greatly appreciated.

I can provide:

  • CubeMX configuration screenshots

  • Relevant code snippets

  • Hercules configuration screenshots

Thanks in advance for any help or direction you can provide!

1 ACCEPTED SOLUTION

Accepted Solutions
STackPointer64
ST Employee

Hello @THommer, and thank you for your patience!

After reviewing the project and making the following modifications, I was able to get it to work:

  • The Ethernet Global Interrupt was not enabled, which caused the application to stop working after enabling FreeRTOS.
  • I reconfigured the Memory Protection Unit to protect LwIP memory sections and descriptors in SRAM instead of AXISRAM.
  • I declared the memory sections in the linker file to ensure they align with the MPU configuration.

Ping and TCP server work as expected. The modifications are added to the USER_CODE sections, so you can add other features using STM32CubeMX, generate the project, and it won't affect the Ethernet functionality.

Best regards,

To improve visibility of answered topics, please click 'Accept as Solution' on the reply that resolved your issue or answered your question.

View solution in original post

8 REPLIES 8
STackPointer64
ST Employee

Hello @THommer, and welcome to ST community!

Could you please provide the following information to assist with troubleshooting:

  • The STM32CubeMX configuration file, so I can inspect the Ethernet, FreeRTOS, and LwIP settings.
  • Hercules configuration details.
  • Have you developed the TCP client application on the STM32 side to communicate with the TCP server? If yes, have you confirmed that the port used for connection matches the server’s expected port?
  • If the application experiences a hard fault, could you provide a screenshot of the call stack to identify where the failure occurs?
  • Have you ensured sufficient memory allocation for your LwIP application and declared the appropriate memory sections in the linker file?
  • Have you configured the Memory Protection Unit (MPU) to protect memory sections so descriptors are not cached?

I look forward to your response.

Best regards,

To improve visibility of answered topics, please click 'Accept as Solution' on the reply that resolved your issue or answered your question.
THommer
Associate II

Hello @STackPointer64,

Thank you for the response and for helping me troubleshoot this. Below is the requested information:

1. STM32CubeMX configuration

attached is the .ioc file for one of the projects I am currently using to attempt a FreeRTOS + LwIP TCP echo server on the NUCLEO-H723ZG. This project is based on a ControllersTech Ethernet tutorial that I modified for this board. I have attempted other configurations, including:

All exhibit similar behavior (ping works, TCP connection does not).

2. Hercules configuration

Below is a screenshot of my Hercules TCP client configuration and the messages shown when attempting to connect.

THommer_0-1768252438813.png

This same error (or similar) appears across different Free + LwIP projects I've tested. For reference, below is what I get when I use the LwIP_TCP_Echo_Server (no FreeRTOS) example from the CubeMX example selector for the NUCLEO-H723:

THommer_1-1768254057879.png

3. TCP server / port confirmation

Yes, the TCP server application is implemented on the STM32 side. I have confirmed that the port used by Hercules matches the server port. Example from the code:

		err = netconn_bind(conn, IP_ADDR_ANY, 7);

4. Hard fault behavior

I have only encountered a hard fault once, in one specific example. At the time, I believe it was related to incorrect memory allocation. I am not currently seeing a hard fault in the attached project.

5. LwIP memory allocation

I have experimented with different heap sizes for LwIP, ranging from 10KB to 64KB. Non of these changes resolved the TCP connection issue when FreeRTOS is enabled.

6. MPU / cache configuration

I have tried multiple MPU configurations based on CubeMX defaults, forum recommendations, and example projects. At this point, I am not confident that my MPU configuration is correct, especially with respect to Ethernet DMA descriptors and cacheability, as this is an area I am still learning.
Please let me know if there is any additional information or a specific configuration you would loke me to focus on. I appreciate your time and guidance.

Best regards,

STackPointer64
ST Employee

Hello @THommer, and thank you for your patience!

After reviewing the project and making the following modifications, I was able to get it to work:

  • The Ethernet Global Interrupt was not enabled, which caused the application to stop working after enabling FreeRTOS.
  • I reconfigured the Memory Protection Unit to protect LwIP memory sections and descriptors in SRAM instead of AXISRAM.
  • I declared the memory sections in the linker file to ensure they align with the MPU configuration.

Ping and TCP server work as expected. The modifications are added to the USER_CODE sections, so you can add other features using STM32CubeMX, generate the project, and it won't affect the Ethernet functionality.

Best regards,

To improve visibility of answered topics, please click 'Accept as Solution' on the reply that resolved your issue or answered your question.
THommer
Associate II

Hello @STackPointer64,

Thank you very much for taking the time to review the project and for providing a corrected version that you were able to confirm as working, I really appreciate the detailed feedback.

I tested the updated project on my end, but unfortunately I am still unable to establish a TCP connection. Below is a screenshot of my latest connection attempt from Hercules:

THommer_0-1768401973993.png

Reviewing the changes you made:

  • I have previously tested configurations with the Ethernet global interrupt enabled, though it appears I may have missed enabling it in the specific project I originally sent you.

  • I have also experimented with similar MPU and LwIP memory configurations, including placing descriptors and buffers in SRAM and aligning linker sections accordingly.

  • One difference I noticed is the heap size — I had been testing a range of values, but not the specific 16*1024-20 Byte(s) configuration used in your example.

At this point, since the same project works on your side, I’m starting to suspect there may be an environmental or hardware-related factor on my setup rather than a pure software issue.

A couple of additional observations that may or may not be relevant:

  • I am currently connecting from my PC using a USB 2.0 Type-A to RJ45 Ethernet adapter, as my onboard Ethernet port is occupied.

  • During testing, the STM32H723 MCU becomes noticeably warm to the touch, which made me wonder whether the device may be under heavy load or stuck in an unintended loop. I’m not sure whether this level of temperature rise is expected for the H7 during Ethernet operation.

Please let me know if there are any specific runtime checks, debug points, or hardware-related items you would recommend verifying next. I’m happy to provide additional screenshots, debugger information, or test results if helpful.

Thanks again for your help, this has already been very informative.

Best regards,

STackPointer64
ST Employee

I have changed the network configuration so that it becomes discoverable on my network. You should make the corresponding changes in the lwip.c file.

To improve visibility of answered topics, please click 'Accept as Solution' on the reply that resolved your issue or answered your question.
THommer
Associate II

 

@STackPointer64,

Thank you for pointing out the network configuration change, I initially missed that. After updating the IP configuration to match my local network, I retested the project.

At first, the board stopped responding to ping when configured with 192.168.0.100, and my PC reported the address as being outside the local network range. I have previously been able to ping this address reliably, but after changing the IP to one within my current local subnet, ping started working again.

With the corrected IP:

  • Ping works reliably

  • TCP connection on port 7 still does not establish

Out of curiosity, I changed the server port to 80, and in that case I am able to establish a TCP connection successfully. However, the connection only remains open for about 1–2 minutes before it is forcefully closed.

Below are screenshots showing:

  1. The failed connection attempt on port 7

  2. The successful connection on port 80 (before it eventually disconnects)

THommer_0-1768422536058.png

THommer_1-1768423011672.png

At this point, it seems like:

  • Network configuration is now correct

  • The TCP server is reachable

  • There may be something port-related, timing-related, or task/stack-related affecting the connection stability

Please let me know what you’d recommend checking next. I’m happy to provide any additional runtime information or test other configurations if needed.

 

THommer
Associate II

@STackPointer64,

Just wanted to follow up and close the loop on this.

After adjusting my PC’s Network & Internet settings as you recommended and ensuring both the PC and the board were on the same subnet, I was able to get my desired static IP address working (192.168.0.100) on port 7. The TCP server now connects reliably, and ping and data exchange are working as expected.

Below is a screenshot showing the successful connection and data exchange in Hercules:

THommer_2-1768427603231.png

Thank you for the guidance, this ended up being a network configuration issue on the host side rather than a problem with the STM32/LwIP configuration.

STackPointer64
ST Employee

I am glad you managed to make it work. I’m happy that I could help.

To improve visibility of answered topics, please click 'Accept as Solution' on the reply that resolved your issue or answered your question.