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
+5 -5
View File
@@ -26,12 +26,12 @@
namespace mapview {
static RasterTileProvider s_raster("/sdcard/maps", LIVE_ROOT);
static VectorTileProvider s_vector(s_raster); // spike: vector data where there is some, raster elsewhere
static PSRAM_BSS RasterTileProvider s_raster("/sdcard/maps", LIVE_ROOT);
static PSRAM_BSS VectorTileProvider s_vector(s_raster); // spike: vector data where there is some, raster elsewhere
static TileProvider* s_provider = &s_raster; // Map tools > Vector map (test) swaps it
static TileCache& s_cache = *new (psramBuf<TileCache>(1)) TileCache(); // decoded tiles, in PSRAM
static TileDownloader s_dl("/sdcard/maps");
static AreaStore s_areas("/sdcard/maps");
static PSRAM_BSS TileDownloader s_dl("/sdcard/maps");
static PSRAM_BSS AreaStore s_areas("/sdcard/maps");
static const uint32_t AVG_TILE_BYTES = 22 * 1024; // OpenTopoMap-ish, for the size estimate
// Hand a tile to the decoder (on the other core); false while one is in flight.
@@ -1036,7 +1036,7 @@ void UITask::layoutMapMarks(double left, double top, int w, int h) {
const int half = MARK_D / 2;
const int lh = lv_font_get_line_height(THEME_FONT_SMALL) + 2;
struct Box { int16_t x1, y1, x2, y2; };
static Box used[6 + MAX_MARKS + MARK_LABELS_MAX]; // the map's controls, the dots, the names
static PSRAM_BSS Box used[6 + MAX_MARKS + MARK_LABELS_MAX]; // the map's controls, the dots, the names
int nu = 0;
const int bottom = mapBottomH(); // the target's bar, or the route's
const int16_t W = (int16_t)w, H = (int16_t)(h - bottom);