Fix UI freeze/reboots: LVGL pool to PSRAM, dangling SSID buttons, scan policy
Firmware / build (push) Successful in 4m24s

- lv_conf: LVGL widget pool 48 KB internal -> 512 KB PSRAM (LV_MEM_POOL_ALLOC).
  It ran out after a few Settings visits (87% used, 31% frag, 4.5 KB biggest
  block; lv_mem_buf_get() failed in a label draw - decoded backtrace). Also
  frees 48 KB of internal RAM: free 16 -> 69 KB, largest block 7.6 -> 31.7 KB
- lv_conf: LV_ASSERT_HANDLER abort() instead of while(1), which spun inside the
  task holding the LVGL lock and froze the UI + console
- wifi_manager: SSID buttons clear their g_ssid_buttons[] slot on
  LV_EVENT_DELETE (SquareLine deletes the Settings screen on leave; stale
  pointers were lv_obj_del()'d on the next scan). Scan only while the list is
  on screen and not connected - 10 s background scans caused the display dots
- main: `mem` console command (internal heap, PSRAM, LVGL pool)
- docs: board page lessons, open-questions #13/#14, ota-updates, CLAUDE.md, log

Verified: 10 Settings visits + 9 list rebuilds, pool peak 4%, 0 crashes; user
confirms no freeze, no reboot, no dots, swipes better.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-09-27 00:32:18 +02:00
parent 842f270398
commit 766019a01e
8 changed files with 79 additions and 15 deletions
+14 -5
View File
@@ -49,14 +49,19 @@
#define LV_MEM_CUSTOM 0
#if LV_MEM_CUSTOM == 0
/*Size of the memory available for `lv_mem_alloc()` in bytes (>= 2kB)*/
#define LV_MEM_SIZE (48U * 1024U) /*[bytes]*/
/* 512 KB pool in PSRAM (2026-09-27). The old 48 KB pool lived in internal
* RAM and ran out: Settings + its Wi-Fi list is ~15 KB, and screen churn +
* fragmentation reached 87% used / 4.5 KB biggest block, then a label draw
* failed lv_mem_buf_get() -> assert. Moving it out also frees 48 KB of the
* scarce internal RAM. `mem` on the console prints the pool state. */
#define LV_MEM_SIZE (512U * 1024U) /*[bytes]*/
/*Set an address for the memory pool instead of allocating it as a normal array. Can be in external SRAM too.*/
#define LV_MEM_ADR 0 /*0: unused*/
/*Instead of an address give a memory allocator that will be called to get a memory pool for LVGL. E.g. my_malloc*/
#if LV_MEM_ADR == 0
#undef LV_MEM_POOL_INCLUDE
#undef LV_MEM_POOL_ALLOC
#define LV_MEM_POOL_INCLUDE <esp_heap_caps.h>
#define LV_MEM_POOL_ALLOC(size) heap_caps_malloc((size), MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT)
#endif
#else /*LV_MEM_CUSTOM*/
@@ -271,8 +276,12 @@
#define LV_USE_ASSERT_OBJ 0 /*Check the object's type and existence (e.g. not deleted). (Slow)*/
/*Add a custom handler when assert happens e.g. to restart the MCU*/
#define LV_ASSERT_HANDLER_INCLUDE <stdint.h>
#define LV_ASSERT_HANDLER while(1); /*Halt by default*/
#define LV_ASSERT_HANDLER_INCLUDE <stdlib.h>
/* Was `while(1);`: a failed assert spun forever inside the calling task while it
* held the LVGL lock - the UI froze, loop() blocked on the lock, and only the
* link task kept running (2026-09-27). abort() panics instead: backtrace on the
* console, core dump to flash (ELF), reboot. A reboot beats a frozen screen. */
#define LV_ASSERT_HANDLER abort();
/*-------------
* Others