LittleFS Error with XIAO ESP32S3 ?

Hello,

I have created a program that works with an Arduino Nano ESP32 and an ESP8266. Now I have a new XIAO ESP32S3 and LittfeFS does not work. I use Serial and D2, D3, D4 and D6 for leds.

E (6867) esp_littlefs: ./managed_components/joltwallet__littlefs/src/littlefs/lfs.c:1384:error: Corrupted dir pair at {0x0, 0x1}

E (6867) esp_littlefs: mount failed,  (-84)
E (6871) esp_littlefs: Failed to initialize LittleFS
[  7036][E][LittleFS.cpp:79] begin(): Mounting LittleFS failed! Error: -1
File read: /configuration.txt[  7042][E][vfs_api.cpp:106] exists(): File system is not mounted
 not successful, file does not exist.
Complete verbose output here
  Compile Date/Time : Jan 30 2025 18:04:22
  Compile Host OS   : windows
  ESP-IDF Version   : v5.3.2-282-gcfea4f7c98-dirty
  Arduino Version   : 3.1.1
------------------------------------------
Board Info:
------------------------------------------
  Arduino Board     : XIAO_ESP32S3
  Arduino Variant   : XIAO_ESP32S3
  Arduino FQBN      : esp32:esp32:XIAO_ESP32S3:UploadSpeed=921600,USBMode=hwcdc,CDCOnBoot=default,MSCOnBoot=default,DFUOnBoot=default,UploadMode=default,CPUFreq=240,FlashMode=qio,FlashSize=8M,PartitionScheme=default_8MB,DebugLevel=verbose,PSRAM=disabled,LoopCore=1,EventsCore=1,EraseFlash=all,JTAGAdapter=default
============ Before Setup End ============
[  2017][I][esp32-hal-periman.c:141] perimanSetPinBus(): Pin 19 already has type USB_DM (45) with bus 0x3fc96c10
[  2017][I][esp32-hal-periman.c:141] perimanSetPinBus(): Pin 20 already has type USB_DP (46) with bus 0x3fc96c10

ESP32 RESET

object Anzahl 2
singleObjectZeitAnzahl 10
singleObjectLength 168
Anzahl Dimstufen 150
E (6867) esp_littlefs: ./managed_components/joltwallet__littlefs/src/littlefs/lfs.c:1384:error: Corrupted dir pair at {0x0, 0x1}

E (6867) esp_littlefs: mount failed,  (-84)
E (6871) esp_littlefs: Failed to initialize LittleFS
[  7036][E][LittleFS.cpp:79] begin(): Mounting LittleFS failed! Error: -1
File read: /configuration.txt[  7042][E][vfs_api.cpp:106] exists(): File system is not mounted
 not successful, file does not exist.
