STM32H743 + LWIP + FreeRTOS: lwip_connect() Hangs Forever – TCP Client Issue
Hi everyone,
I faced a frustrating issue with lwip_connect() hanging forever when trying to use an STM32 as a TCP client (FreeRTOS V1 + LWIP stack).
🧠 Problem Summary
Calling lwip_connect() inside my STM32 TCP client code caused the system to hang indefinitely.
It was getting stuck at this internal LWIP line:
sys_arch_sem_wait(LWIP_API_MSG_SEM(msg), 0);
This only happens when the TCP/IP stack is waiting for the connection to complete, and never gets a response.
🧪 Observations
- I could ping the server (PC) from STM32 successfully.
- My STM32 TCP server mode worked perfectly.
- But when STM32 tried to connect to Hercules TCP server on port 503 — it hung forever.
- LWIP debug logs showed that:
- tcp_connect() was called
- But the TCP state machine never moved forward
- The stack kept calling tcp_slowtmr: polling application
LWIP Debug Logs
lwip_socket(PF_INET, SOCK_STREAM, 0) = 0
lwip_connect(0, addr=192.168.1.1 port=503)
tcp_connect to port 503
tcp_slowtmr: processing active pcb
tcp_slowtmr: polling application
(repeats forever)Thanks in advance for your guidance and suggestions!
