Hello,
i'm using lwip stack in version 1.4.1 in conjunction with an embedded
system based on a Ti TM4C129X microcontroller.
There is no underlying RTOS and i use the raw api. The port of the lwip
stack is a part of Ti's software development kit.
When i try to tranfer a bigger amount of data (e.g. 1000k or more) via a
TCP connection the lwip stack
stops receiving data before all data has been transferred. It seems that
almost always the same amount of data has been
transferred when the stack stops receiving data. The amount of data
seemingly depends on the configured tcp window size (TCP_WND)
and/or the maximum packet size (TCP_MSS). The timers are served via a
call of sys_check_timeouts() in the main loop.
Turning on the debugging output for pbuf, mem and memp shows that there
seems to be a problem with the allocation and
the deallocation of the data buffers. After transmission is started at
first all seems to be ok.
But after a short time the message
memp_malloc: out of memory in pool PBUF_POOL
pbuf_alloc: allocated pbuf 0
is printed out when the stack tries to allocate new memory. Sometimes it
seems that the stack stops working (system is not reachable
via ehternet any more).
Another error messages that sometimes occure are
ASSERT FAIL at line 650 of
../../../../common/third_party/lwip-1.4.1/src/core/pbuf.c: pbuf_free:
p->ref > 0
pbuf_free: 2000dbac has ref 65535, ending here.
and
pbuf_free: 2001617c has ref 1, ending here.
pbuf_free(2000ddbc)
so i think there is a problem with the management of memory or the lwips
buffers respectively.
Here is a excerpt of the debugging output
[...]
pbuf_alloc(length=20) == 2001617c
pbuf_header: old 200161b0 new 2001619c (20)
pbuf_header: old 2001619c new 2001618e (14)
pbuf_free(2001617c)
pbuf_free: 2001617c has ref 1, ending here.
pbuf_free(2000ddbc)
ASSERT FAIL at line 650 of
../../../../common/third_party/lwip-1.4.1/src/core/pbuf.c: pbuf_free:
p->ref > 0
pbuf_free: 2000ddbc has ref 65535, ending here.
pbuf_alloc(length=512)
pbuf_alloc: allocated pbuf 2000d78c
pbuf_alloc(length=512) == 2000d78c
pbuf_free(2001617c)
pbuf_free: deallocating 2001617c
[...]
When this error occurs it seems that the stack tries to free a buffer
multiple times.
You can see that in the following excerpt. pbuf 2000d78c is freed in
line one and in line
24 it is freed again.
[...]
1 pbuf_free(2000d78c)
2 pbuf_free: deallocating 2000d78c
3 pbuf_free: deallocating 20009bbc
4 pbuf_free: deallocating 200099ac
5 pbuf_free: deallocating 20008d4c
6 pbuf_free: deallocating 2000ac3c
7 pbuf_free: deallocating 20008f5c
8 pbuf_alloc(length=20)
9 pbuf_alloc(length=20) == 2001884c
10 pbuf_header: old 20018880 new 2001886c (20)
11 pbuf_header: old 2001886c new 2001885e (14)
12 pbuf_free(2001884c)
13 pbuf_free: 2001884c has ref 1, ending here.
14 pbuf_alloc(length=512)
15 pbuf_alloc: allocated pbuf 20008f5c
16 pbuf_alloc(length=512) == 20008f5c
17 pbuf_alloc(length=512)
18 pbuf_alloc: allocated pbuf 2000ac3c
19 pbuf_alloc(length=512) == 2000ac3c
20 pbuf_alloc(length=512)
21 pbuf_alloc: allocated pbuf 20008d4c
22 pbuf_alloc(length=512) == 20008d4c
23 pbuf_header: old 2000a61c new 2000a62a (-14)
24 pbuf_free(2000d78c)
25 ASSERT FAIL at line 650 of
../../../../common/third_party/lwip-1.4.1/src/core/pbuf.c: pbuf_free:
p->ref > 0
26 pbuf_free: 2000d78c has ref 65535, ending here.
27 pbuf_header: old 2000a62a new 2000a63e (-20)
28 pbuf_header: old 2000a63e new 2000a652 (-20)
[...]
I do not know if this is the reason that causes the problem or if this
is
an stack internal thing that doesn't really affect the functionality.
In addition here is an excerpt from my lwipopts.h:
#define SYS_LIGHTWEIGHT_PROT 1
#define NO_SYS 1
// ---------- Memory options ----------
#define MEM_LIBC_MALLOC 0
#define MEMP_MEM_MALLOC 0
#define MEM_ALIGNMENT 4
#define MEM_SIZE (32 * 1024)
// ---------- Internal Memory Pool Sizes ----------
#define MEMP_NUM_PBUF 48
#define MEMP_NUM_TCP_PCB 16
#define MEMP_NUM_SYS_TIMEOUT 8
#define PBUF_POOL_SIZE 48
// ---------- TCP options ----------
#define LWIP_TCP 1
#define TCP_MSS 1460
#define TCP_WND (2 * TCP_MSS)
#define TCP_SND_BUF TCP_WND
// ---------- Pbuf options ----------
#define PBUF_LINK_HLEN 16
#define PBUF_POOL_BUFSIZE 512
// default is LWIP_MEM_ALIGN_SIZE(TCP_MSS+40+PBUF_LINK_HLEN)
#define ETH_PAD_SIZE 0
// ---------- Sequential layer options ----------
#define LWIP_NETCONN 0
// ---------- Socket Options ----------
#define LWIP_SOCKET 0
If it is helpful i can post a bigger excerpt of the debugging output.
Thank you for your help!
_______________________________________________
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users