B4R Library rLittleFS for B4R

this is littleFS library for esp8266 and esp32 on B4R

it is rESP8266FileSystem modified to work with littleFS
this library is faster and more reliable then spiffs.

we have all functions of rESP8266FileSystem with a few more :
bool OpenAppend (B4RString* FileName);
bool Rename(B4RString* FileName1,B4RString* FileName2);
=> functions added to manage Directories :
bool getIsDirectory();
bool getIsFile();
bool MKDir (B4RString* DIRName);
bool RMDir (B4RString* DIRName);


We can move from rESP8266FileSystem to rLittleFS with a few modifications of code.

the major change is directory management: with rLittleFS we have access to files directory by directory and each time we have to check if it is a file or a new sub-directory

- to use littleFS on esp32, you have to install LITTLEFS in arduino, and a good way is to install development release from espressif :https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_dev_index.json
- more information here: https://espressif.github.io/arduino-esp32/docs/arduino-ide/boards_manager.html

both projects FTPserver on esp8266 and esp32 are built with this library to manage files and directories in esp.
(available in shared creations)

- added an example of project to demonstrate functions of the library

21/01/27 a few modifications for esp32 v2.0 compatibility

last delivery 1.12 ed2 : Zip format ready to unzip it in Additional Library Directory and correct version seen in B4R
 

Attachments

  • rLittleFS.1.12_ed2.zip
    6.4 KB · Views: 68
Last edited:

Johan Hormaza

Well-Known Member
Licensed User
Longtime User
I have this problem with the version of ESP32 Cards V2.0.2

1643295514068.png
 

candide

Active Member
Licensed User
not easy to understand...

normally if esp32 package for arduino is installed, LittleFS is in user\AppData\Local\Arduino15\package\esp32\hardware\esp32\2.0.2\libraries\LittleFS
=> normally cpp and h files are in LittleFS\src\

after, you should have a directory rLittleFS with others libraries B4R added manually.

in your listing i can see:
Documents\Arduino\libraries\LittleFS_esp32\LITTLEFS.cpp
- this directory is strange, it is not arduino directory for LittleFS esp32, it is not library B4R
- "LittleFS_esp32" is not a standard directory, not sure it can be used by Arduino
- Normally, LittleFS .cpp is not in upper case like here "LITTLEFS.cpp"

i think it is more an issue due to installation....

to check installation:
- after installation of package ESP32 in arduino, you can run in arduino a project example with LittleFS provided with package
- after, when rLittleFS directory is installed, you can try a simple compilation of an empty project with LittleFS library added at project , but without to use it
- after you can compile a small project inclutding LittleFS library and it should work.

good luck
 

candide

Active Member
Licensed User
after a test, a short term solution is possible:
in rLittleFS.cpp, you can mask a few lines at start of file and compliation is OK. (because now naming of library is same for esp8266 and esp32)

#include "B4RDefines.h"
//#ifdef ESP32
#include "LITTLEFS"
//#define LittleFS LITTLEFS
//#else
//#include "LittleFS.h"
//#endif

namespace B4R {

i will change the library in forum soon

good luck
 

Johan Hormaza

Well-Known Member
Licensed User
Longtime User
Now it works for me, but I have a problem creating a file.
Here is my code.
B4X:
    Dim filename As String = "test7.dat"
    If fs.OpenReadWrite(filename)=True Then
        Log("BytesAvaible:",fs.Stream.BytesAvailable)
        Log("CurrentSize: ",fs.CurrentFile.Size)

        Dim te As String
        Dim wB As UInt
        Dim b() As Byte
        te = JoinStrings(Array As String("A test line",CRLF))
        b=bc.StringToBytes(te)
        fs.Position = fs.CurrentFile.Size
        wB = fs.Stream.WriteBytes(b, 0 ,b.Length)
        Log("Written:",wB," ",te)
        fs.Close
    Else
        Log("No puedo abrir/crear")
    End If

Log: ./components/esp_littlefs/src/littlefs/lfs.c:1071:error: Corrupted dir pair at {0x0, 0x1}
 
Top