How to use LittleFS on ESP32 Boards?

try to get LittleFS to work on my esp32. I tried both esp32 wroom and esp32-s3. The code works on none. I get errors saying that:

))E (7) esp_littlefs: ./components/esp_littlefs/src/littlefs/lfs.c:1225:error: Corrupted dir pair at {0x0, 0x1}

E (7) esp_littlefs: mount failed, (-84)

E (35) esp_littlefs: Failed to initialize LittleFS

[ 185][E][LittleFS.cpp:95] begin(): Mounting LittleFS failed! Error: -1

An Error has occurred while mounting LittleFS

How to troubleshoot this?

#include <Arduino.h>
#include <FS.h>
#include <LittleFS.h>

File FFfile;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
   if (!LittleFS.begin()) {
    Serial.println("An Error has occurred while mounting LittleFS");
    return;
  }

  File FFfile = LittleFS.open("/test.txt", "w");

  if (!FFfile) {
    Serial.println("There was an error opening the file for writing");
    return;
  }

  if (FFfile.print("Hello, World!")) {
    Serial.println("File was written");
  } else {
    Serial.println("File write failed");
  }

  FFfile.close();
}

void loop() {
  // put your main code here, to run repeatedly:
}

Thanks this helped a lot!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.