LittleFS on ESP32S2 - mount failure - only after saving sketch

Hello,
I am currently toying around with a new board - adafruit qt-py-esp32s2.
Since I could not get the SPIFFS_test example to run on my boards (I tested 4 boards), I switched to the LittleFS_test example.
After a first sucess I started to adapt the code fot my own purposes and ran more and more often into "LittleFS mount failure"(s).
My code allways compiled successfully and it did not matter if I changed just a line or many lines in the code.
Thus I just tool the bare example sketch and tested it -> successfull
--> saved it under a different name and under the same name but different directory
--> resulted in mount failure both times.

If I take one of my own sketches using LittleFS - turning my esp32 board into a analog data logger - and just copy my code into the original "LittleFS_test" example windos (not saved by this time) it runs fine. After saving it, I get the mount failure again.

Could it be, that the code will be compiled differently after saving it?
I could not find any differences in the compile output and the .bin files both have the same size.
I would love to compare the .bin files bit by bit but for this I would have so save the "LitteFS_test" original example first - which already seems to cause the problem.

Did anybody else run into a similar problem?

Please post a small sketch that illustrates the problem, using code tags when you do

Hello UKHeliBob!
The basic code is just the "LittleFS_test" example from the LittleFS library.
Saving this sketch under a new name will already lead to the "LittleFS-mount failure" when the code is running on the esp32s2. It compiles fine.

An example of my code is as follows:

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


#include <driver/dac.h>
#include "esp_adc_cal.h"
#include "driver/adc.h"
#include "esp_err.h"
#include "sdkconfig.h"
#include "driver/gpio.h"
#include "hal/adc_types.h"

/* 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 */

static const adc_bits_width_t width = ADC_WIDTH_BIT_13; //  speziell f'fcr ESP32S2 !!!! Alle anderen Werte nur f'fcr ESP32 und ESP32C3 !!!
// calibration values for the adc
#define DEFAULT_VREF 1100
esp_adc_cal_characteristics_t *adc_chars;     
   

//#define TWOPART

#define FORMAT_LITTLEFS_IF_FAILED true

bool vollIndex = false;
bool sampleBuf1 = true;
int cIndex = 0;

void listDir(fs::FS &fs, const char * dirname, uint8_t levels){
    Serial.printf("Listing directory: %srn", dirname);

    File root = fs.open(dirname);
    if(!root){
        Serial.println("- failed to open directory");
        return;
    }
    if(!root.isDirectory()){
        Serial.println(" - not a directory");
        return;
    }

    File file = root.openNextFile();
    while(file){
        if(file.isDirectory()){
            Serial.print("  DIR : ");
            Serial.println(file.name());
            if(levels){
                listDir(fs, file.path(), levels -1);
            }
        } else {
            Serial.print("  FILE: ");
            Serial.print(file.name());
            Serial.print("tSIZE: ");
            Serial.println(file.size());
        }
        file = root.openNextFile();
    }
}

void createDir(fs::FS &fs, const char * path){
    Serial.printf("Creating Dir: %sn", path);
    if(fs.mkdir(path)){
        Serial.println("Dir created");
    } else {
        Serial.println("mkdir failed");
    }
}

void removeDir(fs::FS &fs, const char * path){
    Serial.printf("Removing Dir: %sn", path);
    if(fs.rmdir(path)){
        Serial.println("Dir removed");
    } else {
        Serial.println("rmdir failed");
    }
}

void readFile(fs::FS &fs, const char * path){
    Serial.printf("Reading file: %srn", path);

    File file = fs.open(path);
    if(!file || file.isDirectory()){
        Serial.println("- failed to open file for reading");
        return;
    }

    Serial.println("- read from file:");
    while(file.available()){
        Serial.write(file.read());
    }
    file.close();
}

void writeFile(fs::FS &fs, const char * path, const char * message){
    Serial.printf("Writing file: %srn", path);

    File file = fs.open(path, FILE_WRITE);
    if(!file){
        Serial.println("- failed to open file for writing");
        return;
    }
    if(file.print(message)){
        Serial.println("- file written");
    } else {
        Serial.println("- write failed");
    }
    file.close();
}

void appendFile(fs::FS &fs, const char * path, const char * message){
    Serial.printf("Appending to file: %srn", path);

    File file = fs.open(path, FILE_APPEND);
    if(!file){
        Serial.println("- failed to open file for appending");
        return;
    }
    if(file.print(message)){
        Serial.println("- message appended");
    } else {
        Serial.println("- append failed");
    }
    file.close();
}

void renameFile(fs::FS &fs, const char * path1, const char * path2){
    Serial.printf("Renaming file %s to %srn", path1, path2);
    if (fs.rename(path1, path2)) {
        Serial.println("- file renamed");
    } else {
        Serial.println("- rename failed");
    }
}

void deleteFile(fs::FS &fs, const char * path){
    Serial.printf("Deleting file: %srn", path);
    if(fs.remove(path)){
        Serial.println("- file deleted");
    } else {
        Serial.println("- delete failed");
    }
}

// SPIFFS-like write and delete file, better use #define CONFIG_LITTLEFS_SPIFFS_COMPAT 1

