esp-idf's default is internal-RAM-only, and a TLS connection needs ~33 KB of it (two ~17 KB I/O buffers + contexts) at the exact moment :sync pushes — with Wi-Fi, USB host, the editor and libgit2 resident, mbedtls_ssl_setup failed there on the first real-repo push (and its failure path then hit the stream double-free fixed in the previous commit). TLS buffers are CPU-only data, so PSRAM is safe; the handshake is network-bound.
86 lines
5.0 KiB
Plaintext
86 lines
5.0 KiB
Plaintext
# Rust often needs a bit of an extra main task stack size compared to C (the default is 3K)
|
||
# You might have to increase this further if you allocate large stack variables in the main task.
|
||
# Bumped for the TLS handshake (Spike 6): mbedtls runs on the calling task and
|
||
# wants several KB of stack on top of the app's own usage. 12 KB ran the editor
|
||
# AND a full TLS-on-main handshake on hardware — the last-known-good value for
|
||
# this shared stack.
|
||
#
|
||
# Spike 7 briefly bumped this to 96 KB because libgit2's push chain is far deeper
|
||
# (~67 KB measured for a trivial config write: nearly every function puts a 4 KB
|
||
# `char path[GIT_PATH_MAX]` on the stack and init→config→FATFS→wear-leveling
|
||
# nests ~10 deep). But this sdkconfig is SHARED with the editor build, so that
|
||
# forced the editor to over-reserve ~80 KB for nothing. Git now runs on its own
|
||
# large-stack thread instead (git_push.rs — GIT_STACK via
|
||
# std::thread::Builder::stack_size), so this drops back to the Spike-6 value.
|
||
# (The "time() only works on the main task" theory was a misdiagnosis: that
|
||
# iteration ran git on a std::thread with the DEFAULT 4 KB stack and just
|
||
# overflowed sooner — it was always stack depth, never thread-vs-main.)
|
||
CONFIG_ESP_MAIN_TASK_STACK_SIZE=12288
|
||
|
||
# Increase a bit these stack sizes as they are also a bit too small by default
|
||
CONFIG_ESP_SYSTEM_EVENT_TASK_STACK_SIZE=4096
|
||
CONFIG_FREERTOS_IDLE_TASK_STACKSIZE=4096
|
||
|
||
# You might have to increase this further if you spawn your own Rust threads
|
||
# that allocate large stack variables; or better yet - use
|
||
# `std::thread::Builder::new().stack_size(XXX)` for spawning
|
||
CONFIG_PTHREAD_TASK_STACK_SIZE_DEFAULT=4096
|
||
|
||
# FatFS long filenames (Spike 3 — SD). Default is 8.3-only, which rejects the
|
||
# persistence module's atomic-save temp name (`notes.md.tmp` has two dots).
|
||
# LFN on the heap keeps the working buffer off the (small) task stack.
|
||
CONFIG_FATFS_LFN_HEAP=y
|
||
|
||
# PSRAM (Spike 7 — the git working set needs it; the docs memory plan budgets
|
||
# ~1.5 MB PSRAM for pack/delta work, and the rope buffer lives there too). This
|
||
# board is an ESP32-S3-WROOM-1-N16R8 → 8 MB *octal* PSRAM, so OCT mode is
|
||
# required (quad would fail to init). USE_MALLOC adds PSRAM to the heap
|
||
# allocator, so large allocations (Box, Rope, libgit2 buffers) land there
|
||
# instead of the ~339 KB internal DRAM Spike 6 measured. Octal PSRAM occupies
|
||
# GPIO 33–37; the EPD/SD pins (4–13) deliberately avoid that range, so no wiring
|
||
# conflict. Speed left at the 40 MHz default (safe first-enable; 80 MHz needs
|
||
# matching flash-freq config and is a later tuning step).
|
||
CONFIG_SPIRAM=y
|
||
CONFIG_SPIRAM_MODE_OCT=y
|
||
CONFIG_SPIRAM_USE_MALLOC=y
|
||
|
||
# FatFS fast seek (sync-latency root cause, 2026-07-12). Without it, lseek
|
||
# resolves by walking the file's FAT cluster chain over SPI — forward from the
|
||
# current position, from the CHAIN HEAD on any backward seek. sd_bench measured
|
||
# ~190 ms per long seek into the 263 MB packfile (5.8 ms at offset 0), and
|
||
# libgit2 pays ~8 such seeks per loose-object write via p_mmap's lseek+read →
|
||
# the ~1.5 s/object commit cost (docs/tradeoff-curves/sync-commit-staging.md).
|
||
# Fast seek builds an in-memory cluster-link map (CLMT) per READ-mode file,
|
||
# making lseek O(1); write-mode files transparently fall back to the walk. The
|
||
# buffer is per-open-file, 4 B × size: 256 words = 1 KB, covering ~127 fragments
|
||
# (the default 64 covers ~31 — a freshly-provisioned pack is near-contiguous,
|
||
# but don't let card aging silently disable the fix; vfs_fat falls back to slow
|
||
# seeks when the map doesn't fit).
|
||
CONFIG_FATFS_USE_FASTSEEK=y
|
||
CONFIG_FATFS_FAST_SEEK_BUFFER_SIZE=256
|
||
|
||
# Silence the legacy-I2C boot warning. esp-idf-hal's i2c.rs is always compiled
|
||
# and binds the old `driver/i2c.h` API, so the legacy driver's TU (and its
|
||
# `__attribute__((constructor))` deprecation warning) gets linked into every
|
||
# image — even though Typoena uses no I2C at all (EPD/SD are SPI, keyboard is
|
||
# USB). This flag wraps that constructor out. Safe here: we link neither the
|
||
# new i2c_master driver nor call the old one, so the conflict-abort check it
|
||
# also removes can never fire.
|
||
CONFIG_I2C_SKIP_LEGACY_CONFLICT_CHECK=y
|
||
|
||
# TLS trust store (Spike 6 — Wi-Fi + TLS, the gate for Spike 7 git push).
|
||
# The certificate bundle backs esp_crt_bundle_attach so an HTTPS GET to
|
||
# api.github.com validates against real roots. FULL rather than the common
|
||
# subset so a less common CA in the chain can't surprise us on the bench.
|
||
CONFIG_MBEDTLS_CERTIFICATE_BUNDLE=y
|
||
CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_FULL=y
|
||
|
||
# mbedTLS allocations go to PSRAM. The default (internal-only) needs ~33 KB of
|
||
# contiguous internal RAM per TLS connection (two ~17 KB I/O buffers + contexts)
|
||
# at the moment `:sync` pushes — with Wi-Fi, USB host, the editor and libgit2
|
||
# all resident, mbedtls_ssl_setup failed exactly there on the first real-repo
|
||
# push (2026-07-13; the failure then tripped the vendored stream double-free —
|
||
# see components/libgit2/esp_mbedtls_stream.c). TLS buffers are CPU-only data,
|
||
# so PSRAM is safe; the handshake is network-bound, not memory-bandwidth-bound.
|
||
CONFIG_MBEDTLS_EXTERNAL_MEM_ALLOC=y
|