CONFIG_MBEDTLS_INTERNAL_MEM_ALLOC vs CONFIG_MBEDTLS_DEFAULT_MEM_ALLOC

glrtheil
Posts: 61
Joined: Tue Dec 07, 2021 2:48 pm

CONFIG_MBEDTLS_INTERNAL_MEM_ALLOC vs CONFIG_MBEDTLS_DEFAULT_MEM_ALLOC

Postby glrtheil » Mon Feb 12, 2024 3:42 pm

What is the difference between CONFIG_MBEDTLS_INTERNAL_MEM_ALLOC and CONFIG_MBEDTLS_DEFAULT_MEM_ALLOC? This doesn't seem to be explained anywhere.

MicroController
Posts: 1696
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: CONFIG_MBEDTLS_INTERNAL_MEM_ALLOC vs CONFIG_MBEDTLS_DEFAULT_MEM_ALLOC

Postby MicroController » Wed Feb 14, 2024 1:45 pm

The help text in menuconfig for "Memory allocation strategy" describes the strategies:

"Internal DRAM memory only" vs. "Either internal or external memory based on default malloc() behavior in ESP-IDF"

glrtheil
Posts: 61
Joined: Tue Dec 07, 2021 2:48 pm

Re: CONFIG_MBEDTLS_INTERNAL_MEM_ALLOC vs CONFIG_MBEDTLS_DEFAULT_MEM_ALLOC

Postby glrtheil » Thu Feb 22, 2024 5:32 pm

MicroController wrote:
Wed Feb 14, 2024 1:45 pm
The help text in menuconfig for "Memory allocation strategy" describes the strategies:

"Internal DRAM memory only" vs. "Either internal or external memory based on default malloc() behavior in ESP-IDF"
Unfortunately, Espressif has broken the help text for menuconfig in vscode plugin, so that information is unavailable to me. That said, even that description tells us nothing. It doesn't explain why internal is actually the default, and what the behavior is in default mode. It's been said elsewhere that default results in static memory allocation, but I'm unable to substantiate that claim.

MicroController
Posts: 1696
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: CONFIG_MBEDTLS_INTERNAL_MEM_ALLOC vs CONFIG_MBEDTLS_DEFAULT_MEM_ALLOC

Postby MicroController » Thu Feb 22, 2024 8:12 pm

It doesn't explain why internal is actually the default, and what the behavior is in default mode.
True. To understand what the options actually mean you have to know about the 'capabilities-based' heap allocator and that you can globally configure malloc's behavior in the IDF: https://docs.espressif.com/projects/esp ... via-malloc

TL;DR: Code (like mbedtls) can explicitly force allocations to internal (or external) RAM by using the capabilities-based allocator API; or the code can just use standard malloc() which may allocate in internal or external RAM depending on how the global CONFIG_SPIRAM_USE is set.

Who is online

Users browsing this forum: Baidu [Spider] and 235 guests