void writeFile2(fs::FS &fs, const char * path, const char * message){
    if(!fs.exists(path)){
    if (strchr(path, '/')) {
            Serial.printf("Create missing folders of: %srn", path);
      char *pathStr = strdup(path);
      if (pathStr) {
        char *ptr = strchr(pathStr, '/');
        while (ptr) {
          *ptr = 0;
          fs.mkdir(pathStr);
          *ptr = '/';
          ptr = strchr(ptr+1, '/');
        }
      }
      free(pathStr);
    }
    }

    Serial.printf("Writing file to: %srn", path);
    File file = fs.open(path, FILE_WRITE);
    if(!file){
        Serial.println("- failed to open file for writing");
        return;
    }
    if(file.print(message)){
        Serial.println("- file written");
    } else {
        Serial.println("- write failed");
    }
    file.close();
}

void deleteFile2(fs::FS &fs, const char * path){
    Serial.printf("Deleting file and empty folders on path: %srn", path);

    if(fs.remove(path)){
        Serial.println("- file deleted");
    } else {
        Serial.println("- delete failed");
    }

    char *pathStr = strdup(path);
    if (pathStr) {
        char *ptr = strrchr(pathStr, '/');
        if (ptr) {
            Serial.printf("Removing all empty folders on path: %srn", path);
        }
        while (ptr) {
            *ptr = 0;
            fs.rmdir(pathStr);
            ptr = strrchr(pathStr, '/');
        }
        free(pathStr);
    }
}

void testFileIO(fs::FS &fs, const char * path){
    Serial.printf("Testing file I/O with %srn", path);

    static uint8_t buf1[512];
    static uint8_t buf2[512];
    sampleBuf1 = true;
    size_t len = 0;
    File file = fs.open(path, FILE_WRITE);
    if(!file){
        Serial.println("- failed to open file for writing");
        return;
    }

   size_t i;
    Serial.print("- writing" );
    uint32_t start = millis();
    for(i=0; i<12; i++){
      for (int b_index = 2; b_index < 512; b_index=b_index+3)
      {
        //uint16_t sample = b_index +6000;
       // uint16_t sample = adc1_get_raw(ADC1_CHANNEL_7);
       uint16_t sample = analogRead(A3);
         /*   
            Serial.print(sample);
            Serial.print(" : ADC Sample    Index: ");
            Serial.println(b_index);*/
        uint8_t sample_u8[3];
        sample_u8[0]=sample & 0xff;
        sample_u8[1]=(sample >> 8);
        sample_u8[2] = 44;

        if (sampleBuf1 == true)
        {
        //buf[b_index] = sample + 44;
        buf1[b_index-2] = sample_u8[1];
        buf1[b_index-1] = sample_u8[0];
        buf1[b_index] = sample_u8[2]; // oder 44 als dez.
        }
        else
        {
        buf2[b_index-2] = sample_u8[1];
        buf2[b_index-1] = sample_u8[0];
        buf2[b_index] = sample_u8[2]; // oder 44 als dez.
        }
        //delayMicroseconds(10);
        if(b_index >= 509)
          vollIndex = true;
      }
        if(vollIndex)
        {
        Serial.println(sampleBuf1);
        sampleBuf1 = !sampleBuf1;
        }
        /*if ((i & 0x001F) == 0x001F){
          Serial.print(".");
        }*/

        if(!sampleBuf1)
          file.write(buf1, 512);
          else
            file.write(buf2, 512);
    }
    Serial.println("");
    uint32_t end = millis() - start;
    Serial.printf(" - %u bytes written in %u msrn", 2048 * 512, end);
    file.close();

   file = fs.open(path);
    start = millis();
    end = start;
  //  i = 0;
    if(file && !file.isDirectory()){
        len = file.size();
        size_t flen = len;
        start = millis();
        Serial.print("- reading" );
        while(len){
            size_t toRead = len;
            Serial.print("File length: ");
            Serial.println(len);
            if(toRead > 512){
                toRead = 512;
            }
            file.read(buf1, toRead);
            Serial.print("To Read: ");
            Serial.println(toRead);
          //  if ((i++ & 0x001F) == 0x001F){
              for (int b_index = 2; b_index < 512; b_index=b_index+3)
              {
                Serial.print("Hallo");
              uint8_t ausgabe_u8[2];
              ausgabe_u8[0] = buf1[b_index-2]; // LSB
              ausgabe_u8[1] = buf1[b_index-1]; // MSB
              //uint16_t ui16 = ausgabe_u8[1] + (ausgabe_u8[0] * 100);
              uint16_t ui16 = ausgabe_u8[1] | (ausgabe_u8[0] <<8 );
              Serial.printf("buf = %d", ui16);
              if (buf1[b_index] == 44)
              {
                Serial.println();
              }
              else
              Serial.printf("Lesefehler");
              }
         //   } --- if i...
            len -= toRead;
        }
        Serial.println("");
        end = millis() - start;
        Serial.printf("- %u bytes read in %u msrn", flen, end);
        file.close();
    } else {
        Serial.println("- failed to open file for reading");
    }
}

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

