From 3f6f5459d17d32fadea123354cd79018cc677993 Mon Sep 17 00:00:00 2001 From: Lee Leahy Date: Mon, 29 Apr 2024 14:17:05 -1000 Subject: [PATCH] Add item 34 to debug menu to display the partition table Verify that the spiffs exists during boot and halt boot when it is missing. --- Firmware/RTK_Surveyor/RTK_Surveyor.ino | 7 ++++++ Firmware/RTK_Surveyor/menuSystem.ino | 4 +++ Firmware/RTK_Surveyor/support.ino | 35 ++++++++++++++++++++++++++ 3 files changed, 46 insertions(+) diff --git a/Firmware/RTK_Surveyor/RTK_Surveyor.ino b/Firmware/RTK_Surveyor/RTK_Surveyor.ino index 3e6c7c6b7..b3d9d7a5c 100644 --- a/Firmware/RTK_Surveyor/RTK_Surveyor.ino +++ b/Firmware/RTK_Surveyor/RTK_Surveyor.ino @@ -896,6 +896,13 @@ void setup() DMW_c("beginDisplay"); beginDisplay(); // Start display to be able to display any errors + DMW_c("findSpiffsPartition"); + if (!findSpiffsPartition()) + { + printPartitionTable(); // Print the partition tables + reportFatalError("spiffs partition not found!"); + } + DMW_c("beginFS"); beginFS(); // Start LittleFS file system for settings diff --git a/Firmware/RTK_Surveyor/menuSystem.ino b/Firmware/RTK_Surveyor/menuSystem.ino index 940d48548..3d10cfa98 100644 --- a/Firmware/RTK_Surveyor/menuSystem.ino +++ b/Firmware/RTK_Surveyor/menuSystem.ino @@ -647,6 +647,8 @@ void menuDebugSoftware() systemPrintf("%d (%d days %d:%02d:%02d)\r\n", settings.rebootSeconds, days, hours, minutes, seconds); } + systemPrintf("34) Print partition table\r\n"); + // Tasks systemPrint("50) Task Highwater Reporting: "); if (settings.enableTaskReports == true) @@ -716,6 +718,8 @@ void menuDebugSoftware() } } } + else if (incoming == 34) + printPartitionTable(); else if (incoming == 50) settings.enableTaskReports ^= 1; else if (incoming == 60) diff --git a/Firmware/RTK_Surveyor/support.ino b/Firmware/RTK_Surveyor/support.ino index 1d97010be..20606197c 100644 --- a/Firmware/RTK_Surveyor/support.ino +++ b/Firmware/RTK_Surveyor/support.ino @@ -799,6 +799,41 @@ void printUbloxInvalidData(PARSE_STATE *parse) systemPrintf(" %s Invalid UBX data, %d bytes\r\n", parse->parserName, parse->length - 1); } +void printPartitionTable(void) +{ + systemPrintln("ESP32 Partition table:\n"); + + systemPrintln("| Type | Sub | Offset | Size | Label |"); + systemPrintln("| ---- | --- | -------- | -------- | ---------------- |"); + + esp_partition_iterator_t pi = esp_partition_find(ESP_PARTITION_TYPE_ANY, ESP_PARTITION_SUBTYPE_ANY, NULL); + if (pi != NULL) + { + do + { + const esp_partition_t *p = esp_partition_get(pi); + systemPrintf("| %02x | %02x | 0x%06X | 0x%06X | %-16s |\r\n", p->type, p->subtype, p->address, p->size, + p->label); + } while ((pi = (esp_partition_next(pi)))); + } +} + +// Locate the partition for the little file system +bool findSpiffsPartition(void) +{ + esp_partition_iterator_t pi = esp_partition_find(ESP_PARTITION_TYPE_ANY, ESP_PARTITION_SUBTYPE_ANY, NULL); + if (pi != NULL) + { + do + { + const esp_partition_t *p = esp_partition_get(pi); + if (strcmp(p->label, "spiffs") == 0) + return true; + } while ((pi = (esp_partition_next(pi)))); + } + return false; +} + // Verify table sizes match enum definitions void verifyTables() {