[  7048][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type LEDC (9) successfully set to 0x42006588
[  7059][V][esp32-hal-periman.c:160] perimanSetPinBus(): Pin 3 successfully set to type LEDC (9) with bus 0x3fc9d374
[  7069][I][esp32-hal-ledc.c:166] ledcAttachChannel(): LEDC attached to pin 3 (channel 0, resolution 10)
[  7078][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type LEDC (9) successfully set to 0x42006588
[  7089][V][esp32-hal-periman.c:160] perimanSetPinBus(): Pin 4 successfully set to type LEDC (9) with bus 0x3fc9d390
[  7099][I][esp32-hal-ledc.c:166] ledcAttachChannel(): LEDC attached to pin 4 (channel 1, resolution 10)
[  7109][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type LEDC (9) successfully set to 0x42006588
[  7120][V][esp32-hal-periman.c:160] perimanSetPinBus(): Pin 5 successfully set to type LEDC (9) with bus 0x3fc9d3ac
[  7130][I][esp32-hal-ledc.c:166] ledcAttachChannel(): LEDC attached to pin 5 (channel 2, resolution 10)
[  7139][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type LEDC (9) successfully set to 0x42006588
[  7150][V][esp32-hal-periman.c:160] perimanSetPinBus(): Pin 43 successfully set to type INIT (0) with bus 0x0
[  7160][V][esp32-hal-periman.c:160] perimanSetPinBus(): Pin 43 successfully set to type INIT (0) with bus 0x0
[  7169][V][esp32-hal-periman.c:160] perimanSetPinBus(): Pin 43 successfully set to type LEDC (9) with bus 0x3fc9d3c8
[  7180][I][esp32-hal-ledc.c:166] ledcAttachChannel(): LEDC attached to pin 43 (channel 3, resolution 10)
=========== After Setup Start ============
INTERNAL Memory Info:
------------------------------------------
  Total Size        :   394660 B ( 385.4 KB)
  Free Bytes        :   356836 B ( 348.5 KB)
  Allocated Bytes   :    32600 B (  31.8 KB)
  Minimum Free Bytes:   353724 B ( 345.4 KB)
  Largest Free Block:   286708 B ( 280.0 KB)
------------------------------------------
GPIO Info:
------------------------------------------
  GPIO : BUS_TYPE[bus/unit][chan]
  --------------------------------------  
     3 : LEDC[0][0]
     4 : LEDC[0][1]
     5 : LEDC[0][2]
    19 : USB_DM
    20 : USB_DP
    43 : LEDC[0][3]
    44 : UART_RX[0]
============ After Setup End =============

IDE is Arduino IDE 2.3.4 with Espressif ESP32 Core Package 3.1.1
Board Setting are all default.
What can I do?

My reduced sketch with the same problem.
Is wants to write but can't.

#include <Streaming.h>
#include <LittleFS.h>

// ------ User Konfiguration ----------------------------------------------------------------------------------------------
Stream &cout {Serial}; 

// ------------------------------------------------------------------------------------------------------------------------

struct ConfigDaten {
  const unsigned zeit [10] {8, 8, 8, 8, 8, 8, 8, 8, 8, 8};
  const unsigned zeitDefault [10] {15, 500, 20, 5, 4, 9, 2, 2, 500, 500};
  enum MODUS {CROSSFADE, CHANGEUPDOWN} mode {CROSSFADE};
};
ConfigDaten configDaten;

// ------------------------------------------------------------------------------------------------------------------------

constexpr unsigned BUFFERSIZE_FILENAME {20};
const char fileName [BUFFERSIZE_FILENAME] {"/configuration.txt"}; 

// Speichern einer Struktur in eine Datei
bool toSave(auto &dataStructure) {
  bool state {false};

  cout << ("File write: ") << (fileName);
  const bool fileexists = LittleFS.exists(fileName);
  File file = LittleFS.open(fileName, "w");
  if (file) {
    file.write(reinterpret_cast<uint8_t*>(&dataStructure), sizeof(dataStructure));  
    file.close();
    state = true;
  }

  cout << (state ?      " successful"    : " not successful");
  cout << (fileexists ? ", is overwrite." : ", is created.") << endl;;
  return state;
}

// Einlesen der Daten aus der Datei
bool toRead(auto &dataStructure) {
  bool state {false};
  
  cout << ("File read: ") << (fileName);

  const bool fileexists = LittleFS.exists(fileName);
  if (fileexists) { 
    File file = LittleFS.open(fileName, "r");
    if (file) {
      file.read(reinterpret_cast<uint8_t*>(&dataStructure), sizeof(dataStructure));  
      file.close();
      state = true;
    }
  }  

  cout << (state ?      " successful." : " not successful");
  cout << (fileexists ? " " : ", file does not exist.") << endl;
  return state;
}

// ------------------------------------------------------------------------------------------------------------------------

void setup()
{  
  Serial.begin(115200);
  delay(5000);
  cout.println("\nESP32 RESET\n");
  
  // Dateisystem initialisieren
  LittleFS.begin();

  for (unsigned i=0; i<3; i++) {
    cout << ("i: ") << i << (" ");
    toSave(configDaten);
  }
  cout << endl;

  // Funktion zum einlesen aufrufen
  toRead(configDaten);
 
    
}

void loop()
{
  
}

ESP-ROM:esp32s3-20210327

ESP32 RESET

E (5006) esp_littlefs: ./managed_components/joltwallet__littlefs/src/littlefs/lfs.c:1384:error: Corrupted dir pair at {0x0, 0x1}

E (5006) esp_littlefs: mount failed,  (-84)
E (5010) esp_littlefs: Failed to initialize LittleFS
i: 0 File write: /configuration.txt not successful, is created.
i: 1 File write: /configuration.txt not successful, is created.
i: 2 File write: /configuration.txt not successful, is created.

File read: /configuration.txt not successful, file does not exist.

For issues with the SEEED products maybe try the SEEED support forum;

https://forum.seeedstudio.com/c/products/xiao/91

I noticed this in the Example code

/* You only need to format LittleFS the first time you run a
   test or else use the LITTLEFS plugin to create a partition
   https://github.com/lorol/arduino-esp32littlefs-plugin

   If you test two partitions, you need to use a custom
   partition.csv file, see in the sketch folder */

//#define TWOPART

and

void setup() {
  Serial.begin(115200);

#ifdef TWOPART
  if (!LittleFS.begin(FORMAT_LITTLEFS_IF_FAILED, "/lfs2", 5, "part2")) {
    Serial.println("part2 Mount Failed");
    return;
  }

Hi,

I have solved it in the meantime as follows. It was definitely the more complicated way. :sweat_smile:

The solution is, randomnerdtutorials - arduino-ide-2-install-esp32-littlefs

you have to use the plugin
C:\Users\...\.arduinoIDE\pluginsarduino-littlefs-upload-1.5.3.vsix

in Sketch folder > data > filename.txt
This is not the sketchbook ordner. This is in the sketch folder from your sketch.

In the IDE

[Ctrl] + [Shift] + [P]
called 'Upload Little FS to Pico/ESP8266/ESP32'

This will organize the flash for LittleFS. This is a one-time process. Since my XIAO was new, this had to be done later. From now on I can create and write any file name I want in the sketch. Ist alles okay.

Or the shorter way from srnet. :wink: :+1:

Many Thanks.

If I remember a long time ago, I think I did and had to do the same thing with the Arduino Nano ESP32 and ESP8266. It was too long ago. That's why I've certainly forgotten about it.
:thinking:
Thanks.

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