/*
      //Range 0-4096
  adc1_config_width(width);
  // full voltage range
  adc1_config_channel_atten(ADC1_CHANNEL_7, ADC_ATTEN_DB_11);  //  py-qt-32S2 Pin A3, Full Range!

  // check to see what calibration is available
  if (esp_adc_cal_check_efuse(ESP_ADC_CAL_VAL_EFUSE_VREF) == ESP_OK)
  {
    Serial.println("Using voltage ref stored in eFuse"); //  funktioniert nicht mit ESP32S2 !!
  }
  if (esp_adc_cal_check_efuse(ESP_ADC_CAL_VAL_EFUSE_TP) == ESP_OK)
  {
    Serial.println("Using two point values from eFuse");
  }
  if (esp_adc_cal_check_efuse(ESP_ADC_CAL_VAL_DEFAULT_VREF) == ESP_OK)
  {
    Serial.println("Using default VREF"); //  funktioniert nicht mit ESP32S2 !!
  }
  //Characterize ADC
  adc_chars = (esp_adc_cal_characteristics_t *)calloc(1, sizeof(esp_adc_cal_characteristics_t));
  esp_adc_cal_characterize(ADC_UNIT_1, ADC_ATTEN_DB_11, width, DEFAULT_VREF, adc_chars);
*/
#ifdef TWOPART
    if(!LittleFS.begin(FORMAT_LITTLEFS_IF_FAILED, "/lfs2", 5, "part2")){
    Serial.println("part2 Mount Failed");
    return;
    }
    appendFile(LittleFS, "/hello0.txt", "World0!rn");
    readFile(LittleFS, "/hello0.txt");
    LittleFS.end();

    Serial.println( "Done with part2, work with the first lfs partition..." );
#endif

    if(!LittleFS.begin(FORMAT_LITTLEFS_IF_FAILED)){
        Serial.println("LittleFS Mount Failed");
        return;
    }
    Serial.println( "SPIFFS-like write file to new path and delete it w/folders" );
    writeFile2(LittleFS, "/new1/new2/new3/hello3.txt", "Hello3");
    listDir(LittleFS, "/", 3);
    deleteFile2(LittleFS, "/new1/new2/new3/hello3.txt");
    
    listDir(LittleFS, "/", 3);
  createDir(LittleFS, "/mydir");
  writeFile(LittleFS, "/mydir/hello2.txt", "Hello2");
  listDir(LittleFS, "/", 1);
  deleteFile(LittleFS, "/mydir/hello2.txt");
  removeDir(LittleFS, "/mydir");
  listDir(LittleFS, "/", 1);
    writeFile(LittleFS, "/hello.txt", "Hello ");
    appendFile(LittleFS, "/hello.txt", "World!rn");
    readFile(LittleFS, "/hello.txt");
    renameFile(LittleFS, "/hello.txt", "/foo.txt");
    readFile(LittleFS, "/foo.txt");
    deleteFile(LittleFS, "/foo.txt");
     deleteFile(LittleFS, "/test.txt");
            uint16_t sample = adc1_get_raw(ADC1_CHANNEL_7);
            Serial.print("ADC Sample: ");
            Serial.println(sample);
    testFileIO(LittleFS, "/test.txt");
    deleteFile(LittleFS, "/test.txt");
  
    Serial.println( "Test complete" ); 
}

void loop(){

}

By the way, I first encountered the problem using MacOS with Arduino IDE 1.8.19. I did not use the board manager to add the files for the qt-py-esp32s2 but used the github repository as recomended by Adafruit.
Today I did a clean installation of the IDE and all dependencies on a Win10 System. The error remains the same and is 100% replicable.
I assume that there is some collision between the "LittleFS" library and the esp32s2 board files.
If the code would always fail, that would be comprehensible. But not failing before saving and failing after saving the sketch doesn´t make sense to me.
Thanks and best regards

To which you have made changes

Does the original example sketch work OK ?

Can you show us the compilation completed message ?

Hello Deva_Rishi,

the compilation messages output is too long to post here (limited to xxx characters).
Is there any particular section that I should post? Otherwise I could only post it divided into several sections.

Thanks

Just the section the IDE shows, when compilation is complete, the bytes used from total etc.

Sorry UKHeliBob,
I did not reply at you at once.
Yes, the original code works until I save it with a new filename and/or under a new directory.
The same is true for all changes I make to the original code.
I can change that code, save and compile it - to check that the code is compilable. If I updload it to the esp32s2 I will get the "mount failure".
Then I open a new window by choosing the original example code, delete that code an paste my new code there. If I do not opt for saving and just upload this code, it will work fine - not mount failure. I could use this - and actually I did use this - as a workaround to my problem. But there has to be something under the hood that either I do wrong or that is implemented wrong.
? Thanks again

Hello Deva_Rishi,
just repeated the procedure that I described in my reply to UKHeliBob. It is repeatable all the time.
So here is the message for compiling my code posted earlier before saving it. The result is a working system with no mounting failure:

