diff --git a/components/micropython/vendor/ports/esp32/boards/sdkconfig.base b/components/micropython/vendor/ports/esp32/boards/sdkconfig.base
index a9e4454427a7d5b32d7ae50b2b8835d2fab84cae..e5e57e6f84aecc3b2a91c58a1d151b7af7bdd7fe 100644
--- a/components/micropython/vendor/ports/esp32/boards/sdkconfig.base
+++ b/components/micropython/vendor/ports/esp32/boards/sdkconfig.base
@@ -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)
 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
 CONFIG_ESP32_ULP_COPROC_ENABLED=y
 CONFIG_ESP32_ULP_COPROC_RESERVE_MEM=2040
diff --git a/components/micropython/vendor/ports/esp32/boards/sdkconfig.spiram b/components/micropython/vendor/ports/esp32/boards/sdkconfig.spiram
index 74d35f7b4ad4a6f1447c778dbc2fc6f727ff18d4..4dfc63624bab52b7efcc3d6864878a3af5fde459 100644
--- a/components/micropython/vendor/ports/esp32/boards/sdkconfig.spiram
+++ b/components/micropython/vendor/ports/esp32/boards/sdkconfig.spiram
@@ -3,7 +3,11 @@
 CONFIG_SPIRAM=y
 CONFIG_SPIRAM_CACHE_WORKAROUND=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
 # to PSRAM bug workarounds.  Apply some options to reduce the firmware size.
diff --git a/components/micropython/vendor/ports/esp32/boards/sdkconfig.spiram_sx b/components/micropython/vendor/ports/esp32/boards/sdkconfig.spiram_sx
index fe388467800e24e84a4e135ca1a63ff49b375bb7..05212b75680fb494c2ba7d9c0dcc46cfda1723af 100644
--- a/components/micropython/vendor/ports/esp32/boards/sdkconfig.spiram_sx
+++ b/components/micropython/vendor/ports/esp32/boards/sdkconfig.spiram_sx
@@ -7,4 +7,8 @@ CONFIG_SPIRAM_SPEED_80M=y
 CONFIG_SPIRAM=y
 CONFIG_SPIRAM_BOOT_INIT=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