2021-07-27 09:49 AM
Hi all,
I am working with a stm32f7508dk. My code is running XIP on 1-bank QSPI.
Here is the MEMORY definitions in my linker file:
MEMORY
{
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 320K
/* FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 64K */
FLASH (rx) : ORIGIN = 0x90000000, LENGTH = 16384K
}
Here is the setup in main()
MPU_Config();
SCB_InvalidateICache();
// SCB->CCR |= (1 <<18); /* Enable branch prediction */
// __DSB();
SCB_InvalidateICache();
SCB_EnableICache();
SCB_InvalidateDCache();
SCB_EnableDCache();
I've implemented USB CDC, and LWIP Tcp_echo_client and Tcp_echo_server as Tcp_client and Tcp_server respectively. These are implemented as raw API, no OS.
Tcp_server opens a listen socket and receives messages only rarely -- used to configure the system. It seems to work properly. I see the failure described below whether I've received any messages on the listening port or not.
The system receives data from USB which triggers a message to be sent from the Tcp_client to a database at a specified address. The data-reception and message trigger occurs about once every 3-5 seconds.
Based on various memory configurations, the messaging will fail after as few as 30 messages, or as many as 300 messages, but it always fails.
Note, each message has about 3 frames of data. SYN/ACK ... data .. FIN/ACK look proper using wireshark to analyze on the receiving computer.
Related settings in lwipopts.h:
#define TCP_STATS 1
#define TCP_MSS 536
#define MEM_SIZE 0
#define MEM_LIBC_MALLOC 1
#define MEM_USE_POOLS 0
#define MEMP_MEM_MALLOC 0
#define TCP_DEBUG LWIP_DBG_ON
monitoring TCP debug messages, the messages start as:
tcp_recved: received 242 bytes, wnd 2144 (0).
tcp_recved: received 187 bytes, wnd 2144 (0).
tcp_recved: received 45 bytes, wnd 2144 (0).
tcp_close: closing in State: ESTABLISHED
TCP connection closed: FIN_WAIT_1 27017 -> 52433.
tcp_pcb_purge
tcp_slowtmr: no active pcbs
tcp_slowtmr: no active pcbs
tcp_connect to port 27017
after about 4 messages I see:
tcp_alloc: killing off oldest TIME-WAIT connection
tcp_kill_timewait: killing oldest TIME-WAIT PCB 0x20027ca0 (28)
tcp_connect to port 27017
tcp_recved: received 242 bytes, wnd 2144 (0).
tcp_recved: received 187 bytes, wnd 2144 (0).
tcp_recved: received 45 bytes, wnd 2144 (0).
tcp_close: closing in State: ESTABLISHED
TCP connection closed: FIN_WAIT_1 27017 -> 52437.
tcp_pcb_purge
tcp_slowtmr: no active pcbs
tcp_slowtmr: no active pcbs
tcp_slowtmr: no active pcbs
which, as I understand, is acceptable -- killing and reusing conversations that are finished but not yet timed out.
After a while, I start seeing additional entries announcing 'processing active pcb' and 'polling application' which seem to get more prevalent over time.
tcp_alloc: killing off oldest TIME-WAIT connection
tcp_kill_timewait: killing oldest TIME-WAIT PCB 0x20027c04 (19)
tcp_connect to port 27017
tcp_recved: received 242 bytes, wnd 2144 (0).
tcp_recved: received 187 bytes, wnd 2144 (0).
tcp_slowtmr: processing active pcb
tcp_slowtmr: polling application
tcp_recved: received 45 bytes, wnd 2144 (0).
tcp_close: closing in State: ESTABLISHED
TCP connection closed: FIN_WAIT_1 27017 -> 52574.
tcp_pcb_purge
tcp_slowtmr: no active pcbs
tcp_slowtmr: no active pcbs
More:
tcp_connect to port 27017
tcp_slowtmr: processing active pcb
tcp_slowtmr: polling application
tcp_slowtmr: processing active pcb
tcp_slowtmr: polling application
tcp_recved: received 242 bytes, wnd 2144 (0).
tcp_recved: received 187 bytes, wnd 2144 (0).
tcp_slowtmr: processing active pcb
tcp_slowtmr: polling application
tcp_recved: received 45 bytes, wnd 2144 (0).
tcp_close: closing in State: ESTABLISHED
TCP connection closed: FIN_WAIT_1 27017 -> 52644.
tcp_pcb_purge
tcp_slowtmr: no active pcbs
At some point I start seeing:
tcp_fasttmr: delayed ACK
Shortly after, an endless loop of the following:
tcp_alloc: killing off oldest TIME-WAIT connection
tcp_alloc: killing off oldest LAST-ACK connection
tcp_alloc: killing off oldest CLOSING connection
tcp_alloc: killing oldest connection with prio lower than 64
tcp_alloc: killing off oldest TIME-WAIT connection
tcp_alloc: killing off oldest LAST-ACK connection
tcp_alloc: killing off oldest CLOSING connection
tcp_alloc: killing oldest connection with prio lower than 64
Using MEM_LIBC_MALLOC 1 allowed for many more messages.
I've seen comments pointing toward problems with dcache, DTCM, pool configuration.
Can anyone point me toward a guide on setting up LWIP specifically for the STM32F750x8?
Thanks,
Jim C
2021-08-11 03:16 AM
Hello @JColl.2 ,
Memory allocation might be the problem here because you are opening TCP connections relatively frequently.
You could possibly set up a single TCP connection instead of a per transfer connection and see what the result is.
I hope this helps.
BeST Regards,
Walid