Hello people,

I've been trying to figure out how lwIP uses memory and it's really important to know exact (or maximum) amount of memory that lwIP uses. I am using lwIP v1.4.1 with FreeRTOS v8.2.3 on ZYNQ custom board. Right now, I am working with application examples provided by Xilinx (XAPP1026 <https://www.xilinx.com/support/documentation/application_notes/xapp1026.pdf>). On ZYNQ board, I am running iperf <https://en.wikipedia.org/wiki/Iperf> server, and on PC iperf client.

When both MEMP_MEM_MALLOC and MEM_LIBC_MALLOC are 0 then everything works completely expected. However, when I set MEMP_MEM_MALLOC to 1 (according to RAM usage article from lwIP wiki <http://lwip.wikia.com/wiki/Lwipopts.h>), so that every piece of dynamically allocated memory comes from heap of MEM_SIZE size, application always crashes, no matter how big or small MEM_SIZE is (I have a lot of RAM, so I tried to put MEM_SIZE to even more then 20 MB!). Application crashes because two of FreeRTOS asserts fail, I get these two prints: "Assert failed in file queue.c, line 1224" and "Assert failed in file port.c, line 424". According to call trace (which I provided in attachments), it crashes when XEmacPs_IntrHandler (I am using Xilinx layer 2 drivers) tries to allocate memory for pbuf.

Is this problem even related to lwIP or maybe to FreeRTOS or Xilinx drivers, what do you think? I am also providing the entire lwipopts.h, so that you can see whether some other options need to be changed in order to make application work with MEMP_MEM_MALLOC set to 1.

Thanks in advance.

#ifndef __LWIPOPTS_H_
#define __LWIPOPTS_H_

#ifndef PROCESSOR_LITTLE_ENDIAN
#define PROCESSOR_LITTLE_ENDIAN
#endif

#define SYS_LIGHTWEIGHT_PROT 1


#define OS_IS_FREERTOS
#define DEFAULT_THREAD_PRIO 2
#define TCPIP_THREAD_PRIO (2 + 1)
#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 MEM_ALIGNMENT 64
#define MEM_SIZE 786432
#define MEMP_NUM_PBUF 16
#define MEMP_NUM_UDP_PCB 4
#define MEMP_NUM_TCP_PCB 32
#define MEMP_NUM_TCP_PCB_LISTEN 8
#define MEMP_NUM_TCP_SEG 256
#define MEMP_NUM_SYS_TIMEOUT 8
#define MEMP_NUM_NETBUF 8
#define MEMP_NUM_NETCONN 16
#define MEMP_NUM_TCPIP_MSG_API 16
#define MEMP_NUM_TCPIP_MSG_INPKT 64
#define MEMP_MEM_MALLOC 1

#define MEMP_NUM_NETBUF     8
#define MEMP_NUM_NETCONN    16
#define LWIP_PROVIDE_ERRNO  1
#define MEMP_NUM_SYS_TIMEOUT 8
#define PBUF_POOL_SIZE 256
#define PBUF_POOL_BUFSIZE 1700
#define PBUF_LINK_HLEN 16

#define ARP_TABLE_SIZE 10
#define ARP_QUEUEING 1

#define ICMP_TTL 255
#define LWIP_BROADCAST_PING 1
#define LWIP_MULTICAST_PING 1

#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 1500
#define IP_DEFAULT_TTL 255
#define LWIP_CHKSUM_ALGORITHM 3

#define LWIP_UDP 0
#define UDP_TTL 255

#define LWIP_TCP 1
#define TCP_MSS 1460
#define TCP_SND_BUF 8192
#define TCP_WND 2048
#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 LWIP_SO_RECVBUF 0
#define LWIP_SO_RECVTIMEO 0
#define RECV_BUFSIZE_DEFAULT 8192
#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 NO_SYS_NO_TIMERS 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 0
#define DHCP_DOES_ARP_CHECK 0

#define CONFIG_LINKSPEED_AUTODETECT 1

#define LWIP_STATS 1
#define LWIP_STATS_DISPLAY 1

#endif
_______________________________________________
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users

Reply via email to