lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lwip-users] MEM_SIZE


From: Giuseppe Modugno
Subject: Re: [lwip-users] MEM_SIZE
Date: Thu, 15 Mar 2018 11:16:14 +0100
User-agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0

Il 14/03/2018 16:42, Giuseppe Modugno ha scritto:
I was experimenting with lwip memory allocator. I defined:

#define MEM_LIBC_MALLOC  0
#define MEM_USE_POOLS      0
#define MEM_SIZE  (32 * 1024)
#define LWIP_RAM_HEAP_POINTER  ( (void *)0x2007C000 )

I'm using LPC1768 that has a 32kB SRAM block starting from address 0x2007C000. However I have a Hard Fault error during mem_init(), because ram_end is initialized to 0x2007C000 + (32*1024), that is over the available memory.

So MEM_SIZE should be smaller than available heap memory.

Another question regarding memory management of lwip.

I understood lwip uses memory pools for many things (TCP pcbs, UDP pcbs, RAW pcb, timers and so on). The memory pools are defined in include/lwip/priv/memp_std.h. They aren't allocated from the heap, but from pools. I think because it is supposed they must be allocated frequently, so they could bring to fragmentation and the allocation should be fast.

Does lwip use strictly heap (mem_malloc) for its own purposes? It seems yes (I see some mem_malloc calls in httpd, dhcp, pbuf, ...).
Is it possible to compile lwip so it doesn't use heap at all?

I think with the following options:

#define MEM_LIBC_MALLOC  0
#define MEM_USE_POOLS      1
#define MEM_USE_CUSTOM_POOLS 1  /* Needed by MEM_USE_POOLS */

In this way, heap implementation isn't a real heap, but a set of different-sized pools. This set is defined in arhc/lwippools.h. Is it correct?

I tried to compile with this options, but I have this error (for example compiling memp.c):

mingw32-gcc.exe -Wall -std=c11 -Wall -pedantic -Wparentheses -Wsequence-point -Wextra -Wundef -Wshadow -Wpointer-arith -Wcast-qual -Wwrite-strings -Wold-style-definition -Wcast-align -Wmissing-prototypes -Wredundant-decls -Wnested-externs -Wno-address -Wunreachable-code -Wuninitialized -Wlogical-op -Wno-format -g -DLWIP_DEBUG -DDEBUG -Isrc\lwip\src\include -Isrc -Isrc\ports\mingw\lwip_arch -Isrc\ports\mingw -Isrc\bus -Isrc\WpdPack\Include -I..\..\..\work_git -Isrc\lwip\src\include\lwip\apps -c C:\Users\Giuseppe\Documents\work_git\webserver\webserver\src\lwip\src\core\memp.c -o mingw\Debug\src\lwip\src\core\memp.o
In file included from src\lwip\src\include/lwip/memp.h:58:0,
                 from C:\Users\Giuseppe\Documents\work_git\webserver\webserver\src\lwip\src\core\memp.c:48: src\lwip\src\include/lwip/priv/memp_priv.h:89:5: error: expected expression before ')' token
     ) ,
     ^




reply via email to

[Prev in Thread] Current Thread [Next in Thread]