From 271ffd4f7447715cc4fb85a7dca0159bcf1df91e Mon Sep 17 00:00:00 2001 From: tyeth Date: Tue, 19 Dec 2023 13:32:21 +0000 Subject: [PATCH] Add aggressive reinit of filesystem --- src/provisioning/tinyusb/Wippersnapper_FS.cpp | 6 +++--- src/provisioning/tinyusb/Wippersnapper_FS.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/provisioning/tinyusb/Wippersnapper_FS.cpp b/src/provisioning/tinyusb/Wippersnapper_FS.cpp index 1adf8de22..22b845d3e 100644 --- a/src/provisioning/tinyusb/Wippersnapper_FS.cpp +++ b/src/provisioning/tinyusb/Wippersnapper_FS.cpp @@ -95,7 +95,7 @@ Wippersnapper_FS::Wippersnapper_FS() { // If a filesystem does not already exist - attempt to initialize a new // filesystem - if (!initFilesystem()) { + if (!initFilesystem() || !initFilesystem(true)) { WS_DEBUG_PRINTLN("ERROR Initializing Filesystem"); setStatusLEDColor(RED); while (1) @@ -123,13 +123,13 @@ Wippersnapper_FS::~Wippersnapper_FS() {} @return True if filesystem initialized correctly, false otherwise. */ /**************************************************************************/ -bool Wippersnapper_FS::initFilesystem() { +bool Wippersnapper_FS::initFilesystem(bool force_format) { // Init. flash library if (!flash.begin()) return false; // Check if FS exists - if (!wipperFatFs.begin(&flash)) { + if (force_format || !wipperFatFs.begin(&flash)) { // No filesystem exists - create a new FS // NOTE: THIS WILL ERASE ALL DATA ON THE FLASH if (!makeFilesystem()) diff --git a/src/provisioning/tinyusb/Wippersnapper_FS.h b/src/provisioning/tinyusb/Wippersnapper_FS.h index f89d6e2ee..6d8d65b80 100644 --- a/src/provisioning/tinyusb/Wippersnapper_FS.h +++ b/src/provisioning/tinyusb/Wippersnapper_FS.h @@ -44,7 +44,7 @@ class Wippersnapper_FS { Wippersnapper_FS(); ~Wippersnapper_FS(); - bool initFilesystem(); + bool initFilesystem(bool force_format = false); void initUSBMSC(); void eraseCPFS();