Maximum memory allocation

Deouss
Posts: 425
Joined: Tue Mar 20, 2018 11:36 am

Maximum memory allocation

Postby Deouss » Thu Jul 26, 2018 10:18 am

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

User avatar
Vader_Mester
Posts: 300
Joined: Tue Dec 05, 2017 8:28 pm
Location: Hungary
Contact:

Re: Maximum memory allocation

Postby Vader_Mester » Thu Jul 26, 2018 12:13 pm

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.
Image

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);
}

Deouss
Posts: 425
Joined: Tue Mar 20, 2018 11:36 am

Re: Maximum memory allocation

Postby Deouss » Thu Jul 26, 2018 12:44 pm

Hey, appreciate your help! Big thanks!
I will try to transfer bitmap directly to spi through socket)

Deouss
Posts: 425
Joined: Tue Mar 20, 2018 11:36 am

Re: Maximum memory allocation

Postby Deouss » Thu Jul 26, 2018 11:40 pm

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 )

User avatar
Vader_Mester
Posts: 300
Joined: Tue Dec 05, 2017 8:28 pm
Location: Hungary
Contact:

Re: Maximum memory allocation

Postby Vader_Mester » Fri Jul 27, 2018 2:21 am

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 )
Well the Wroom failed cause it does not ha a SPI RAM. It only has Flash. Only Wrover modules have RAM.
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: Google [Bot] and 85 guests