I am using FreeRTOS with lwIP. It is working properly. I am able to send from the ZCU104 (arm cortex m53) to a PC and vice-versa via Ethernet rgb8 images. I can send and receive at 1fps 640x480 images (921600 bytes) or at 30fp 2x2 images. However, when I try to send/receive 640x480 images at 30fps the issue comes. I can see on wireshark (here is the .pcap file) that the packages arrive and I can read the first 6404803 bytes. Afterwards, I cannot receive anymore and I cannot read what wireshark is showing. There is a TCP window update, a couple of packets are sent and then only TCP retransmissions.
The task to receive is this:
union Usize {
unsigned char array[4];
uint32_t size;
};
union Usize convert;
if(FD_ISSET(subscriber->publisher_socket_to_receive_fd, fd_set))
{
read_bytes = lwip_recvfrom(subscriber->publisher_socket_to_receive_fd, bufsize, 4, 0, NULL, NULL); //Read first 4 bytes to get the total length of the message
if (read_bytes > 0) {
total_bytes = total_bytes + read_bytes;
convert.array[0] = bufsize[0];
convert.array[1] = bufsize[1];
convert.array[2] = bufsize[2];
convert.array[3] = bufsize[3];
subscriber->data_subscribe_size = convert.size+1+4; // 1 extra for the ID and 4 ones to include the total length
subscriber->data_to_subscribe = malloc((subscriber->data_subscribe_size)*sizeof(unsigned char));
subscriber->data_to_subscribe[0] = subscriber->ID; // ID depends on the HW blocks, so it is directly copied (hardcoded)
subscriber->data_to_subscribe[1] = bufsize[0];
subscriber->data_to_subscribe[2] = bufsize[1];
subscriber->data_to_subscribe[3] = bufsize[2];
subscriber->data_to_subscribe[4] = bufsize[3];
while(total_bytes < convert.size+4)
{
read_bytes = lwip_recvfrom(subscriber->publisher_socket_to_receive_fd, subscriber->data_to_subscribe+total_bytes+1, convert.size-total_bytes+4, 0, NULL, NULL); // Read the rest of the bytes
total_bytes = total_bytes + read_bytes;
}
subscriber->QueueFree = FALSE;
}
}
This is the FreeRTOSConfig.h
#define configUSE_PREEMPTION 1
#define configUSE_MUTEXES 1
#define configUSE_RECURSIVE_MUTEXES 1
#define configUSE_COUNTING_SEMAPHORES 1
#define configUSE_TIMERS 1
#define configUSE_IDLE_HOOK 0
#define configUSE_TICK_HOOK 0
#define configUSE_MALLOC_FAILED_HOOK 1
#define configUSE_TRACE_FACILITY 1
#define configUSE_16_BIT_TICKS 0
#define configUSE_APPLICATION_TASK_TAG 0
#define configUSE_CO_ROUTINES 0
#define configTICK_RATE_HZ (100)
#define configMAX_PRIORITIES (8)
#define configMAX_CO_ROUTINE_PRIORITIES 2
#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 200)
#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 524288 ) )
#define configMAX_TASK_NAME_LEN 10
#define configIDLE_SHOULD_YIELD 1
#define configTIMER_TASK_PRIORITY (configMAX_PRIORITIES - 1)
#define configTIMER_QUEUE_LENGTH 10
#define configTIMER_TASK_STACK_DEPTH ((configMINIMAL_STACK_SIZE) * 2)
#define configASSERT( x ) if( ( x ) == 0 ) vApplicationAssert( __FILE__, __LINE__ )
#define configUSE_QUEUE_SETS 1
#define configCHECK_FOR_STACK_OVERFLOW 2
#define configQUEUE_REGISTRY_SIZE 10
#define configUSE_STATS_FORMATTING_FUNCTIONS 1
#define configNUM_THREAD_LOCAL_STORAGE_POINTERS 0
#define configUSE_TICKLESS_IDLE 0
#define configTASK_RETURN_ADDRESS NULL
#define INCLUDE_vTaskPrioritySet 1
#define INCLUDE_uxTaskPriorityGet 1
#define INCLUDE_vTaskDelete 1
#define INCLUDE_vTaskCleanUpResources 1
#define INCLUDE_vTaskSuspend 1
#define INCLUDE_vTaskDelayUntil 1
#define INCLUDE_vTaskDelay 1
#define INCLUDE_eTaskGetState 1
#define INCLUDE_xTimerPendFunctionCall 1
#define INCLUDE_pcTaskGetTaskName 1
#define configTIMER_ID XPAR_XTTCPS_0_DEVICE_ID
#define configTIMER_BASEADDR XPAR_XTTCPS_0_BASEADDR
#define configTIMER_INTERRUPT_ID XPAR_XTTCPS_0_INTR
#define configUNIQUE_INTERRUPT_PRIORITIES 32
#define configINTERRUPT_CONTROLLER_DEVICE_ID XPAR_SCUGIC_SINGLE_DEVICE_ID
#define configINTERRUPT_CONTROLLER_BASE_ADDRESS XPAR_SCUGIC_0_DIST_BASEADDR
#define configINTERRUPT_CONTROLLER_CPU_INTERFACE_OFFSET 0x10000
void vApplicationAssert( const char *pcFile, uint32_t ulLine );
void FreeRTOS_SetupTickInterrupt( void );
#define configSETUP_TICK_INTERRUPT() FreeRTOS_SetupTickInterrupt()
void FreeRTOS_ClearTickInterrupt( void );
#define configCLEAR_TICK_INTERRUPT() FreeRTOS_ClearTickInterrupt()
#define configGENERATE_RUN_TIME_STATS 0
#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS()
#define portGET_RUN_TIME_COUNTER_VALUE()
#define configCOMMAND_INT_MAX_OUTPUT_SIZE 2096
#define recmuCONTROLLING_TASK_PRIORITY ( configMAX_PRIORITIES - 2 )
#define fabs( x ) __builtin_fabs( x )
#define configMAX_API_CALL_INTERRUPT_PRIORITY (18)
#define configUSE_PORT_OPTIMISED_TASK_SELECTION 1
And this is the lwipopts.h
#define SYS_LIGHTWEIGHT_PROT 1
#define NO_SYS_NO_TIMERS 1
#define OS_IS_FREERTOS
#define DEFAULT_THREAD_PRIO 2
#define TCPIP_THREAD_PRIO (2)
#define TCPIP_THREAD_STACKSIZE 1024
#define DEFAULT_TCP_RECVMBOX_SIZE 200
#define DEFAULT_ACCEPTMBOX_SIZE 5
#define TCPIP_MBOX_SIZE 200
#define DEFAULT_UDP_RECVMBOX_SIZE 100
#define DEFAULT_RAW_RECVMBOX_SIZE 30
#define LWIP_COMPAT_MUTEX 0
#define LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT 1
#define LWIP_TCP_KEEPALIVE 0
#define MEM_ALIGNMENT 64
#define MEM_SIZE 524288
#define MEMP_NUM_PBUF 1024
#define MEMP_NUM_UDP_PCB 4
#define MEMP_NUM_TCP_PCB 128
#define MEMP_NUM_TCP_PCB_LISTEN 64
#define MEMP_NUM_TCP_SEG 256
#define MEMP_NUM_SYS_TIMEOUT 8
#define MEMP_NUM_NETBUF 64
#define MEMP_NUM_NETCONN 64
#define MEMP_NUM_TCPIP_MSG_API 32
#define MEMP_NUM_TCPIP_MSG_INPKT 64
#define MEMP_NUM_NETBUF 64
#define MEMP_NUM_NETCONN 64
#define LWIP_PROVIDE_ERRNO 1
#define MEMP_NUM_SYS_TIMEOUT 8
#define PBUF_POOL_SIZE 16384
#define PBUF_POOL_BUFSIZE 3400
#define PBUF_LINK_HLEN 16
#define ARP_TABLE_SIZE 10
#define ARP_QUEUEING 1
#define ICMP_TTL 255
#define IP_OPTIONS 0
#define IP_FORWARD 0
#define IP_REASSEMBLY 1
#define IP_FRAG 1
#define IP_REASS_MAX_PBUFS 128
#define IP_FRAG_MAX_MTU 3000
#define IP_DEFAULT_TTL 255
#define LWIP_CHKSUM_ALGORITHM 3
#define LWIP_UDP 1
#define UDP_TTL 255
#define LWIP_TCP 1
#define TCP_MSS 2920
#define TCP_SND_BUF 32768
#define TCP_WND 32768
#define TCP_TTL 255
#define TCP_MAXRTX 12
#define TCP_SYNMAXRTX 4
#define TCP_QUEUE_OOSEQ 1
#define TCP_SND_QUEUELEN 16 * TCP_SND_BUF/TCP_MSS
#define CHECKSUM_GEN_TCP 0
#define CHECKSUM_GEN_UDP 0
#define CHECKSUM_GEN_IP 0
#define CHECKSUM_CHECK_TCP 0
#define CHECKSUM_CHECK_UDP 0
#define CHECKSUM_CHECK_IP 0
#define LWIP_FULL_CSUM_OFFLOAD_RX 1
#define LWIP_FULL_CSUM_OFFLOAD_TX 1
#define MEMP_SEPARATE_POOLS 1
#define MEMP_NUM_FRAG_PBUF 256
#define IP_OPTIONS_ALLOWED 0
#define TCP_OVERSIZE TCP_MSS
#define LWIP_DHCP 1
#define DHCP_DOES_ARP_CHECK 1
#define CONFIG_LINKSPEED_AUTODETECT 1
Thanks for the help.