touch: beta_35 — worker-thread history flush, radio memory guards, 30.5 KB DRAM freed, crash-safe prefs

- History flush runs on the core-0 worker (snapshot + storage-busy gate +
  bounded shutdown wait): kills the V4's multi-second ui:hist stalls and
  the refuses-to-wake-after-message symptom (SPIFFS GC off the UI thread).
- BLE + Wi-Fi runtime enables share the boot co-init heap guard (50 KB
  free + 20 KB block): refuse with a toast + revert the switch instead of
  panicking (BLE) or silently not starting while claiming on (Wi-Fi).
- Internal DRAM: static footprint 95,365 -> 64,908 B (30.5 KB freed):
  serial_interface -> PSRAM; 23 keyboard layout maps const'd -> flash;
  nine rings/tables -> psAlloc PSRAM (UITask/TouchPrefsStore/MyMesh);
  unused TinyUSB MSC + DFU-mode class drivers stubbed out of the link
  (usb_unused_class_stubs.c) — CDC + runtime-DFU untouched, double-flash
  verified over the stubbed stack.
- DataStore prefs writes are crash-safe (write .tmp, swap) with a
  self-healing loader (.tmp recovery) and a truthful save result up to
  the profile-name toast — fixes the boots-with-default-name-once report.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Kaj SchittecatandClaude Fable 5 committed 2026-07-06 13:34:24 +02:00
1 parent 4e1ac2ca6b
commit 01900296f3
12 files changed
+394 -99

No files matched your search

+15 -1
View File
@@ -67,7 +67,21 @@ static uint32_t _atoi(const char* sp) {
#ifdef MULTI_TRANSPORT_COMPANION
#include <helpers/esp32/MultiTransportCompanionInterface.h>
#include "helpers/esp32/MqttBridge.h"
MultiTransportCompanionInterface serial_interface;
#include <esp_heap_caps.h>
#include <new>
// ~9.2 KB of TCP/WS/USB framing buffers. Internal DRAM is the scarce pool on
// the touch boards (Wi-Fi + BLE coexistence needs ~50 KB free), and none of
// these buffers are touched from ISR context, so build the whole object in
// PSRAM (heap is up before C++ static init on ESP32; falls back to internal
// RAM if PSRAM is absent). In-TU init order runs this before
// ui_task(&serial_interface) further down.
static void* s_si_mem = [] {
void* p = heap_caps_malloc(sizeof(MultiTransportCompanionInterface),
MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT);
return p ? p : malloc(sizeof(MultiTransportCompanionInterface));
}();
MultiTransportCompanionInterface& serial_interface =
*new (s_si_mem) MultiTransportCompanionInterface();
#ifndef TCP_PORT
#define TCP_PORT 5000
#endif