Compiling library "FS"
Zuvor kompilierte Datei wird verwendet: C:\Users\Rudolf\AppData\Local\Temp\arduino_build_504842\libraries\FS\vfs_api.cpp.o
Zuvor kompilierte Datei wird verwendet: C:\Users\Rudolf\AppData\Local\Temp\arduino_build_504842\libraries\FS\FS.cpp.o
Compiling library "LittleFS"
Zuvor kompilierte Datei wird verwendet: C:\Users\Rudolf\AppData\Local\Temp\arduino_build_504842\libraries\LittleFS\LittleFS.cpp.o
Compiling core...
Zuvor kompilierte Datei wird verwendet: C:\Users\Rudolf\AppData\Local\Temp\arduino_build_504842\core\variant.cpp.o
Using precompiled core: C:\Users\Rudolf\AppData\Local\Temp\arduino_cache_693743\core\core_506ac443639379592a65fbb44a702dee.a
Linking everything together...
"C:\\Users\\Rudolf\\Documents\\Arduino\\hardware\\espressif\\esp32/tools/xtensa-esp32s2-elf/bin/xtensa-esp32s2-elf-g++" "-Wl,--Map=C:\\Users\\Rudolf\\AppData\\Local\\Temp\\arduino_build_504842/LITTLEFS_test.ino.map" "-LC:\\Users\\Rudolf\\Documents\\Arduino\\hardware\\espressif\\esp32/tools/sdk/esp32s2/lib" "-LC:\\Users\\Rudolf\\Documents\\Arduino\\hardware\\espressif\\esp32/tools/sdk/esp32s2/ld" "-LC:\\Users\\Rudolf\\Documents\\Arduino\\hardware\\espressif\\esp32/tools/sdk/esp32s2/qspi_qspi" -T memory.ld -T sections.ld -T esp32s2.rom.ld -T esp32s2.rom.api.ld -T esp32s2.rom.libgcc.ld -T esp32s2.rom.newlib-funcs.ld -T esp32s2.rom.newlib-data.ld -T esp32s2.rom.spiflash.ld -T esp32s2.rom.newlib-time.ld -T esp32s2.peripherals.ld -mlongcalls -Wl,--cref -Wl,--gc-sections -fno-rtti -fno-lto -u _Z5setupv -u _Z4loopv -u esp_app_desc -u pthread_include_pthread_impl -u pthread_include_pthread_cond_impl -u pthread_include_pthread_local_storage_impl -u pthread_include_pthread_rwlock_impl -u ld_include_highint_hdl -u start_app -u __ubsan_include -Wl,--wrap=longjmp -u __assert_func -u vfs_include_syscalls_impl -Wl,--undefined=uxTopUsedPriority -u app_main -u newlib_include_heap_impl -u newlib_include_syscalls_impl -u newlib_include_pthread_impl -u newlib_include_assert_impl -u __cxa_guard_dummy -DESP32 -DCORE_DEBUG_LEVEL=0 -DBOARD_HAS_PSRAM -DARDUINO_USB_MODE=0 -DARDUINO_USB_CDC_ON_BOOT=1 -DARDUINO_USB_MSC_ON_BOOT=0 -DARDUINO_USB_DFU_ON_BOOT=0 -Wl,--start-group "C:\\Users\\Rudolf\\AppData\\Local\\Temp\\arduino_build_504842\\sketch\\LITTLEFS_test.ino.cpp.o" "C:\\Users\\Rudolf\\AppData\\Local\\Temp\\arduino_build_504842\\libraries\\FS\\FS.cpp.o" "C:\\Users\\Rudolf\\AppData\\Local\\Temp\\arduino_build_504842\\libraries\\FS\\vfs_api.cpp.o" "C:\\Users\\Rudolf\\AppData\\Local\\Temp\\arduino_build_504842\\libraries\\LittleFS\\LittleFS.cpp.o" "C:\\Users\\Rudolf\\AppData\\Local\\Temp\\arduino_build_504842\\core\\variant.cpp.o" "C:\\Users\\Rudolf\\AppData\\Local\\Temp\\arduino_cache_693743\\core\\core_506ac443639379592a65fbb44a702dee.a" -lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -lconsole -llwip -llog -lheap -lsoc -lesp_hw_support -lxtensa -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lasio -lcbor -lunity -lcmock -lcoap -lnghttp -lesp-tls -lesp_adc_cal -lesp_hid -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lesp_https_server -lesp_lcd -lprotobuf-c -lprotocomm -lmdns -lesp_local_ctrl -lsdmmc -lesp_serial_slave_link -lesp_websocket_client -lexpat -lwear_levelling -lfatfs -lfreemodbus -ljsmn -ljson -llibsodium -lmqtt -lopenssl -lperfmon -lspiffs -lusb -ltouch_element -lulp -lwifi_provisioning -lbutton -lrmaker_common -ljson_parser -ljson_generator -lesp_schedule -lesp_rainmaker -lqrcode -lws2812_led -lesp-dsp -lesp-sr -lesp32-camera -lesp_littlefs -lfb_gfx -lasio -lcbor -lcmock -lunity -lcoap -lesp_lcd -lesp_websocket_client -lexpat -lfreemodbus -ljsmn -llibsodium -lperfmon -lusb -ltouch_element -lesp_adc_cal -lesp_hid -lfatfs -lwear_levelling -lopenssl -lesp_rainmaker -lesp_local_ctrl -lesp_https_server -lwifi_provisioning -lprotocomm -lprotobuf-c -lmdns -lrmaker_common -lmqtt -ljson_parser -ljson_generator -lesp_schedule -lqrcode -larduino_tinyusb -lcat_face_detect -lhuman_face_detect -lcolor_detect -lmfn -ldl -ljson -lspiffs -lesp_tts_chinese -lvoice_set_xiaole -lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -lconsole -llwip -llog -lheap -lsoc -lesp_hw_support -lxtensa -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lnghttp -lesp-tls -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lsdmmc -lesp_serial_slave_link -lulp -lmbedtls -lmbedcrypto -lmbedx509 -lcoexist -lcore -lespnow -lmesh -lnet80211 -lpp -lsmartconfig -lwapi -lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -lconsole -llwip -llog -lheap -lsoc -lesp_hw_support -lxtensa -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lnghttp -lesp-tls -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lsdmmc -lesp_serial_slave_link -lulp -lmbedtls -lmbedcrypto -lmbedx509 -lcoexist -lcore -lespnow -lmesh -lnet80211 -lpp -lsmartconfig -lwapi -lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -lconsole -llwip -llog -lheap -lsoc -lesp_hw_support -lxtensa -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lnghttp -lesp-tls -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lsdmmc -lesp_serial_slave_link -lulp -lmbedtls -lmbedcrypto -lmbedx509 -lcoexist -lcore -lespnow -lmesh -lnet80211 -lpp -lsmartconfig -lwapi -lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -lconsole -llwip -llog -lheap -lsoc -lesp_hw_support -lxtensa -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lnghttp -lesp-tls -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lsdmmc -lesp_serial_slave_link -lulp -lmbedtls -lmbedcrypto -lmbedx509 -lcoexist -lcore -lespnow -lmesh -lnet80211 -lpp -lsmartconfig -lwapi -lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -lconsole -llwip -llog -lheap -lsoc -lesp_hw_support -lxtensa -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lnghttp -lesp-tls -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lsdmmc -lesp_serial_slave_link -lulp -lmbedtls -lmbedcrypto -lmbedx509 -lcoexist -lcore -lespnow -lmesh -lnet80211 -lpp -lsmartconfig -lwapi -lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -lconsole -llwip -llog -lheap -lsoc -lesp_hw_support -lxtensa -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lnghttp -lesp-tls -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lsdmmc -lesp_serial_slave_link -lulp -lmbedtls -lmbedcrypto -lmbedx509 -lcoexist -lcore -lespnow -lmesh -lnet80211 -lpp -lsmartconfig -lwapi -lphy -lesp_phy -lphy -lesp_phy -lphy -lxt_hal -lm -lnewlib -lstdc++ -lpthread -lgcc -lcxx -lapp_trace -lgcov -lapp_trace -lgcov -lc -Wl,--end-group -Wl,-EL -o "C:\\Users\\Rudolf\\AppData\\Local\\Temp\\arduino_build_504842/LITTLEFS_test.ino.elf"
"C:\\Users\\Rudolf\\Documents\\Arduino\\hardware\\espressif\\esp32/tools/esptool/esptool.exe" --chip esp32s2 elf2image --flash_mode dio --flash_freq 80m --flash_size 4MB -o "C:\\Users\\Rudolf\\AppData\\Local\\Temp\\arduino_build_504842/LITTLEFS_test.ino.bin" "C:\\Users\\Rudolf\\AppData\\Local\\Temp\\arduino_build_504842/LITTLEFS_test.ino.elf"
esptool.py v3.2
Merged 2 ELF sections
"C:\\Users\\Rudolf\\Documents\\Arduino\\hardware\\espressif\\esp32/tools/gen_esp32part.exe" -q "C:\\Users\\Rudolf\\AppData\\Local\\Temp\\arduino_build_504842/partitions.csv" "C:\\Users\\Rudolf\\AppData\\Local\\Temp\\arduino_build_504842/LITTLEFS_test.ino.partitions.bin"
Bibliothek FS in Version 2.0.0 im Ordner: C:\Users\Rudolf\Documents\Arduino\hardware\espressif\esp32\libraries\FS  wird verwendet
Bibliothek LittleFS in Version 2.0.0 im Ordner: C:\Users\Rudolf\Documents\Arduino\hardware\espressif\esp32\libraries\LittleFS  wird verwendet
"C:\\Users\\Rudolf\\Documents\\Arduino\\hardware\\espressif\\esp32/tools/xtensa-esp32s2-elf/bin/xtensa-esp32s2-elf-size" -A "C:\\Users\\Rudolf\\AppData\\Local\\Temp\\arduino_build_504842/LITTLEFS_test.ino.elf"
Der Sketch verwendet 269930 Bytes (20%) des Programmspeicherplatzes. Das Maximum sind 1310720 Bytes.
Globale Variablen verwenden 19212 Bytes (5%) des dynamischen Speichers, 308468 Bytes für lokale Variablen verbleiben. Das Maximum sind 327680 Bytes.
Erzwinge Reset durch öffnen/schließen mit 1200 bps auf dem Port COM3
PORTS {COM3, } / {COM3, COM4, } => {COM4, }
Found upload port: COM4
C:\Users\Rudolf\Documents\Arduino\hardware\espressif\esp32/tools/esptool/esptool.exe --chip esp32s2 --port COM4 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 80m --flash_size 4MB 0xe000 C:\Users\Rudolf\Documents\Arduino\hardware\espressif\esp32/tools/partitions/boot_app0.bin 0x1000 C:\Users\Rudolf\AppData\Local\Temp\arduino_build_504842/LITTLEFS_test.ino.bootloader.bin 0x10000 C:\Users\Rudolf\AppData\Local\Temp\arduino_build_504842/LITTLEFS_test.ino.bin 0x8000 C:\Users\Rudolf\AppData\Local\Temp\arduino_build_504842/LITTLEFS_test.ino.partitions.bin 0x2d0000 C:\Users\Rudolf\Documents\Arduino\hardware\espressif\esp32/variants/adafruit_qtpy_esp32s2/tinyuf2.bin 
esptool.py v3.2
Serial port COM4
Connecting.....

