Page 1 of 1

[SOLVED] RAM for mbedTLS

Posted: Wed Jan 24, 2018 10:42 am
by s.allasia
Hi,
I am using "mbedtls_ssl_setup" funtion for setup an https web server but it is throwing an exception:

Code: Select all

mbedTLS error in mbedtls_ssl_setup(&ssl, &conf):
SSL - Memory allocation failed (-32512) at line 4363
Is ESP32 ram finished?
If yes what I can do?
I found "TLS maximum message content length" in "menuconfig". It set as 16384 bytes but it's its maximum.

Re: RAM for mbedTLS

Posted: Wed Jan 24, 2018 11:38 pm
by ESP_Angus
Hi s.allsia,

It looks like your ESP32 may have run out of free heap memory, yes.

You can check this with:
heap_caps_get_free_size(MALLOC_CAP_8BIT) (maybe see also heap_caps_get_largest_free_block().)

If you have any large static RAM allocations that you can move to heap allocatiosn which are freed, or data which can be marked "const" so it doesn't use RAM, these will free up memory.
s.allasia wrote: I found "TLS maximum message content length" in "menuconfig". It set as 16384 bytes but it's its maximum.
If you know that you're not going to ever receive a message of this length, you can reduce this down to a minimum size determined by the TLS protocols (usually around 4096 bytes). Reducing to 4KB will free 12*2KB = 24KB of mbedTLS session memory usage.

More details here: http://esp-idf.readthedocs.io/en/latest ... ontent-len

Re: RAM for mbedTLS

Posted: Thu Jan 25, 2018 10:14 am
by s.allasia
Great!!!
I reduced RAM size of mbedTLS in "menuconfig" and It's works!
Now I constantly check free heap memory with "heap_caps_get_free_size(MALLOC_CAP_8BIT)"

Thanks a lot Angus!

Re: [SOLVED] RAM for mbedTLS

Posted: Thu Oct 15, 2020 8:21 pm
by fertioga
i have this problem and i used IDE Arduino... How i can solve?
Can you helpme?