From 2be6d0bdd20a5f15bfd037bd1dfd3c0c2081891e Mon Sep 17 00:00:00 2001 From: Owen Date: Tue, 8 Mar 2022 14:56:25 +0100 Subject: [PATCH] Start SPIFFS before camera module, #214 --- esp32-cam-webserver.ino | 8 +++++++- storage.cpp | 4 ++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/esp32-cam-webserver.ino b/esp32-cam-webserver.ino index 5b46b0f..bc94b59 100644 --- a/esp32-cam-webserver.ino +++ b/esp32-cam-webserver.ino @@ -488,6 +488,7 @@ void setup() { Serial.println(myVer); Serial.print("Base Release: "); Serial.println(baseVersion); + Serial.println(); // Warn if no PSRAM is detected (typically user error with board selection in the IDE) if(!psramFound()){ @@ -511,6 +512,12 @@ void setup() { digitalWrite(LED_PIN, LED_ON); #endif + // Start the SPIFFS filesystem before we initialise the camera + if (filesystem) { + filesystemStart(); + delay(200); // a short delay to let spi bus settle after SPIFFS init + } + // Create camera config structure; and populate with hardware and other defaults camera_config_t config; config.ledc_channel = LEDC_CHANNEL_0; @@ -649,7 +656,6 @@ void setup() { if (filesystem) { delay(200); // a short delay to let spi bus settle after camera init - filesystemStart(); loadPrefs(SPIFFS); } else { Serial.println("No Internal Filesystem, cannot load or save preferences"); diff --git a/storage.cpp b/storage.cpp index 8a2644a..e740878 100644 --- a/storage.cpp +++ b/storage.cpp @@ -185,10 +185,11 @@ void removePrefs(fs::FS &fs) { } void filesystemStart(){ + Serial.println("Starting internal SPIFFS filesystem"); while ( !SPIFFS.begin(FORMAT_SPIFFS_IF_FAILED) ) { // if we sit in this loop something is wrong; // if no existing spiffs partition exists one should be automagically created. - Serial.println("SPIFFS Mount failed, this can happen on first-run initialisation."); + Serial.println("SPIFFS Mount failed, this can happen on first-run initialisation"); Serial.println("If it happens repeatedly check if a SPIFFS partition is present for your board?"); for (int i=0; i<10; i++) { flashLED(100); // Show SPIFFS failure @@ -197,6 +198,5 @@ void filesystemStart(){ delay(1000); Serial.println("Retrying.."); } - Serial.println("Internal filesystem contents"); listDir(SPIFFS, "/", 0); }