And this is the same after saving the sktech und compiling and uploading it again:

Linking everything together...
"C:\\Users\\Rudolf\\Documents\\Arduino\\hardware\\espressif\\esp32/tools/xtensa-esp32s2-elf/bin/xtensa-esp32s2-elf-g++" "-Wl,--Map=C:\\Users\\Rudolf\\AppData\\Local\\Temp\\arduino_build_504842/LITTLEFS_test_8bit.ino.map" "-LC:\\Users\\Rudolf\\Documents\\Arduino\\hardware\\espressif\\esp32/tools/sdk/esp32s2/lib" "-LC:\\Users\\Rudolf\\Documents\\Arduino\\hardware\\espressif\\esp32/tools/sdk/esp32s2/ld" "-LC:\\Users\\Rudolf\\Documents\\Arduino\\hardware\\espressif\\esp32/tools/sdk/esp32s2/qspi_qspi" -T memory.ld -T sections.ld -T esp32s2.rom.ld -T esp32s2.rom.api.ld -T esp32s2.rom.libgcc.ld -T esp32s2.rom.newlib-funcs.ld -T esp32s2.rom.newlib-data.ld -T esp32s2.rom.spiflash.ld -T esp32s2.rom.newlib-time.ld -T esp32s2.peripherals.ld -mlongcalls -Wl,--cref -Wl,--gc-sections -fno-rtti -fno-lto -u _Z5setupv -u _Z4loopv -u esp_app_desc -u pthread_include_pthread_impl -u pthread_include_pthread_cond_impl -u pthread_include_pthread_local_storage_impl -u pthread_include_pthread_rwlock_impl -u ld_include_highint_hdl -u start_app -u __ubsan_include -Wl,--wrap=longjmp -u __assert_func -u vfs_include_syscalls_impl -Wl,--undefined=uxTopUsedPriority -u app_main -u newlib_include_heap_impl -u newlib_include_syscalls_impl -u newlib_include_pthread_impl -u newlib_include_assert_impl -u __cxa_guard_dummy -DESP32 -DCORE_DEBUG_LEVEL=0 -DBOARD_HAS_PSRAM -DARDUINO_USB_MODE=0 -DARDUINO_USB_CDC_ON_BOOT=1 -DARDUINO_USB_MSC_ON_BOOT=0 -DARDUINO_USB_DFU_ON_BOOT=0 -Wl,--start-group "C:\\Users\\Rudolf\\AppData\\Local\\Temp\\arduino_build_504842\\sketch\\LITTLEFS_test_8bit.ino.cpp.o" "C:\\Users\\Rudolf\\AppData\\Local\\Temp\\arduino_build_504842\\libraries\\FS\\FS.cpp.o" "C:\\Users\\Rudolf\\AppData\\Local\\Temp\\arduino_build_504842\\libraries\\FS\\vfs_api.cpp.o" "C:\\Users\\Rudolf\\AppData\\Local\\Temp\\arduino_build_504842\\libraries\\LittleFS\\LittleFS.cpp.o" "C:\\Users\\Rudolf\\AppData\\Local\\Temp\\arduino_build_504842\\core\\variant.cpp.o" "C:\\Users\\Rudolf\\AppData\\Local\\Temp\\arduino_cache_693743\\core\\core_506ac443639379592a65fbb44a702dee.a" -lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -lconsole -llwip -llog -lheap -lsoc -lesp_hw_support -lxtensa -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lasio -lcbor -lunity -lcmock -lcoap -lnghttp -lesp-tls -lesp_adc_cal -lesp_hid -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lesp_https_server -lesp_lcd -lprotobuf-c -lprotocomm -lmdns -lesp_local_ctrl -lsdmmc -lesp_serial_slave_link -lesp_websocket_client -lexpat -lwear_levelling -lfatfs -lfreemodbus -ljsmn -ljson -llibsodium -lmqtt -lopenssl -lperfmon -lspiffs -lusb -ltouch_element -lulp -lwifi_provisioning -lbutton -lrmaker_common -ljson_parser -ljson_generator -lesp_schedule -lesp_rainmaker -lqrcode -lws2812_led -lesp-dsp -lesp-sr -lesp32-camera -lesp_littlefs -lfb_gfx -lasio -lcbor -lcmock -lunity -lcoap -lesp_lcd -lesp_websocket_client -lexpat -lfreemodbus -ljsmn -llibsodium -lperfmon -lusb -ltouch_element -lesp_adc_cal -lesp_hid -lfatfs -lwear_levelling -lopenssl -lesp_rainmaker -lesp_local_ctrl -lesp_https_server -lwifi_provisioning -lprotocomm -lprotobuf-c -lmdns -lrmaker_common -lmqtt -ljson_parser -ljson_generator -lesp_schedule -lqrcode -larduino_tinyusb -lcat_face_detect -lhuman_face_detect -lcolor_detect -lmfn -ldl -ljson -lspiffs -lesp_tts_chinese -lvoice_set_xiaole -lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -lconsole -llwip -llog -lheap -lsoc -lesp_hw_support -lxtensa -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lnghttp -lesp-tls -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lsdmmc -lesp_serial_slave_link -lulp -lmbedtls -lmbedcrypto -lmbedx509 -lcoexist -lcore -lespnow -lmesh -lnet80211 -lpp -lsmartconfig -lwapi -lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -lconsole -llwip -llog -lheap -lsoc -lesp_hw_support -lxtensa -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lnghttp -lesp-tls -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lsdmmc -lesp_serial_slave_link -lulp -lmbedtls -lmbedcrypto -lmbedx509 -lcoexist -lcore -lespnow -lmesh -lnet80211 -lpp -lsmartconfig -lwapi -lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -lconsole -llwip -llog -lheap -lsoc -lesp_hw_support -lxtensa -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lnghttp -lesp-tls -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lsdmmc -lesp_serial_slave_link -lulp -lmbedtls -lmbedcrypto -lmbedx509 -lcoexist -lcore -lespnow -lmesh -lnet80211 -lpp -lsmartconfig -lwapi -lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -lconsole -llwip -llog -lheap -lsoc -lesp_hw_support -lxtensa -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lnghttp -lesp-tls -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lsdmmc -lesp_serial_slave_link -lulp -lmbedtls -lmbedcrypto -lmbedx509 -lcoexist -lcore -lespnow -lmesh -lnet80211 -lpp -lsmartconfig -lwapi -lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -lconsole -llwip -llog -lheap -lsoc -lesp_hw_support -lxtensa -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lnghttp -lesp-tls -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lsdmmc -lesp_serial_slave_link -lulp -lmbedtls -lmbedcrypto -lmbedx509 -lcoexist -lcore -lespnow -lmesh -lnet80211 -lpp -lsmartconfig -lwapi -lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -lconsole -llwip -llog -lheap -lsoc -lesp_hw_support -lxtensa -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lnghttp -lesp-tls -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lsdmmc -lesp_serial_slave_link -lulp -lmbedtls -lmbedcrypto -lmbedx509 -lcoexist -lcore -lespnow -lmesh -lnet80211 -lpp -lsmartconfig -lwapi -lphy -lesp_phy -lphy -lesp_phy -lphy -lxt_hal -lm -lnewlib -lstdc++ -lpthread -lgcc -lcxx -lapp_trace -lgcov -lapp_trace -lgcov -lc -Wl,--end-group -Wl,-EL -o "C:\\Users\\Rudolf\\AppData\\Local\\Temp\\arduino_build_504842/LITTLEFS_test_8bit.ino.elf"
"C:\\Users\\Rudolf\\Documents\\Arduino\\hardware\\espressif\\esp32/tools/esptool/esptool.exe" --chip esp32s2 elf2image --flash_mode dio --flash_freq 80m --flash_size 4MB -o "C:\\Users\\Rudolf\\AppData\\Local\\Temp\\arduino_build_504842/LITTLEFS_test_8bit.ino.bin" "C:\\Users\\Rudolf\\AppData\\Local\\Temp\\arduino_build_504842/LITTLEFS_test_8bit.ino.elf"
esptool.py v3.2
Merged 2 ELF sections
"C:\\Users\\Rudolf\\Documents\\Arduino\\hardware\\espressif\\esp32/tools/gen_esp32part.exe" -q "C:\\Users\\Rudolf\\AppData\\Local\\Temp\\arduino_build_504842/partitions.csv" "C:\\Users\\Rudolf\\AppData\\Local\\Temp\\arduino_build_504842/LITTLEFS_test_8bit.ino.partitions.bin"
Bibliothek FS in Version 2.0.0 im Ordner: C:\Users\Rudolf\Documents\Arduino\hardware\espressif\esp32\libraries\FS  wird verwendet
Bibliothek LittleFS in Version 2.0.0 im Ordner: C:\Users\Rudolf\Documents\Arduino\hardware\espressif\esp32\libraries\LittleFS  wird verwendet
"C:\\Users\\Rudolf\\Documents\\Arduino\\hardware\\espressif\\esp32/tools/xtensa-esp32s2-elf/bin/xtensa-esp32s2-elf-size" -A "C:\\Users\\Rudolf\\AppData\\Local\\Temp\\arduino_build_504842/LITTLEFS_test_8bit.ino.elf"
Der Sketch verwendet 269930 Bytes (20%) des Programmspeicherplatzes. Das Maximum sind 1310720 Bytes.
Globale Variablen verwenden 19212 Bytes (5%) des dynamischen Speichers, 308468 Bytes für lokale Variablen verbleiben. Das Maximum sind 327680 Bytes.
Erzwinge Reset durch öffnen/schließen mit 1200 bps auf dem Port COM3
PORTS {COM3, } / {COM3, COM4, } => {COM4, }
Found upload port: COM4
C:\Users\Rudolf\Documents\Arduino\hardware\espressif\esp32/tools/esptool/esptool.exe --chip esp32s2 --port COM4 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 80m --flash_size 4MB 0xe000 C:\Users\Rudolf\Documents\Arduino\hardware\espressif\esp32/tools/partitions/boot_app0.bin 0x1000 C:\Users\Rudolf\AppData\Local\Temp\arduino_build_504842/LITTLEFS_test_8bit.ino.bootloader.bin 0x10000 C:\Users\Rudolf\AppData\Local\Temp\arduino_build_504842/LITTLEFS_test_8bit.ino.bin 0x8000 C:\Users\Rudolf\AppData\Local\Temp\arduino_build_504842/LITTLEFS_test_8bit.ino.partitions.bin 0x2d0000 C:\Users\Rudolf\Documents\Arduino\hardware\espressif\esp32/variants/adafruit_qtpy_esp32s2/tinyuf2.bin 
esptool.py v3.2
Serial port COM4
Connecting...
Chip is ESP32-S2FNR2
Features: WiFi, Embedded Flash 4MB, Embedded PSRAM 2MB, ADC and temperature sensor calibration in BLK2 of efuse V1
Crystal is 40MHz
MAC: 84:f7:03:f6:ac:90
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 921600
Changed.

