[SOLVED] RAM for mbedTLS

s.allasia
Posts: 21
Joined: Tue Jan 09, 2018 3:12 pm

[SOLVED] RAM for mbedTLS

Postby s.allasia » Wed Jan 24, 2018 10:42 am

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.
Last edited by s.allasia on Thu Jan 25, 2018 10:16 am, edited 1 time in total.

ESP_Angus
Posts: 2196
Joined: Sun May 08, 2016 4:11 am

Re: RAM for mbedTLS

Postby ESP_Angus » Wed Jan 24, 2018 11:38 pm

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

s.allasia
Posts: 21
Joined: Tue Jan 09, 2018 3:12 pm

Re: RAM for mbedTLS

Postby s.allasia » Thu Jan 25, 2018 10:14 am

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!

fertioga
Posts: 2
Joined: Thu Oct 15, 2020 8:09 pm

Re: [SOLVED] RAM for mbedTLS

Postby fertioga » Thu Oct 15, 2020 8:21 pm

i have this problem and i used IDE Arduino... How i can solve?
Can you helpme?

Who is online

Users browsing this forum: No registered users and 46 guests