LWIP Raw API connection to a server aborted after 19 seconds on Nucleo-F767ZI board
Hi,
I have configured an ethernet application with LWIP and without OS using RAW API, the connection to a server running on a net assistant tool keeps aborting after 19 seconds of running.
With DHCP disabled, the application's ip address is configured to 192.168.3.168, while the server is running with ip address of 192.168.3.40 and port of 5189. The pings to the both ip addresses are OK, the server can be connected from another PC with ip address of 192.168.3.127.
The execution sequence of the code is as below:
tcp_err(pcb, TcpErrorCallBack);
tcp_sent(pcb, TcpSentCallBack);
tcp_recv(pcb, TcpRecvedCallBack);
tcp_poll(pcb, TcpPollCallBack, 10);
tcp_bind(pcb, &localAddr, 0);
err_t err = tcp_connect(pcb, &remoteAddr, remotePort, TcpConnectedCallBack);
The callback function TcpConnectedCallBack() never gets called, and the application has never connected to the server. tcp_poll() is used to execute tcp_connect() every 5 seconds. After the first execution of tcp_connect, all other executions of tcp_connect returns -10 (Conn already established). Sometimes, the first execution of tcp_connect returns -4 (Routing problem). Each time when the first execution of tcp_connect returns ERR_OK,the TcpErrorCallBack gets called with error code of -13(Connection aborted) 19 seconds after its running with following call stack trace:

The tcp_pcb used for tcp_connect has the following contents after the execution of tcp_connect:

When tracking down the execution of tcp_connect, I got this:

It seems there are incoming data packets:

Having done some experiments, I found whether or not I use tcp_poll or tcp_bind, they all do not make difference.
The main.c which includes all the application code attached. The ioc file is also attached.
After 10 hours debugging, I am nearly desperate about this, so please help!
Regards
Chao
E:\SLC\Designs\Software\STM32\TcpF767ZI\Core\Src\main.c
E:\SLC\Designs\Software\STM32\TcpF767ZI\TcpF767ZI.ioc