pbuf alloc not able to allocate memory

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
User39504831
Level 2
Level 2
First like received First solution authored 10 replies posted

Hi

Am using TC37x lite kit and implementing UDP using lwip stack. 

Here's how am using `pbuf`

`

char buffer[100] = "hello world";

struct pbuf *p = pbuf_alloc(PBUF_TRANSPORT, sizeof(buffer), PBUF_RAM);
`
after this am getting `p` as NULL.
 
Am using default linker script ( generated from ADS), psram_x = 64k and heap = 4k
This udp implementation is the only one currently running on my board. So am confused as to why memory is not getting allocated
Need some help
Thanks
0 Likes
1 Solution
Di_W
Moderator
Moderator
Moderator
500 solutions authored 1000 replies posted 250 solutions authored

Please trace into pbuf_alloc, and then should know the reason. 

By default, lwIP utilizes a static heap for mem_malloc(), but you have the option to use the C standard library malloc () and free() instead. Additionally, lwIP allows custom memory pools to emulate dynamic allocation.

You can check which of the three memory allocation methods mentioned above is being used by your system and ensure that the memory is properly initialized.

Reference 1: Buffer and Memory Management

Chapters: 6.1 Packet Buffers (Pbufs) and 6.2 Memory Management

Link: https://www.artila.com/download/RIO/RIO-2010PG/lwip.pdf

Reference 2: lwIP Application Developers Manual

Chapter: lwipopts.h

Section: Memory Management (RAM Usage)

Link: https://lwip.fandom.com/wiki/Lwipopts.h

View solution in original post

0 Likes
1 Reply
Di_W
Moderator
Moderator
Moderator
500 solutions authored 1000 replies posted 250 solutions authored

Please trace into pbuf_alloc, and then should know the reason. 

By default, lwIP utilizes a static heap for mem_malloc(), but you have the option to use the C standard library malloc () and free() instead. Additionally, lwIP allows custom memory pools to emulate dynamic allocation.

You can check which of the three memory allocation methods mentioned above is being used by your system and ensure that the memory is properly initialized.

Reference 1: Buffer and Memory Management

Chapters: 6.1 Packet Buffers (Pbufs) and 6.2 Memory Management

Link: https://www.artila.com/download/RIO/RIO-2010PG/lwip.pdf

Reference 2: lwIP Application Developers Manual

Chapter: lwipopts.h

Section: Memory Management (RAM Usage)

Link: https://lwip.fandom.com/wiki/Lwipopts.h

0 Likes