Skip to content

Commit

Permalink
Start SPIFFS before camera module, #214
Browse files Browse the repository at this point in the history
  • Loading branch information
easytarget committed Mar 8, 2022
1 parent 9402cdf commit 2be6d0b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
8 changes: 7 additions & 1 deletion esp32-cam-webserver.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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()){
Expand All @@ -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;
Expand Down Expand Up @@ -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");
Expand Down
4 changes: 2 additions & 2 deletions storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -197,6 +198,5 @@ void filesystemStart(){
delay(1000);
Serial.println("Retrying..");
}
Serial.println("Internal filesystem contents");
listDir(SPIFFS, "/", 0);
}

0 comments on commit 2be6d0b

Please sign in to comment.