lwip-users
[Top][All Lists]
Advanced

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

[lwip-users] Allocate a pool dynamically?


From: DROZ Loïc
Subject: [lwip-users] Allocate a pool dynamically?
Date: Fri, 2 Jul 2021 06:18:42 +0000

Hello,

 

I ran into a problem with the receive thread of my Ethernet driver working with LwIP and I am looking for some advice. Some context first:

 

The LwIP documentation suggests that incoming data should be transferred into PBUF_POOL packet buffers. If I read the code correctly, this means such pools are allocated from the MEMP_PBUF_POOL memory pool. This is a problem for me in cases where these packet buffers are reused to transmit data later: as the MEMP_PBUF_POOL is allocated as a static array in memory, by default it lies in memory inaccessible by my Ethernet hardware interface, the same is therefore true for the payloads of packet buffers allocated from this pool. As such, the Ethernet hardware interface will fail to transmit packet buffers that were allocated in the receive thread.

 

If I understand correctly, it is possible to relocate the memory arrays of pools, by redefining the LWIP_DECLARE_MEMORY_ALIGNED macro to place the array it allocates in a memory region defined in the linker script. However, my project uses an OS with a complicated build procedure, and I would like to avoid changes to the linker script if possible.

 

My OS uses all the memory accessible by the Ethernet hardware interface, as a heap for dynamic memory allocation. It provides a malloc-like function for dynamic memory allocation. Is it possible to use it to allocate a pool’s memory array? I cannot modify LWIP_DECLARE_MEMORY_ALIGNED directly to declare and initialize it using this malloc-like function, as is it a global variable and requires a constant initializer. I then tried to modify LWIP_DECLARE_MEMORY_ALIGNED to :

 

#define LWIP_DECLARE_MEMORY_ALIGNED(variable_name, size) u8_t variable_name

 

… and then allocating the pool’s memory array at the beginning of the memp_init_pool function, and modifying the struct memp_desc * argument, but it is causing problems with allocation from pools, which I am currently trying to debug. Do you know if there would be a simpler way?

 

Best,

 

Loïc


reply via email to

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