I am struggling with data allocation for LCD buffer which is 640x480/16bit or 320x240/16.
Question - what is the maximum memory chunk I can allocate on ESP?
I recently bought 16Mb ESP modules with 8Mb psram.
I use malloc() however it fails - Guru med or invalid ptr.
I am receiving data with socket so additional question is how large buffer can socket handle?
What do you advise?
Thank you
Maximum memory allocation
- Vader_Mester
- Posts: 300
- Joined: Tue Dec 05, 2017 8:28 pm
- Location: Hungary
- Contact:
Re: Maximum memory allocation
For heap allocation read this. I think it's better to use these functions.
https://esp-idf.readthedocs.io/en/lates ... alloc.html
There is an option in Menuconfig to enaple Heap allocation in SPI RAM.
https://esp-idf.readthedocs.io/en/lates ... alloc.html
There is an option in Menuconfig to enaple Heap allocation in SPI RAM.
Code: Select all
task_t coffeeTask()
{
while(atWork){
if(!xStreamBufferIsEmpty(mug)){
coffeeDrink(mug);
} else {
xTaskCreate(sBrew, "brew", 9000, &mug, 1, NULL);
xSemaphoreTake(sCoffeeRdy, portMAX_DELAY);
}
}
vTaskDelete(NULL);
}
Re: Maximum memory allocation
Hey, appreciate your help! Big thanks!
I will try to transfer bitmap directly to spi through socket)
I will try to transfer bitmap directly to spi through socket)
Re: Maximum memory allocation
I wanted to update on the heap memory allocation if anyone is interested.
With the second option 'Make ram allocatable using heap_caps...' it was possible to allocate around 4Mb SPI ram I'm guessing external on Wrover. I had issues with switching to Wroom and flashing - error 'failed to init external ram'.
I used MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT
heap_caps_get_largest_free_block() on wroom reports around 1.5Mb free ram to use. Expected much more.
Maybe in new framework something will be improved )
With the second option 'Make ram allocatable using heap_caps...' it was possible to allocate around 4Mb SPI ram I'm guessing external on Wrover. I had issues with switching to Wroom and flashing - error 'failed to init external ram'.
I used MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT
heap_caps_get_largest_free_block() on wroom reports around 1.5Mb free ram to use. Expected much more.
Maybe in new framework something will be improved )
- Vader_Mester
- Posts: 300
- Joined: Tue Dec 05, 2017 8:28 pm
- Location: Hungary
- Contact:
Re: Maximum memory allocation
Well the Wroom failed cause it does not ha a SPI RAM. It only has Flash. Only Wrover modules have RAM.Deouss wrote:I wanted to update on the heap memory allocation if anyone is interested.
With the second option 'Make ram allocatable using heap_caps...' it was possible to allocate around 4Mb SPI ram I'm guessing external on Wrover. I had issues with switching to Wroom and flashing - error 'failed to init external ram'.
I used MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT
heap_caps_get_largest_free_block() on wroom reports around 1.5Mb free ram to use. Expected much more.
Maybe in new framework something will be improved )
Some people have found a way to circumvent the need to change menuconfig between modul switching i'll look for the topic.
Wroom should not indicate more than a 2-300kB RAM as it has no external.
Code: Select all
task_t coffeeTask()
{
while(atWork){
if(!xStreamBufferIsEmpty(mug)){
coffeeDrink(mug);
} else {
xTaskCreate(sBrew, "brew", 9000, &mug, 1, NULL);
xSemaphoreTake(sCoffeeRdy, portMAX_DELAY);
}
}
vTaskDelete(NULL);
}
Who is online
Users browsing this forum: Majestic-12 [Bot] and 78 guests