8000 esp32: Allow malloc() to allocate from SPIRAM. · micropython/micropython@8322afc · GitHub
[go: up one dir, main page]

Skip to content

Commit 8322afc

Browse files
committed
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 readout via PSRAM on 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. Signed-off-by: Angus Gratton <angus@redyak.com.au>
1 parent cfcce4b commit 8322afc

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

ports/esp32/boards/sdkconfig.base

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ CONFIG_LWIP_PPP_CHAP_SUPPORT=y
4949
# Use 4kiB output buffer instead of default 16kiB
5050
CONFIG_MBEDTLS_ASYMMETRIC_CONTENT_LEN=y
5151

52+
# Allow mbedTLS to allocate from PSRAM or internal memory
53+
CONFIG_MBEDTLS_DEFAULT_MEM_ALLOC=y
54+
5255
# ULP coprocessor support
5356
# Only on: ESP32, ESP32S2, ESP32S3
5457
CONFIG_ULP_COPROC_ENABLED=y

ports/esp32/boards/sdkconfig.spiram

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
CONFIG_SPIRAM=y
44
CONFIG_SPIRAM_CACHE_WORKAROUND=y
55
CONFIG_SPIRAM_IGNORE_NOTFOUND=y
6-
CONFIG_SPIRAM_USE_CAPS_ALLOC=y
6+
CONFIG_SPIRAM_USE_MALLOC=y
7+
CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL=8192
78

89
# SPIRAM increases the size of the firmware and overflows iram0_0_seg, due
910
# to PSRAM bug workarounds. Apply some options to reduce the firmware size.

ports/esp32/boards/sdkconfig.spiram_sx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ CONFIG_SPIRAM_SPEED_80M=y
77
CONFIG_SPIRAM=y
88
CONFIG_SPIRAM_BOOT_INIT=y
99
CONFIG_SPIRAM_IGNORE_NOTFOUND=y
10-
CONFIG_SPIRAM_USE_CAPS_ALLOC=y
10+
CONFIG_SPIRAM_USE_MALLOC=y
11+
CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL=8192

0 commit comments

Comments
 (0)
0