Hi,
Is there any documentation that explain the difference between CONFIG_SPIRAM_USE_MEMMAP , SPIRAM_USE_CAPS_ALLOC and SPIRAM_USE_MALLOC ? What are the pros and cons of each of the approaches? Thank you.
SPIRAM option CONFIG_SPIRAM_USE_MEMMAP
-
- Posts: 1708
- Joined: Mon Oct 17, 2022 7:38 pm
- Location: Europe, Germany
Re: SPIRAM option CONFIG_SPIRAM_USE_MEMMAP
Docs
Basically, it's a hierarchy of functionality:
1. SPIRAM_USE_MEMMAP: Your code can access SPIRAM/PSRAM via pointers. But it's just "bare" memory so you have to manage the memory regions/addresses you use yourself; the PSRAM is like a single, huge, statically allocated byte array. May be an option if you only need one or a few large RAM areas (buffers,...).
2. SPIRAM_USE_CAPS_ALLOC: You can allocate memory from PSRAM via heap_caps_malloc(…, MALLOC_CAP_SPIRAM) (and free() it afterwards). Management of addresses and free/used regions is done by the heap manager for you so you can dynamically allocate and deallocate many smaller blocks of varying sizes, but PSRAM is only used when code explicitly requests it via heap_caps_malloc(...).
3. SPIRAM_USE_MALLOC: PSRAM can be allocated via standard malloc(...) calls too. This way, generic code (third-party,...) which only uses standard malloc(...) and may not even be aware of heap_caps_malloc/PSRAM can "automatically" use PSRAM too. This may however cause issues with some code which expects malloc(...) to allocate fast, unconditionally accessible RAM.
Re: SPIRAM option CONFIG_SPIRAM_USE_MEMMAP
Thank you for the detailed explanation.
Who is online
Users browsing this forum: No registered users and 128 guests