Good Day,
I have a system running on a Xilinx Zynq. It has been in use for several years, and has worked well.
The core system is based around FreeRTOS+TCP Labs build 160919
We’ve recently made some small changes to the system, and now we’ve run into a problem. We are allowing clients to connect via TCP (using TCP Echo Server Demo as a framework). The clients send a command at their leisure, and receive a reply of data.
This works perfectly. Until it doesn’t. After a random number of requests, the FreeRTOS device will stop replying to the TCP client. The socket is still open, commands can still be sent to the FreeRTOS device - there’s just no response.
I’ve done some debugging, and it seems the freertos_send() is where the failure is occuring. We do have UDP Logging enabled, so I sprinkled to debug printf’s around.
Here’s the code that calls freertos_send()
WrittenSize = 0;
FreeRTOS_debug_printf( ( "PreFreeRTOS_send WriteSize: %d\n", write_size ) );
while (WrittenSize < write_size) {
if (write_size-WrittenSize > CMD_TXBUF_SIZE) { ActualWriteSize = CMD_TXBUF_SIZE; } else { ActualWriteSize = write_size-WrittenSize; }
WrittenSize += FreeRTOS_send( xConnectedSocket, &write_buf[WrittenSize], ActualWriteSize, 0);
FreeRTOS_debug_printf( ( "PostFreeRTOS_send WrittenSize: %d\n", WrittenSize ) );
}
For a while, it works perfectly.
63.126.875 [Command_Server] PreFreeRTOS_send WriteSize: 1969
63.127.075 [Command_Server] PostFreeRTOS_send WrittenSize: 1384
63.128.655 [Command_Server] PostFreeRTOS_send WrittenSize: 1969
64.016.244 [Tmr Svc ] Status LED State: OFF
64.016.272 [Tmr Svc ] Tick Count: 620000
64.016.300 [Tmr Svc ] Eth Status: 4
64.360.036 [Command_Server] PreFreeRTOS_send WriteSize: 1969
64.360.237 [Command_Server] PostFreeRTOS_send WrittenSize: 1384
64.362.354 [Command_Server] PostFreeRTOS_send WrittenSize: 1969
64.710.854 [Command_Server] PreFreeRTOS_send WriteSize: 1969
64.711.054 [Command_Server] PostFreeRTOS_send WrittenSize: 1384
64.711.699 [Command_Server] PostFreeRTOS_send WrittenSize: 1969
65.016.274 [Tmr Svc ] Status LED State: ON
65.016.301 [Tmr Svc ] Tick Count: 630000
65.016.328 [Tmr Svc ] Eth Status: 4
65.582.766 [Command_Server] PreFreeRTOS_send WriteSize: 1969
65.583.007 [Command_Server] PostFreeRTOS_send WrittenSize: 1384
65.584.072 [Command_Server] PostFreeRTOS_send WrittenSize: 1969
66.016.344 [Tmr Svc ] Status LED State: OFF
66.016.371 [Tmr Svc ] Tick Count: 640000
66.016.398 [Tmr Svc ] Eth Status: 4
66.082.665 [Command_Server] PreFreeRTOS_send WriteSize: 1969
66.083.161 [Command_Server] PostFreeRTOS_send WrittenSize: 1384
66.083.523 [Command_Server] PostFreeRTOS_send WrittenSize: 1969
66.155.013 [Command_Server] PreFreeRTOS_send WriteSize: 1969
66.155.252 [Command_Server] PostFreeRTOS_send WrittenSize: 1384
66.156.350 [Command_Server] PostFreeRTOS_send WrittenSize: 1969
66.182.248 [Command_Server] PreFreeRTOS_send WriteSize: 1969
66.182.482 [Command_Server] PostFreeRTOS_send WrittenSize: 1384
66.183.353 [Command_Server] PostFreeRTOS_send WrittenSize: 1969
66.275.432 [Command_Server] PreFreeRTOS_send WriteSize: 1969
66.275.632 [Command_Server] PostFreeRTOS_send WrittenSize: 1384
66.276.274 [Command_Server] PostFreeRTOS_send WrittenSize: 1969
66.287.343 [Command_Server] PreFreeRTOS_send WriteSize: 1969
66.287.557 [Command_Server] PostFreeRTOS_send WrittenSize: 1384
66.288.615 [Command_Server] PostFreeRTOS_send WrittenSize: 1969
66.369.637 [Command_Server] PreFreeRTOS_send WriteSize: 1969
66.369.852 [Command_Server] PostFreeRTOS_send WrittenSize: 1384
66.371.396 [Command_Server] PostFreeRTOS_send WrittenSize: 1969
66.383.218 [Command_Server] PreFreeRTOS_send WriteSize: 1969
66.383.353 [Command_Server] PostFreeRTOS_send WrittenSize: 1384
66.383.955 [Command_Server] PostFreeRTOS_send WrittenSize: 1969
66.461.642 [Command_Server] PreFreeRTOS_send WriteSize: 1969
66.461.767 [Command_Server] PostFreeRTOS_send WrittenSize: 1384
66.461.866 [Command_Server] PostFreeRTOS_send WrittenSize: 1969
66.488.743 [Command_Server] PreFreeRTOS_send WriteSize: 1969
66.488.843 [Command_Server] PostFreeRTOS_send WrittenSize: 1384
66.489.196 [Command_Server] PostFreeRTOS_send WrittenSize: 1969
But then, suddenly,
67.831.410 [Command_Server] PreFreeRTOS_send WriteSize: 1969
67.831.913 [Command_Server] FreeRTOS_send: 7734 -> c0a8651bip:62195: no space
67.831.949 [Command_Server] PostFreeRTOS_send WrittenSize: -28
Looks like -28 corresponds to pdFREERTOS_ERRNO_ENOSPC
So freertos_send bombs because there’s no space in a buffer is what I can gather. Which is fine. But what would cause this error to prevent freertos_send from ever working again?
It’s probably worth mentioning that I have a huge heap, tons of stack size, and 512 network buffer descriptors. This device has 4GB of ram, so I’m not pressed for memory space.
Here are some additional details after the error occurs
ip-debug-stats
Packets received by the network interface 2442
Count of transmitted packets 5937
Count of packets dropped to generate ARP 1
Lowest ever available network buffers 476
Lowest ever free space in network event queue 534
Count of failed attempts to obtain a network buffer 0
Count of expired ARP entries 0
Count of failures to create a socket 0
Count of times recvfrom() has discarding bytes 0
Count of lost Etheret Rx events (event queue full?) 0
Count of lost IP stack events (event queue full?) 0
Count of failed calls to bind() 0
Count of receive timeouts 6445959
Count of failed sends due to oversized payload 0
Count of failed sends due to unbound socket 0
Count of failed transmits due to timeout 0
Number of times task had to wait to obtain a DMA Tx descriptor 0
Failed to notify select group 0
Total network buffers obtained 8176
Total network buffers released 8145
net-stats
1685.722.295 [IP-task ] Prot Port IP-Remote : Port R/T Status Alive tmout Child
1685.722.335 [IP-task ] TCP 7734 0 ip: 0 0/0 eTCP_LISTEN 999999 0 1/20
1685.722.380 [IP-task ] TCP 7734 c0a8651b ip:62195 1/1 eESTABLISHED 19625 14985
1685.722.430 [IP-task ] UDP Port 7734
1685.722.454 [IP-task ] UDP Port 8999
1685.722.478 [IP-task ] UDP Port 65001
1685.722.503 [IP-task ] UDP Port 65002
1685.722.527 [IP-task ] UDP Port 5001
1685.722.549 [IP-task ] UDP Port 1499
1685.722.571 [IP-task ] FreeRTOS_netstat: 8 sockets 476 < 480 < 512 buffers free
task-stats
Task State Priority Stack #
************************************************
UDP CLI R 0 588 7
IDLE R 0 164 3
DetectAndSet B 3 65336 8
IP-task B 5 720 1
EMAC B 6 206 6
Tmr Svc B 3 188 4
LogTask B 0 426 11
Command_Server B 0 65242 12
ReadAndXmit B 4 65212 10
CommandListener S 2 65316 9
query-heap
Current free heap 3049152 bytes, minimum ever free heap 3048784 bytes
Any ideas what could be causing this? Is it possible this has been corrected in a newer version of FreeRTOS+TCP? Are there substantial difficulties in transferring from the old FreeRTOS+TCP Labs release to a newer 10.x release?
Much Thanks,
Ben