martin-ger / esp-open-lwip

ESP8266 lwIP library with NAT, SLIP, ENC28j60 Ethernet, and routing support
67 stars 25 forks source link

building with MEM_USE_POOLS=1 #11

Open st0ff3r opened 6 years ago

st0ff3r commented 6 years ago

anyone succeed in building with MEM_USE_POOLS=1 to avoid memory fragmentation?

tried to removed attr/DMEM_ATTR parameters in meme_std.h and creating a lwippools.h with:

if MEM_USE_POOLS

LWIP_MALLOC_MEMPOOL_START LWIP_MALLOC_MEMPOOL(100, 256) LWIP_MALLOC_MEMPOOL(50, 512) LWIP_MALLOC_MEMPOOL(20, 1024) LWIP_MALLOC_MEMPOOL(20, 1536) LWIP_MALLOC_MEMPOOL_END

endif / MEM_USE_POOLS /

but still get error when compiling:

In file included from lwip/core/memp.c:141:0: include/lwip/memp_std.h:42:1: error: initializer element is not constant LWIP_MEMPOOL(TCP_PCB, MEMP_NUM_TCP_PCB, sizeof(struct tcp_pcb), "TCP_PCB") ^ include/lwip/memp_std.h:42:1: error: (near initialization for 'memp_num[2]') lwip/core/memp.c:160:47: error: variably modified 'memp_memory_TCP_PCB_base' at file scope

define LWIP_MEMPOOL(name,num,size,desc) u8_t mempmemory ## name ## _base \

                                           ^

include/lwip/memp_std.h:42:1: note: in expansion of macro 'LWIP_MEMPOOL' LWIP_MEMPOOL(TCP_PCB, MEMP_NUM_TCP_PCB, sizeof(struct tcp_pcb), "TCP_PCB") ^

think I don't quite understand how the LWIP_MEMPOOL macro stuff works

any clues?

st0ff3r commented 6 years ago

if I change

define MEMP_NUM_TCP_PCB ((volatile uint32)0x600011FC)

to

define MEMP_NUM_TCP_PCB 5

it gets a little bit further.

makes sense because ((volatile uint32)0x600011FC) is not a static value

now the compilation dies at

lwip/netif/etharp.c: In function 'etharp_query': lwip/netif/etharp.c:1163:20: error: 'MEM_ARP_QUEUE' undeclared (first use in this function) memp_free(MEM_ARP_QUEUE, old);

st0ff3r commented 6 years ago

in lwip/netif/etharp.c line 116 memp_free(MEM_ARP_QUEUE, old);

needs to be

memp_free(MEMP_ARP_QUEUE, old);

st0ff3r commented 6 years ago

ld: address 0x4000e118 of build/app.out section .bss' is not within regiondram0_0_seg' ld: address 0x4000e118 of build/app.out section .bss' is not within regiondram0_0_seg' liblwip_open.a(dns.o): In function dns_parse_name': dns.c:(.irom0.text+0x54): undefined reference toos_zalloc' dns.c:(.irom0.text+0x58): undefined reference to `os_free'

can see from my linker map that memp is eating up the RAM:

.bss 0x000000003fff0c40 0x1b34c liblwip_open.a(memp.o)

any suggestions?

martin-ger commented 6 years ago

No real idea - sorry. As the code is actually from the esp-open-sdk I assume, that never anybody has tried to compile this with this option for the ESP.

I would read the last error: .bbs not within dram as: too much RAM allocated for static variables (buffers)?