cancel
Showing results for 
Search instead for 
Did you mean: 

lwIP pool location

abeslic
Associate II

Hi,

Does any one how to make pbuf’s be in a certain memory range?

For example when I call pbuf_alloc(PBUF_RAW, PBUF_POOL_BUFSIZE, PBUF_POOL) it will allocate a pbuf from a pool that is contained in this array memp_memory, is there a better way/proper way to do this no how I did.

memp.c:

....

 /** This is the actual memory used by the pools (all pools in one big block). */

static u8_t memp_memory[MEM_ALIGNMENT - 1

#define LWIP_MEMPOOL(name,num,size,desc) + ( (num) * (MEMP_SIZE + MEMP_ALIGN_SIZE(size) ) )

#include "lwip/memp_std.h"

] __attribute__((section(".my_mem")));

....

I just added __attribute__((section(".my_mem"))), in my linker scrip I have that section tied to an absolute address.

And I'm using lwIP 1.4.0.

 

Best regards,

Alex

2 REPLIES 2
STea
ST Employee

Hello @abeslic ,

if you are using CubeIDE the way to set you memory pool in a dedicated memory region has no apparent flows from my side  .

but if you want to place the Pbufs in a spesific place in RAM for example you can do the following :

To relocate a pool, declare it as extern in cc.h. Example for GCC:

* extern u8_t \_\_attribute\_\_((section(".onchip_mem"))) memp_memory_my_private_pool_base[];

__attribute__((section(".Rx_PoolSection"))) extern u8_t memp_memory_RX_POOL_base[];

BR

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
LCE
Principal

With LWIP 2.x and a STM32H733 I'm using this in lwip/arch.h :

in lwip/arch.h:
#ifndef LWIP_DECLARE_MEMORY_ALIGNED
#define LWIP_DECLARE_MEMORY_ALIGNED(variable_name, size) u8_t variable_name[LWIP_MEM_ALIGN_BUFFER(size)] __ATT_SECT_LWIPPOOL
#endif

in main.h:
#define __ATT_SECT_LWIPPOOL     __attribute__((section(".LwipPoolSection")))

in linker file:
SRAXI_D1(xrw)		: ORIGIN = 0x24000000, LENGTH = 320K
...
/* lwIP POOL section */
	.LwipPoolSection (NOLOAD):
	{
		. = ALIGN(4);
		*(.LwipPoolSection)
		*(.LwipPoolSection*)
		. = ALIGN(4);
	} >SRAXI_D1
/*	} >SRAXI_D1_LWIP */