Skip to content
Snippets Groups Projects
Commit a7d6ef3a authored by Angus Gratton's avatar Angus Gratton Committed by moon2
Browse files

esp32: Allow malloc() to allocate from SPIRAM.


Also shrinks the "prefer internal" threshold to 8KB, any allocation larger
than this will try PSRAM first.

Change the mbedTLS config to use regular malloc() as well, instead of
internal only.  The default is set to internal-only due to to potential
physical security issue of readout via PSRAM on the original ESP32.
However, as MicroPython runs from plaintext flash and all other context is
in the MP heap of PSRAM then it's hard to see how worsens physical security
for MP.

This work was funded through GitHub Sponsors.

Signed-off-by: default avatarAngus Gratton <angus@redyak.com.au>
parent 29d5f767
No related branches found
No related tags found
1 merge request!388micropython: Backport upstream GC improvements
...@@ -49,6 +49,15 @@ CONFIG_LWIP_PPP_CHAP_SUPPORT=y ...@@ -49,6 +49,15 @@ CONFIG_LWIP_PPP_CHAP_SUPPORT=y
# Use 4kiB output buffer instead of default 16kiB (because IDF heap is fragmented in 4.0) # Use 4kiB output buffer instead of default 16kiB (because IDF heap is fragmented in 4.0)
CONFIG_MBEDTLS_ASYMMETRIC_CONTENT_LEN=y CONFIG_MBEDTLS_ASYMMETRIC_CONTENT_LEN=y
# Allow mbedTLS to allocate from PSRAM or internal memory
#
# (The ESP-IDF default is internal-only, partly for physical security to prevent
# possible information leakage from unencrypted PSRAM contents on the original
# ESP32 - no PSRAM encryption on that chip. MicroPython doesn't support flash
# encryption and is already storing the Python heap in PSRAM so this isn't a
# significant factor in overall physical security.)
CONFIG_MBEDTLS_DEFAULT_MEM_ALLOC=y
# ULP coprocessor support # ULP coprocessor support
CONFIG_ESP32_ULP_COPROC_ENABLED=y CONFIG_ESP32_ULP_COPROC_ENABLED=y
CONFIG_ESP32_ULP_COPROC_RESERVE_MEM=2040 CONFIG_ESP32_ULP_COPROC_RESERVE_MEM=2040
......
...@@ -3,7 +3,11 @@ ...@@ -3,7 +3,11 @@
CONFIG_SPIRAM=y CONFIG_SPIRAM=y
CONFIG_SPIRAM_CACHE_WORKAROUND=y CONFIG_SPIRAM_CACHE_WORKAROUND=y
CONFIG_SPIRAM_IGNORE_NOTFOUND=y CONFIG_SPIRAM_IGNORE_NOTFOUND=y
CONFIG_SPIRAM_USE_CAPS_ALLOC=y CONFIG_SPIRAM_USE_MALLOC=y
# This is the threshold for preferring small allocations from internal memory
# first, before failing over to PSRAM.
CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL=8192
# SPIRAM increases the size of the firmware and overflows iram0_0_seg, due # SPIRAM increases the size of the firmware and overflows iram0_0_seg, due
# to PSRAM bug workarounds. Apply some options to reduce the firmware size. # to PSRAM bug workarounds. Apply some options to reduce the firmware size.
......
...@@ -7,4 +7,8 @@ CONFIG_SPIRAM_SPEED_80M=y ...@@ -7,4 +7,8 @@ CONFIG_SPIRAM_SPEED_80M=y
CONFIG_SPIRAM=y CONFIG_SPIRAM=y
CONFIG_SPIRAM_BOOT_INIT=y CONFIG_SPIRAM_BOOT_INIT=y
CONFIG_SPIRAM_IGNORE_NOTFOUND=y CONFIG_SPIRAM_IGNORE_NOTFOUND=y
CONFIG_SPIRAM_USE_CAPS_ALLOC=y CONFIG_SPIRAM_USE_MALLOC=y
# This is the threshold for preferring small allocations from internal memory
# first, before failing over to PSRAM.
CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL=8192
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment