Skip to content

Reduce ESP32 TLS memory use with dynamic mbedTLS buffers - #3211

Merged
floitsch merged 1 commit into
masterfrom
floitsch/esp-idf-dynamic-tls-buffers
Sep 9, 2026
Merged

floitsch merged 1 commit into
masterfrom
floitsch/esp-idf-dynamic-tls-buffers

Conversation

@floitsch

@floitsch floitsch commented Sep 8, 2026 •

Copy link
Copy Markdown
Member

Reduce TLS heap use on ESP32 by enabling dynamic mbedTLS buffers and disabling retention of the peer certificate after verification. Apply both settings to all six supported targets (ESP32, C3, C6, P4, S2, and S3); certificate verification remains enabled.

The required partial-header fix for nonblocking dynamic TLS receives (toitware/esp-idf#132) is available on master through #3216.

Generate sdkconfig.defaults with idf.py save-defconfig, then recreate sdkconfig from those defaults for each target. Keep the existing 7800/3700-byte record limits and leave dynamic freeing of configuration/CA data disabled. TLS 1.3 remains disabled; these settings would need revisiting when enabling it.

Validation after rebasing:

  • Configuration round trips pass for all six targets: saving defaults reproduces each committed sdkconfig.defaults, and regenerating solely from those defaults reproduces each committed sdkconfig byte-for-byte.
  • ESP32 and ESP32-P4 firmware builds pass with master's ESP-IDF pin and P4 crypto support.

The ESP-IDF fix was previously validated with a host regression suite, allocation-failure injection, AddressSanitizer checks, and 54 verified TLS 1.2 transfers covering AES-CBC, AES-GCM, and ChaCha20-Poly1305, fragmented reads, and peer-certificate retention on/off. Physical-board execution of the TLS regression remains outstanding.

@floitsch
floitsch force-pushed the floitsch/esp-idf-dynamic-tls-buffers branch from 62be510 to 17b8d75 Compare September 9, 2026 14:24
@floitsch
floitsch enabled auto-merge (squash) September 9, 2026 14:26
@floitsch
floitsch merged commit e77f234 into master Sep 9, 2026
36 of 37 checks passed
@floitsch
floitsch deleted the floitsch/esp-idf-dynamic-tls-buffers branch September 9, 2026 14:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant