From dcc80e14d787752f09fcef396818a8902545a05b Mon Sep 17 00:00:00 2001 From: "torlando-agent[bot]" <281092095+torlando-agent[bot]@users.noreply.github.com> Date: Sat, 25 Jul 2026 02:01:05 +0000 Subject: [PATCH] fix: report active firmware and LittleFS storage --- lib/tdeck_ui/UI/LXMF/SettingsScreen.cpp | 17 +++++++++++------ src/main.cpp | 19 +++++++++++++------ .../test_message_persistence_contract.py | 8 ++++++++ 3 files changed, 32 insertions(+), 12 deletions(-) diff --git a/lib/tdeck_ui/UI/LXMF/SettingsScreen.cpp b/lib/tdeck_ui/UI/LXMF/SettingsScreen.cpp index 19819f68..3d80c4ec 100644 --- a/lib/tdeck_ui/UI/LXMF/SettingsScreen.cpp +++ b/lib/tdeck_ui/UI/LXMF/SettingsScreen.cpp @@ -8,7 +8,7 @@ #include #include "../LVGL/LVGLLock.h" -#include +#include #include #include #include @@ -753,7 +753,7 @@ void SettingsScreen::create_system_section(lv_obj_t* parent) { _label_identity_hash = create_label_row(parent, "Identity: --"); _label_lxmf_address = create_label_row(parent, "LXMF: --"); - _label_firmware = create_label_row(parent, "Firmware: v1.0.0"); + _label_firmware = create_label_row(parent, "Firmware: " FIRMWARE_VERSION); _label_storage = create_label_row(parent, "Storage: --"); _label_ram = create_label_row(parent, "RAM: --"); } @@ -1292,10 +1292,15 @@ void SettingsScreen::update_system_info() { } // Storage - size_t total = SPIFFS.totalBytes(); - size_t used = SPIFFS.usedBytes(); - size_t free = total - used; - String storage = "Storage: " + String(free / 1024) + " KB free"; + size_t total = LittleFS.totalBytes(); + size_t used = LittleFS.usedBytes(); + String storage; + if (total == 0 || used > total) { + storage = "Storage: unavailable"; + } else { + size_t free = total - used; + storage = "Storage: " + String(free / 1024) + " KB free"; + } lv_label_set_text(_label_storage, storage.c_str()); // RAM diff --git a/src/main.cpp b/src/main.cpp index 4bc2227e..97029452 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1300,7 +1300,14 @@ void setup_ui_manager() { // Configure settings screen UI::LXMF::SettingsScreen* settings = ui_manager->get_settings_screen(); if (settings) { - settings->set_firmware_version(FIRMWARE_VERSION); + String firmware_info = FIRMWARE_VERSION; + const esp_partition_t* running_partition = esp_ota_get_running_partition(); + if (running_partition) { + firmware_info += " ["; + firmware_info += running_partition->label; + firmware_info += "]"; + } + settings->set_firmware_version(firmware_info); // Pass GPS for status display settings->set_gps(&gps); @@ -1754,6 +1761,11 @@ void setup() { setup_ui_manager(); BOOT_PROFILE_END("ui_manager"); + // Confirm app0 as soon as the persistent store, LXMF router, and UI have + // all initialized successfully. Do not defer this behind announces or + // callback setup: a reset after this point must not roll back to app1. + confirm_running_firmware(); + // Now that UIManager has built screens and configured the active // one, start the LVGL render task. Doing this any earlier means // the LVGL task refreshes its empty default screen on top of the @@ -1815,11 +1827,6 @@ void setup() { Serial.flush(); }); - // Columba writes app0 plus fresh OTA-selection data. This framework has - // bootloader rollback enabled, so confirm the app only after filesystem, - // LXMF, and UI initialization have all completed successfully. - confirm_running_firmware(); - // Boot profiling complete BOOT_PROFILE_COMPLETE(); #ifdef BOOT_PROFILING_ENABLED diff --git a/tests/build_scripts/test_message_persistence_contract.py b/tests/build_scripts/test_message_persistence_contract.py index eafcae6a..093749ba 100644 --- a/tests/build_scripts/test_message_persistence_contract.py +++ b/tests/build_scripts/test_message_persistence_contract.py @@ -99,3 +99,11 @@ def test_successful_boot_cancels_ota_rollback_after_subsystems_initialize(): setup = function_body(source, "void setup()", "void loop()") assert setup.index("setup_lxmf();") < setup.index("setup_ui_manager();") assert setup.index("setup_ui_manager();") < setup.index("confirm_running_firmware();") + + +def test_system_info_reports_littlefs_not_unmounted_spiffs(): + source = (REPO_ROOT / "lib/tdeck_ui/UI/LXMF/SettingsScreen.cpp").read_text() + assert '"Firmware: " FIRMWARE_VERSION' in source + assert "LittleFS.totalBytes()" in source + assert "LittleFS.usedBytes()" in source + assert "SPIFFS.totalBytes()" not in source