This time I get the "mount failure" again.

I cannot spot any differnces in the messages.
Thanks again

I have tested the original LITTLEFS_test sketch

  • loaded it into the IDE
  • uploaded it to the ESP32
  • saved the sketch in the sketchbook folder with a new name
  • uploaded it again
  • closed the file
  • opened the file with the new name
  • uploaded it

All of this was with an original ESP32 but I note that you are using and ESP32S2 which may be a factor in your problem

Yes, the esp32s2 type of processor must be core to my problem. As I mentioned earlier, I could not get the example "SPIFFS_test" to run on any esp32s2 board at all.
So I where I stand now is that I can replicate the behaviour across different esp32s2 boards and across different operating systems for the IDE. I do not believe that it is any kind of unstable behaviour in part of the cpu. So I suspect, that the compiler uses different dependencies when compiling the code that it takes as the original example when compared to compiling the code after it was saved under a different name. Unfortunately the compiler output -- and this is miles and miles of output -- does not show any differences and my knowledge about the linking and compiling process under the hood of the Arduino IDE is far too limited to verify that.
Many thanks to you for your help and effort!

You are saying that the compiled binary resulting from the compilation process would differ ? What happens when you upload a previously exported compiled binary ?

So what is your board selection in the IDE ?

I think that a different compilation process is causing my problem, but I cannot find any proof for that.

