I'm trying to understand the documents (having in mind this stm32 document: AN3384), stm32 examples and comments on some source files from this stack in order to choose the correct options for my application.
According to the literature I see there are 3 types of pbuf: ROM, RAM and POOL.
Some authors say that:
- PBUF_POOL can be managed as a pools of dynamic memory (heap) that can be freed after being used. But it can also be used as static memory pools. But reading literature "pbuf allocation is performed from a pool of statically pre-allocated pbufs".
- The way for having static or dynamic pbufs is enabling one of this two options: MEM_USE_POOLS or MEMP_MEM_MALLOC.
- Source code comment says about PBUF_POOL: "pbuf payload refers to RAM. This one comes from a pool and should be used for RX... Don't use this for TX with TCP packets".
- PBUF_ROM is for constant data payload that doesn't change.
- PBUF_RAM only can be used as a dynamic ram memory. Only MEMP_MEM_MALLOC.
- Regarding point 1: Are they only static objects or can they be treated as both static and dynamic elements?
- Regarding point 2: is it true that defining MEMP_MEM_MALLOC I would have all the pbufs dynamically allocated? and defining MEM_USE_POOLS is used for having all the pbuf statically allocated. This questions are not clear on stm32 literature documents so I need it to clarify.
- Regarding point 3: If I'm not wrong I can only define one way for memory managing on opt.h file: static or dynamic (MEM_USE_POOLS or not). If I enable static memory for reception incoming pbuf, how could I work with non static pbuf for transmission packets if I've defined static memory (in order to have received pbuf statically allocated)? Can static buffers (PBUF_POOL) be used packets transmission if packets are UDP ones?
- Regarding point 4: I guess in case of need of pbuf_rom the opt.h defined option must be static memory: MEM_USE_POOLS.
- Regarding pint 5: is this assertion true?
I'm a bit confused and I'm not sure if the options I'have explined are correctly understood for me. So, please let me know which of them are my missunderstunding.
Thanks in advance.