fix(l2): WiFi fails to start or join - big statics and task stacks to PSRAM

WiFi starts and joins on internal RAM: ~42 KB the first time, ~25 KB after,
more for WPA. Free internal RAM had shrunk to ~20 KB after opening the map
(the tile decoder's 12 KB stack, the 32 KB I-cache, the DMA draw buffers,
UI statics), so a scan failed at once (esp_wifi_init: no memory) and a join
during a tile download timed out (AUTH_EXPIRE).

- ESP-IDF: CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY, and the esp_timer
  task stack 8 -> 4 KB (it uses ~0.4 KB). Rebuild the framework libs:
  pio run -e Wio_Tracker_L2_idf_libs.
- PSRAM_BSS (EXT_RAM_BSS_ATTR) on the UI's big statics: QR codes, map
  state, charts, lists. .dram0.bss 115 -> 66 KB.
- The tile decoder's and fetcher's task stacks in PSRAM.

Free internal RAM, idle: 48 -> 105 KB; WiFi up: 57 KB, 29 KB at the
lowest while downloading tiles.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Jakub
2026-10-14 17:23:29 +02:00
co-authored by Claude Opus 5.5
parent 3825dcc077
commit 2f2db6045c
17 changed files with 49 additions and 29 deletions
@@ -55,7 +55,10 @@ public:
_job_stale = false;
_job_state = JOB_RUNNING;
#if defined(ESP32)
if (!_task && xTaskCreatePinnedToCore(jobTask, "tiles", 12288, this, tskIDLE_PRIORITY + 1, &_task, 0) != pdPASS) {
// The stack in PSRAM: internal RAM is what WiFi starts on (it fails to
// with ~25 KB left), and the task only reads the SD card, never the flash.
if (!_task && xTaskCreatePinnedToCoreWithCaps(jobTask, "tiles", 12288, this, tskIDLE_PRIORITY + 1, &_task, 0,
MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT) != pdPASS) {
_task = nullptr;
runJob(); // no task: here, as before
return true;
@@ -147,7 +147,7 @@ static void layout(double left, double top, int w, int h, int z, bool on, int bo
// Greedy placement: the icon, then the text right / left / above / below it.
struct Box { int16_t x1, y1, x2, y2; };
static Box used[MAX_PLACED * 2 + 8];
static PSRAM_BSS Box used[MAX_PLACED * 2 + 8];
int nu = 0;
// The map's controls: button columns, the zoom pill between them, scale /
// credit and the centre button above the bottom bar, the bar.
@@ -206,6 +206,6 @@ private:
}
};
static VectorPacks s_vpacks;
static PSRAM_BSS VectorPacks s_vpacks;
} // namespace mapview