My board setup in IDE is:

C:\Users\Rudolf\Documents\Arduino\hardware\espressif\esp32/tools/esptool/esptool.exe --chip esp32s2 --port COM4 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 80m --flash_size 4MB 0xe000 C:\Users\Rudolf\Documents\Arduino\hardware\espressif\esp32/tools/partitions/boot_app0.bin 0x1000 C:\Users\Rudolf\AppData\Local\Temp\arduino_build_504842/LITTLEFS_test_8bit.ino.bootloader.bin 0x10000 C:\Users\Rudolf\AppData\Local\Temp\arduino_build_504842/LITTLEFS_test_8bit.ino.bin 0x8000 C:\Users\Rudolf\AppData\Local\Temp\arduino_build_504842/LITTLEFS_test_8bit.ino.partitions.bin 0x2d0000 C:\Users\Rudolf\Documents\Arduino\hardware\espressif\esp32/variants/adafruit_qtpy_esp32s2/tinyuf2.bin
esptool.py v3.2
Serial port COM4
Connecting...
Chip is ESP32-S2FNR2
Features: WiFi, Embedded Flash 4MB, Embedded PSRAM 2MB, ADC and temperature sensor calibration in BLK2 of efuse V1
Crystal is 40MHz

It derives from "ESP32 Arduino (in sketchbook)" from the espressif github repository.

I will try and upload a previously exported binary and report to you this evening.

So you are not using the ESP32-core ?

On Win10 I installed the board support package following the Adafruit tutorial for the qt-py esp32s2. (tried to find out, if there were any updates for the packages).

The ESP32-S2 Arduino board support package is currently part of the 2.0.0 or later release. To use the ESP32-S2 with Arduino, you'll need to follow the steps below for your operating system. You can also check out the Espressif Arduino repository for the most up to date details on how to install it.

On MacOS I inserted the json path and installed the esp32 2.0.0. BSP version via the board manager - the behaviour of the boards are the same for both my installations

Well really i am suspecting an error in the core. So i'd say you should take the matter up with the developers of it and report it as an issue.

I was able to figure this out... seems there is a partition csv file that it should have for the file system setup... The example sketch has a partitions.csv file in the sketch directory that it uses. If you save the sketch somewhere else you dont get this file... If I copy that file to the new sketch location it works.

go to sketch->show folder to get the location of the example (I was having a hard time finding it in the install)

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