docs: findings on moving the mbedTLS record buffers to PSRAM - #141
Closed
davelee98 wants to merge 1 commit into
Closed
docs: findings on moving the mbedTLS record buffers to PSRAM#141davelee98 wants to merge 1 commit into
davelee98 wants to merge 1 commit into
Conversation
od_tls_reserve_records() holds 2 x 17,408 B = 34,816 B of internal DRAM from boot -- the largest single app-owned internal block, on the part where internal DRAM is the scarce resource. Verdict: safe with caveats. The potential hard blocker -- hardware crypto DMA being unable to reach external PSRAM -- does not apply to S3. Verified against the pinned S3 SDK: HARDWARE_AES/SHA/MPI=y, AES_USE_INTERRUPT=y, SOC_PSRAM_DMA_CAPABLE=1, SOC_AES_GDMA=1, SOC_SHA_SUPPORT_DMA=1. The generic "don't do this on classic ESP32/C3/C6" caveat is moot here: TLS compiles only on the five OPENDISPLAY_ENABLE_WIFI envs, all of which are S3. Caveats recorded: AES still needs a small internal bounce buffer for unaligned interior record pointers (its size is flagged unverified -- Arduino ships prebuilt libs); s_tlsSlotBusy[] is non-atomic under a global allocator hook that catches every mbedTLS caller, which is pre-existing and should be fixed first; and record buffers hold plaintext, which PSRAM puts on the external bus. Also notes a discrepancy found in passing: two comments assert CONFIG_SPIRAM_IGNORE_NOTFOUND=1, which is not present in the pinned S3 sdkconfig. Claude-Session: https://claude.ai/code/session_01Dr3hFvUyZUaLvadPLQcvyz
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Working notes on whether
od_tls_reserve_records()'s two 17,408 B record slots (34,816 B of internal DRAM, held from boot) can move toMALLOC_CAP_SPIRAM. Documentation only — no code change.Verdict: safe with caveats, on S3. The concern that would have been a hard blocker — hardware crypto DMA being unable to reach external PSRAM — does not apply to ESP32-S3.
Verified against the pinned S3 SDK (Arduino 3.3.9 / IDF 5.5.4):
CONFIG_MBEDTLS_HARDWARE_AES/_SHA/_MPI=yCONFIG_MBEDTLS_AES_USE_INTERRUPT=ySOC_PSRAM_DMA_CAPABLE1SOC_AES_GDMA,SOC_SHA_SUPPORT_DMA(1)The generic "don't do this on classic ESP32/C3/C6" caveat is moot here: TLS compiles only under
OPENDISPLAY_HAS_WIFI, set on exactly five envs, all S3.Caveats recorded:
s_tlsSlotBusy[]is non-atomic under a global allocator hook that catches every mbedTLS caller, not just the LAN TLS server. Pre-existing and independent of PSRAM; the doc recommends fixing it first so a concurrency bug and a placement bug can't be confused.Also notes a discrepancy found in passing:
src/wifi_service.h:61andsrc/wifi_service.cpp:275both assertCONFIG_SPIRAM_IGNORE_NOTFOUND=1, which is not present in the pinned S3 sdkconfig. Either set somewhere I didn't find, or both comments are stale.All
file:linecitations were re-verified againstmainHEAD976f0c2(the investigation was originally done on a feature branch where the line numbers differ).https://claude.ai/code/session_01Dr3hFvUyZUaLvadPLQcvyz