Split heap gate into separate free-memory (50KB) and largest-block (20KB) thresholds based on field measurements. Enable wolfSSL single-precision ECC to use fixed 256-bit arrays instead of heap-allocated fast-math bignums, reducing TLS handshake memory footprint. Reclaim ~7KB by right-sizing ESP timer task stacks and move WiFi code out of IRAM to free ~25-30KB for heap. Add memory audit landmarks for font and EPUB allocations.
34 lines
964 B
Python
34 lines
964 B
Python
from pathlib import Path
|
|
|
|
Import("env")
|
|
|
|
|
|
PROJECT_DIR = Path(env.subst("$PROJECT_DIR"))
|
|
MARKER = "/* CrossPoint wolfSSL compatibility overrides */"
|
|
OVERRIDES = f"""
|
|
|
|
{MARKER}
|
|
#undef NO_DH
|
|
#ifndef HAVE_FFDHE_2048
|
|
#define HAVE_FFDHE_2048
|
|
#endif
|
|
/* MEMFIX-PORT: 8192 handles up to RSA-4096 keys (the public-CA maximum,
|
|
ISRG Root X1 included) with half the per-bignum heap of 16384: with
|
|
WOLFSSL_SMALL_STACK each fast-math temp is FP_MAX_BITS/8 * 2 bytes on the
|
|
heap, and TLS cert verification allocates dozens at once. */
|
|
#undef FP_MAX_BITS
|
|
#define FP_MAX_BITS 8192
|
|
"""
|
|
|
|
|
|
def patch_user_settings(path: Path) -> None:
|
|
text = path.read_text()
|
|
if MARKER in text:
|
|
text = text.split(MARKER, 1)[0].rstrip()
|
|
path.write_text(text + OVERRIDES + "\n")
|
|
print(f"Patched wolfSSL settings: {path.relative_to(PROJECT_DIR)}")
|
|
|
|
|
|
for settings in PROJECT_DIR.glob(".pio/libdeps/*/Arduino-wolfSSL/src/user_settings.h"):
|
|
patch_user_settings(settings)
|