Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please test with LITTLEFS for esp32 #197

Open
lorol opened this issue Sep 8, 2020 · 6 comments
Open

Please test with LITTLEFS for esp32 #197

lorol opened this issue Sep 8, 2020 · 6 comments

Comments

@lorol
Copy link

lorol commented Sep 8, 2020

Hi @rjwats

I tested with minor tweak of platformio.ini and ESPFS.h, at least it builds fine with my "hacky" esp32 library here: https://github.com/lorol/LITTLEFS
See the PlatformIO note at the the bottom of README.
You can add also to build_flags -D CONFIG_LITTLEFS_FOR_IDF_3_2 until the core repositories get moved to newer IDF

Update:
It seems to be actually working. Few "errors" on serial console, but they are due to:
https://github.com/espressif/arduino-esp32/blob/4638628873a061c36faffebe4d146d13f960076d/libraries/FS/src/vfs_api.cpp#L57
I don't know what to do with them :) SPIFFS is different than LittleFS and we have to live with that ...
... see also here: espressif/arduino-esp32#4138

Update2:
I forgot to mention I needed to add a /config folder (and a dummy holder.txt file in it) to project data directory before flash the FS image. Otherwise it will not be able to create and save the config jsons. I guess again SPIFFS creates folder/file at once (as file) while LittleFS not, unless we make-up backwards as on ESP8266 is done.
It is maybe the best to have all 7 x .json files created as empty files under /config folder. Probably other tweaks ...

image

BTW the error [E][WiFiGeneric.cpp:117] wifiLowLevelInit(): esp_wifi_init 4353 is present also with standard SPIFFS setting

Appreciate your validation.

Thank you,

@raomin
Copy link
Contributor

raomin commented Mar 20, 2021

+1
I moved my esp32 project to use @lorol's LITTLEFS with esp8266-react and it's working fine with CONFIG_LITTLEFS_SPIFFS_COMPAT 1
LITTLEFS is really more reliable then SPIFFS, worth the effort IMO.

@raomin
Copy link
Contributor

raomin commented Mar 23, 2021

Ah, one thing I found is that the LittleFS does not unlink (delete) files if they have opened descriptors.
This is an issue with factory reset:

Failed to unlink path "/config/apSettings.json". Has open FD.
Failed to unlink path "/config/mqttSettings.json". Has open FD.
Failed to unlink path "/config/ntpSettings.json". Has open FD.
Failed to unlink path "/config/securitySettings.json". Has open FD.
Failed to unlink path "/config/sensorSettings.json". Has open FD.

@proddy
Copy link

proddy commented Mar 23, 2021

I discoverd this too, it's by design in LitteFS (see lorol/LITTLEFS#22). I fixed in my fork with code below (sorry should have done a PR).

void FactoryResetService::factoryReset() {
#ifdef ESP32
  /* 
   * Based on LITTLEFS. Modified by proddy
   * Could be replaced with fs.rmdir(FS_CONFIG_DIRECTORY) in IDF 4.2 when platformio catches up
   */
    File root = fs->open(FS_CONFIG_DIRECTORY);
    File file;
    while (file = root.openNextFile()) {
        char * pathStr = strdup(file.name());
        file.close();
        fs->remove(pathStr);
    }
#elif defined(ESP8266)
    Dir configDirectory = fs->openDir(FS_CONFIG_DIRECTORY);
    while (configDirectory.next()) {
        String path = FS_CONFIG_DIRECTORY;
        path.concat("/");
        path.concat(configDirectory.fileName());
        fs->remove(path);
    }
#endif
    RestartService::restartNow();
}

@rjwats
Copy link
Owner

rjwats commented Mar 24, 2021

Thx for the example Proddy, does the strdup need a free in your example (i'm never sure)?

My plan was to wait for the IDF 4.2 release of arduino-esp32 before bothering with adding LITTLEFS support. I wasn't experiencing issues with SPIFFS but I appreciate that others have. Seeing as the 4.2 release may be a way off... might be worth rethinking.

Would probably have to ditch the documentation around manual FS uploads. I'm assuming the PIO tooling doesn't allow for that with a custom FS library - anyone have any experience?

@proddy
Copy link

proddy commented Mar 24, 2021

yeah should be free'd but no point since the ESP is restarted ;)

@FernandoGarcia
Copy link

Hi!

I'm facing similar issue and I would like to suggest to add some validation here.

The interface is returning a positive message and restarting the controller but the file is not deleted.

Captura de tela de 2022-04-03 16 29 57

Best regards.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants