Closed nycholas closed 3 years ago
In the source file, the use of LittleFS.open and LittleFS.exists should be changes to LITTLEFS.open and LITTLEFS.exists.
Also, the #endif on line 297 should include the return statement that is on line 298.
Header source file is named LITTLEFS.h, not LittleFS.h. Compiling in Arduino IDE v1.8.13 fails when not using correct spelling for an OS (Debian Gnu/Linux) that adhere to details.
littlefs_test:3:22: fatal error: LittleFS.h: No such file or directory
compilation terminated.
exit status 1
LittleFS.h: No such file or directory
@poberth and @berrak
I have just followed the documentation from arduino-esp8266[1]:
To convert most applications from SPIFFS to LittleFS simply requires changing the SPIFFS.begin() to LittleFS.begin() and SPIFFS.open() to LittleFS.open() with the rest of the code remaining untouched.
In my projects, I have used the PlatformIO and on configurations is:
[common_env_data]
platform_packages =
framework-arduinoespressif8266
tool-mklittlefs
build_flags =
-Os
-DUSE_LITTLEFS=1
[env:nodemcuv2]
platform = espressif8266
board = nodemcuv2
framework = arduino
board_build.mcu = esp8266
Note on detail to tool-mklittlefs
on configuration.
And a simple example:
#include <Arduino.h>
#include <ESP8266WiFi.h>
#define TJPGD_LOAD_SD_LIBRARY
#include <LittleFS.h>
#include <TJpg_Decoder.h>
void setup() {
Serial.printf("Starting FS...\n");
if (!LittleFS.begin())
{
Serial.println("File System mount failed.");
return;
}
Dir dir = LittleFS.openDir("/");
while (dir.next())
{
if (dir.fileSize())
{
Serial.printf("*FS: %s\n", dir.fileName().c_str());
}
}
}
How are you building your projects?
[1] - https://arduino-esp8266.readthedocs.io/en/latest/filesystem.html [2] - https://platformio.org/
@nycholas I am using LittleFs on esp32 and the library to to is this one : https://github.com/lorol/LITTLEFS that has been integrated in version 4.2 of the Arduino esp32 core idf-release.
Some #ifdef may be required to load the proper library on esp8266 and on esp32.
@poberth Yes, in fact. I got a ESP32 and when a few days I will be able to test this code on ESP32. If you would like to add this code on PR, take your time.
Thank you.
@poberth and @berrak,
I was testing the library on boards WEMOS D1 R1[1], ESP8666 DevKit v1.0[2] and Doit ESP32 DevKit v1[3].
Usage:
#define TJPGD_LOAD_SD_LIBRARY
#ifdef ESP8266
#include <LittleFS.h>
#endif
#ifdef ESP32
#include <FS.h>
#define LittleFS LITTLEFS
#include <LITTLEFS.h>
#endif
#include <TJpg_Decoder.h>
[env:d1]
platform = https://github.com/platformio/platform-espressif8266.git#develop
board = d1
framework = arduino
upload_speed = 115200
monitor_speed = 115200
board_build.arduino.ldscript = eagle.flash.4m1m.ld
board_build.filesystem = littlefs
platform_packages =
framework-arduinoespressif8266
tool-mklittlefs
lib_deps =
TFT_eSPI
https://github.com/cenobites/TJpg_Decoder#master
build_flags =
-Os
-DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG
-DUSER_SETUP_LOADED=1
-DST7735_DRIVER=1
-DTFT_WIDTH=128
-DTFT_HEIGHT=160
-DTFT_CS=15
-DTFT_DC=0
-DTFT_RST=2
-DTFT_SCLK=14
-DLOAD_GLCD=1
-DSPI_FREQUENCY=27000000
-DSPI_READ_FREQUENCY=20000000
-DSPI_TOUCH_FREQUENCY=2500000
-DSUPPORT_TRANSACTIONS=1
-DUSE_LITTLEFS=1
[env:esp8266]
platform = espressif8266
board = nodemcuv2
framework = arduino
board_build.mcu = esp8266
board_build.f_cpu = 160000000L
board_build.filesystem = littlefs
upload_speed = 921600
monitor_speed = 115200
platform_packages =
framework-arduinoespressif8266
tool-mklittlefs
lib_deps =
TFT_eSPI
https://github.com/cenobites/TJpg_Decoder#master
build_flags =
-Os
-DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG
-DUSER_SETUP_LOADED=1
-DST7735_DRIVER=1
-DTFT_WIDTH=128
-DTFT_HEIGHT=160
-DTFT_CS=15
-DTFT_DC=0
-DTFT_RST=2
-DTFT_SCLK=14
-DLOAD_GLCD=1
-DSPI_FREQUENCY=27000000
-DSPI_READ_FREQUENCY=20000000
-DSPI_TOUCH_FREQUENCY=2500000
-DSUPPORT_TRANSACTIONS=1
-DUSE_LITTLEFS=1
[env:esp32]
platform = espressif32
board = esp32doit-devkit-v1
framework = arduino
board_build.mcu = esp32
board_build.f_cpu = 240000000L
board_build.f_flash = 80000000L
board_build.flash_mode = qio
board_build.filesystem = littlefs
upload_speed = 921600
monitor_speed = 115200
platform_packages =
framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git
tool-mklittlefs
lib_deps =
LittleFS_esp32
build_flags =
-Os
-DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG
-DUSER_SETUP_LOADED=1
-DST7735_DRIVER=1
-DTFT_WIDTH=128
-DTFT_HEIGHT=160
-DTFT_CS=15
-DTFT_DC=0
-DTFT_RST=2
-DTFT_SCLK=14
-DLOAD_GLCD=1
-DSPI_FREQUENCY=27000000
-DSPI_READ_FREQUENCY=20000000
-DSPI_TOUCH_FREQUENCY=2500000
-DSUPPORT_TRANSACTIONS=1
-DUSE_LITTLEFS=1
Thank you.
[1] - https://docs.platformio.org/en/latest/boards/espressif8266/d1.html#board-espressif8266-d1 [2] - https://docs.platformio.org/en/latest/boards/espressif8266/nodemcuv2.html#board-espressif8266-nodemcuv2 [3] - https://docs.platformio.org/en/latest/boards/espressif32/esp32doit-devkit-v1.html#board-espressif32-esp32doit-devkit-v1
Thanks, I will merge. I assume the original examples still worked!
Note: to use any of file system functions in the sketch, add the following include to the sketch:
//#include "FS.h" // SPIFFS is declared
include "LittleFS.h" // LittleFS is declared
SDFS and SD
FAT filesystems are supported on the ESP8266 using the old Arduino wrapper “SD.h” which wraps the “SDFS.h” filesystem transparently.
Any commands discussed below pertaining to SPIFFS or LittleFS are applicable to SD/SDFS.
For legacy applications, the classic SD filesystem may continue to be used, but for new applications, directly accessing the SDFS filesystem is recommended as it may expose additional functionality that the old Arduino SD filesystem didn’t have.
Note that in earlier releases of the core, using SD and SPIFFS in the same sketch was complicated and required the use of NO_FS_GLOBALS. The current design makes SD, SDFS, SPIFFS, and LittleFS fully source compatible and so please remove any NO_FS_GLOBALS definitions in your projects when updgrading core versions.
https://arduino-esp8266.readthedocs.io/en/latest/filesystem.html