B4R Question LittleFS compile errors when Arduino board updated to v3

RJB

Active Member
Licensed User
Longtime User
If I update the esp32 board from v1.0.6 to v3.0.1 in the Arduino board manager I get littleFS errors on compile
The rLittleFS library version is 1.11 and no online version is shown in the Libraries manager.
Is there/ should there be an updated version of the library to work with the updated arduino board?
The errors are:
B4X:
Compiling (ESP32 Dev Module)    Error
C:\Users\robin\Documents\Arduino\libraries\LittleFS_esp32\src\LITTLEFS.cpp: In member function 'virtual bool LITTLEFSImpl::exists(const char*)':
C:\Users\robin\Documents\Arduino\libraries\LittleFS_esp32\src\LITTLEFS.cpp:44:18: error: no matching function for call to 'LITTLEFSImpl::open(const char*&, const char [2])'
   44 |     File f = open(path, "r");
      |              ~~~~^~~~~~~~~~~
In file included from C:\Users\robin\Documents\Arduino\libraries\LittleFS_esp32\src\LITTLEFS.cpp:17:
C:\Users\robin\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.0.1\libraries\FS\src/vfs_api.h:37:15: note: candidate: 'virtual fs::FileImplPtr VFSImpl::open(const char*, const char*, bool)'
   37 |   FileImplPtr open(const char *path, const char *mode, const bool create) override;
      |               ^~~~
C:\Users\robin\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.0.1\libraries\FS\src/vfs_api.h:37:15: note:   candidate expects 3 arguments, 2 provided
Error during build: exit status 1
Thanks
 

candide

Active Member
Licensed User
i didn't change parameter myself, just in Arduino i removed sdk esp32 3.0.2 to install sdk 2.0.17 and i redo the test of examples provided with rLittleFS.

can you run example provided with rLittleFS library ? for me it is OK...
 
Upvote 0

RJB

Active Member
Licensed User
Longtime User
i didn't change parameter myself, just in Arduino i removed sdk esp32 3.0.2 to install sdk 2.0.17 and i redo the test of examples provided with rLittleFS.

can you run example provided with rLittleFS library ? for me it is OK...
I will try this but I noticed that there are two library files. The IDE was listing v1.11 in the library manager so I tried updating to the V1.12 given in the first post of the library discussion. I assume that is the correct one as it has the example in it. However the library manager is still showing V1.11
Before I go further can you confirm that I am using the correct library?
Thanks
 
Upvote 0

RJB

Active Member
Licensed User
Longtime User
To add insult to injury:
The library manager is showing the library with either version and the library is selected. However trying to compile with either version gives the error "Could not find a part of the path 'C:\Program Files (x86)\Anywhere Software\B4R\AdditionalLibraries\rlittlefs'". All three files are there!
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
'C:\Program Files (x86)\Anywhere Software\B4R\AdditionalLibraries\rlittlefs'
This looks strange to me.
Which version of B4R are you using ?
The latest version of B4R is 4.0 and it is a 64 bit version, therefore it should be in 'C:\Program Files\Anywhere Software\B4R\AdditionalLibraries\rlittlefs'
Maybe the path configuration is not OK.
I would also suggest you to change the structure of the AdditionalLibraries to the recommended structure as explained HERE.
 
Upvote 0

RJB

Active Member
Licensed User
Longtime User
Yes B4R 4.0.
Everything was working OK until I updated to the latest Arduino version then all sorts of problems cropped up.
LittleFS was working until I tried updating it. The error does show the path that the files are in and the library is listed in the library manager.
However this all might be the accumulation of changes in setup etc. over the years, so what I will do over the weekend is build a completely new installation on another PC, using the recommendations above.
Fingers crossed!!!!
rLittleFS is the only additional library in this app so if Candide can confirm the correct version then it should be straight forward.
 
Upvote 0

candide

Active Member
Licensed User
rLittleFS v1.12 is the last one. (v1.11 in B4R is an error in xml file)

This one is working well for me with esp32 sdk v3.0.2
tested with ESP32 Dev Module, ESP32C3 Dev Module

what is board used in NOK case ?
 
Upvote 0

RJB

Active Member
Licensed User
Longtime User
By 'the last one' do you mean the one in the first post in https://www.b4x.com/android/forum/threads/rlittlefs-for-b4r.130630/#content labeled v1.12?
I've now set up Arduino and B4R on a laptop which had never had them installed before.
Using the example from the link above I get:
rLittleFS is shown in the B4R Libraries manager
rLittleFS is selected in Libraries manager and is shown as OK in the code window
If I de-select rLittleFS in Libraries manager then the line 'private lfs as LittleFS' shows an error in the code window
with it enabled, compile fails with "Could not find part of the path 'C:\Progam Files\Anywhere Software\Additional Libraries\b4r\rlittlefs'
the additional libraries directory includes files: rLittleFS.cpp, rLittleFS.h and rLittleFS.xml

I'm using ESP32 Dev Module for testing and Arduino IDE version 2.3.2
I've tried with ESP32 boards v1.0.6, v2.0.0 and v3.0.2 in Arduino, all give the error

The physical board I'm testing with is a LillyGo TTGO, which has always worked OK before. If I load it with an older app version via OTA (i.e. one created before upgrading the Arduino IDE etc. ) it works OK.

It's coming up to midnight now and my head hurts so I'm going to bed! I'll try to find and install an older version of the Arduino IDE in the morning to see if that makes any difference.
 
Upvote 0

RJB

Active Member
Licensed User
Longtime User
Thinking about it overnight I didn't see how the Arduino IDE could be causing the not found error.
This morning I tried creating a directory called rLittleFS in the Additional Libraries directory then copying the three files (.h, .cpp, .xml) into it.
The example now compiles and runs - I haven't checked the output but I presume it's OK.

The important point here is that the three files have to be in both the Additional Libraries directory and the Additional Libraries\rLittleFS directory.

It won't work if they are only in one or the other!

Anybody have any thoughts on that?

[8/7/24: see: https://www.b4x.com/android/forum/threads/location-for-rlittlefs-library-files.161995/]
 
Last edited:
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
Just old idea: better for the result if there is a small test project to download and check by any one...
 
Upvote 0

RJB

Active Member
Licensed User
Longtime User
Just using the example file from the download in the first post of: https://www.b4x.com/android/forum/threads/rlittlefs-for-b4r.130630/#content.
Copied here:
B4X:
#Region Project Attributes
    #AutoFlushLogs: True
    #CheckArrayBounds: True
    #StackBufferSize: 600
#End Region
'Ctrl+Click to open the C code folder: ide://run?File=%WINDIR%\System32\explorer.exe&Args=%PROJECT%\Objects\Src

Sub Process_Globals
    Public Serial1 As Serial
    Private wifi As ESP8266WiFi
    Private bc As ByteConverter
'    Private astream As AsyncStreams
    Private lfs As LittleFS
'    Private pinbutton As Pin
    Private task0 As Boolean = False
    Private task1 As Boolean = False
    Private task2 As Boolean = False
    Private task3 As Boolean = False
    Private task4 As Boolean = False
    Private task5 As Boolean = False
    Private task6 As Boolean = False
    Dim str(10) As String
    Dim LF() As Byte = Array As Byte(10)
    
    str(0) = "Hello "
    str(1) ="World "
    str(2) = "I am "
    str(3) = "from "
    str(4) = "France "
    str(5) = "and "
    str(6) = "i like "
    str(7) ="B4X "
    str(8) ="LittleFS "
    str(9) ="exemple "
End Sub

Private Sub AppStart
    Serial1.Initialize(115200)
    Log("AppStart")
    'example of connecting to a local network
    If wifi.Connect2("Livebox-7b06", "7FC5C5CF1EA762DFE469A36349") Then
        Log("Connected to network")
        CallSubPlus("ListCleanWrite_FS",5000,0)
    Else
        Log("Failed to connect to network")
    End If
End Sub


Sub ListCleanWrite_FS(tag As Byte)
    If Not(lfs.Initialize) Then
        Log("LITTLEFS Mount Failed")
    Else
        Log("LITTLEFS Mount OK")
        Log("***ListDIR:")
        listdir("/",7)
        Log("end listdir"):Log(" ")
        
        clean
        Log("end clean"):Log(" ")
        
        write_1
        Log("end write_1"):Log(" ")
        
        Log("***ListDIR:")
        listdir("/",5)
        Log("end phase 1.0"):Log(" ")
    End If
    task0 = True
    CallSubPlus("ReadRemoveList_FS",10000,0)
End Sub
    
Sub ReadRemoveList_FS(tag As Byte)
    read_1
    Log("end read 1"):Log(" ")
    
    remove_1
    Log("end remove 1"):Log(" ")
    
    Log("***ListDIR:")
    listdir("/",5)
    Log("end phase 1.1"):Log(" ")
    task1 = True
    CallSubPlus("MkdirWriteListRemoveRmdirList_FS",10000,0)
End Sub

Sub MkdirWriteListRemoveRmdirList_FS(tag As Byte)
    createDIR_2

    write_2
    
    listdir("/", 1)
    Log("end phase 2.1"):Log(" ")
    
    remove_2

    removeDIR_2

    Log("***ListDIR:")
    listdir("/", 1)
    Log("end phase 2.2"):Log(" ")
    task2 = True
    CallSubPlus("WriteReadRenameReadRemove_FS",10000,0)
End Sub

Sub WriteReadRenameReadRemove_FS(tag As Byte)
    write_3
    Log("end write_3")
    
    append_3
    Log("end append_3")
        
    read_3
    Log("end read_3")
    
    rename_3
    Log("end rename_3")
    
    read2_3
    Log("end read2_3")
        
    remove_3

    Log("***ListDIR:")
    listdir("/",3)
    Log("end remove_3")
    Log("end phase 3"):Log(" ")
    task3=True
    CallSubPlus("WriteUlongReadUlong_FS",10000,0)
End Sub

Sub WriteUlongReadUlong_FS(tag As Byte)
    Log("test Write Ulong in a file")
    
    WriteUlong
    
    ReadUlong
    Log("end write 10000 Ulong")
    task4=True
    CallSubPlus("WriteStringReadString_FS",10000,0)
End Sub

Sub WriteStringReadString_FS(tag As Byte)
    Log("test Read/Check String in a file")

    lfs.Remove("/StringFile.txt")
    
    writeString
    
    readString
    Log("end read/check text sentences")
    task5=True
    CallSubPlus("End_FS",10000,0)
End Sub

Sub End_FS(tag As Byte)
    Log("Test completed" )
    Private task1 As Boolean = False
    Private task2 As Boolean = False
    Private task3 As Boolean = False
    Private task4 As Boolean = False
    Private task5 As Boolean = False
    Private task6 As Boolean = False
End Sub





Sub clean
    remove_1
    remove_2
    removeDIR_2
    remove_3
    lfs.Remove("/new1/new2/new3")
    lfs.RMDir("/new1/new2")
'    lfs.Format
End Sub

Sub write_1
    lfs.OpenReadWrite("/new1/new2/new3/hello3.txt")
    Dim txt() As Byte = "Hello3 a tous"
    lfs.Stream.WriteBytes(txt,0,txt.Length)
    lfs.close
    Log("file hello3.txt created")
End Sub

Sub read_1
    If lfs.Exists("/new1/new2/new3/hello3.txt") Then
        lfs.OpenRead("/new1/new2/new3/hello3.txt")
        Dim txt(lfs.CurrentFile.Size) As Byte
        lfs.Stream.ReadBytes(txt,0,lfs.CurrentFile.Size)
        lfs.close
        Log("file content : ",txt)
    Else
        Log(" file /new1/new2/new3/hello3.txt not created")
    End If
End Sub

Sub remove_1
    If lfs.Exists("/new1/new2/new3/hello3.txt")    Then
        lfs.Remove("/new1/new2/new3/hello3.txt")
        Log("file /new1/new2/new3/hello3.txt removed")
    Else
        Log("file /new1/new2/new3/hello3.txt don't exist")
    End If
End Sub

Sub createDIR_2
    If Not(lfs.Exists("/mydir")) Then
        lfs.MKDir("/mydir")
    Else
        Log("directory /mydir already exists")
    End If
End Sub

Sub write_2
    lfs.OpenReadWrite("/mydir/hello2.txt")
    Dim txt() As Byte = "Hello2"
    lfs.Stream.WriteBytes(txt,0,txt.Length)
    lfs.close
    Log("directory mydir created, file hello3.txt created, file content : ",txt)
End Sub

Sub remove_2
    If lfs.Exists("/mydir/hello2.txt")    Then
        lfs.Remove("/mydir/hello2.txt")
        Log("/mydir/hello2.txt removed")
    Else
        Log("file /mydir/hello2.txt don't exist")
    End If
End Sub

Sub removeDIR_2
    If lfs.exists("/mydir") Then
        lfs.RMDir("/mydir")
        Log("directory mydir removed removed")
    Else
        Log("directory mydir don't exist")
    End If
End Sub

Sub write_3
    lfs.OpenReadWrite("/hello.txt")
    Dim txt() As Byte =JoinStrings(Array As String("Hello! ",CRLF))
    lfs.Stream.WriteBytes(txt,0,txt.Length)
    lfs.Close
End Sub

Sub append_3
    lfs.OpenAppend("/hello.txt")
    Dim txt() As Byte =JoinStrings(Array As String("World!",CRLF))
    lfs.Stream.WriteBytes(txt,0,txt.Length)
    lfs.Close
End Sub

Sub read_3
    If lfs.Exists("/hello.txt") Then
        lfs.OpenRead("/hello.txt")
        Dim txt(lfs.CurrentFile.Size) As Byte
        lfs.Stream.ReadBytes(txt,0,lfs.CurrentFile.Size)
        lfs.close
        Log("text after append : ",txt)
    Else
        Log("file /hello.txt not created")
    End If
End Sub

Sub rename_3
    If lfs.Exists("/hello.txt") Then
        lfs.Rename("/hello.txt", "/foo.txt")
    Else
        Log("file /hello.txt not created before rename")
    End If
End Sub

Sub read2_3
    If lfs.Exists("/foo.txt") Then
        lfs.OpenRead("/foo.txt")
        Dim txt(lfs.CurrentFile.Size) As Byte
        lfs.Stream.ReadBytes(txt,0,lfs.CurrentFile.Size)
        lfs.close
        Log("text after rename : ",txt)
    Else
        Log("file /foo.txt not created before rename")
    End If
End Sub

Sub remove_3
    If lfs.Exists("/foo.txt") Then
        lfs.Remove("/foo.txt")
    Else
        Log("file /foo.txt not created before remove")
    End If
End Sub
    
Sub listdir(path As String, nblevel As Byte)
'    Log("stack: ",StackBufferUsage)
    If nblevel > 6 Then nblevel = 6
    Dim ppath() As Byte
    Dim level() As Byte = DIRlevel(bc.StringToBytes(path))
    For Each f As File In lfs.ListFiles(path)
        If f.isdirectory Then
            If path <> "/" Then
                ppath = JoinBytes(Array(path.getbytes,"/".getbytes,f.name.getbytes))
            Else
                ppath = JoinBytes(Array(path.getbytes,f.name.getbytes))
            End If
            Log(level,"Dir  : ",ppath)
            If nblevel-1>0  Then
                If nblevel > 1 Then listdir(bc.stringfrombytes(ppath),nblevel-1)
            End If
        Else
            Log(level,"Name: ",f.name," - Size: ",f.size)
        End If
    Next
End Sub

Sub DIRlevel(lpath() As Byte) As Byte()
    Dim level As Byte = 0
    If lpath.Length >1 Then lpath = JoinBytes(Array(lpath,"/".getbytes))
    For Each f As Byte In bc.substring(lpath,1)
        If f = 47 Then level = level +1
    Next
    Dim tmp() As Byte = "-   -   -   -   -   -   -   -"
    Return bc.SubString2(tmp,0,(level*4)+1)
End Sub

Sub WriteUlong
    Log("test writebytes Ulong 0<10000")
    If lfs.OpenReadWrite("/Ulongfile.txt") Then
        Dim i As ULong
        For i = 0 To 10000
            writefile(i)
        Next
        lfs.Close
    Else
        Log("error open /Ulongsfile.txt")
    End If
End Sub
Sub writefile(nb As ULong)
    lfs.stream.WriteBytes( bc.ULongsToBytes(Array As ULong(nb)),0,4)
End Sub

Sub ReadUlong
    Log("test readbytes Ulong 0<10000")
    If lfs.Exists("/Ulongfile.txt") Then
        lfs.OpenRead("/Ulongfile.txt")
        Dim i As ULong
        For i = 0 To 10000
            readfile(i)
        Next
        lfs.Close
    End If
End Sub
Sub readfile(nb As ULong)
    Dim buff(4) As Byte : Dim j As UInt
    j =lfs.stream.readBytes(buff,0,4)
    If j = 0 Then
        Log("error readbytes ", nb)
    End If
    If bc.ULongsfromBytes(buff)(0) <> nb Then Log("wrong value at read ",nb)
End Sub

Sub writeString
    Log("test writeString 100 sentences")
    If lfs.OpenReadWrite("/StringFile.txt") Then
        Log(StackBufferUsage)
        RndSeed(Millis)
        For i = 0 To 100
            writestring2(i)
        Next
        Log(StackBufferUsage)
        lfs.Close
    Else
        Log("error open /StringFile.txt")
    End If
End Sub
Sub writestring2(nb As Byte)
    Dim stra() As Byte= JoinStrings(Array As String(nb," ",str(Rnd(0,10)),str(Rnd(0,10)),str(Rnd(0,10)),str(Rnd(0,10)),str(Rnd(0,10)),str(Rnd(0,10)),str(Rnd(0,10)),".",CRLF))
    lfs.stream.WriteBytes(stra,0,stra.Length)
End Sub

Sub readString
    Log("test readStrings 100 sentences")
    Dim buff(256) As Byte : Dim Rbuff As UInt:Dim Lbuff As UInt:Dim NBstay As UInt = 0
    If lfs.Exists("/StringFile.txt") Then
        lfs.OpenRead("/StringFile.txt")
        Log("start - bytesavailable",lfs.Stream.BytesAvailable)
        Do While lfs.Stream.BytesAvailable > 0
            Log(" "):Log(" bytesavailable ",lfs.Stream.BytesAvailable)
            Rbuff =NBstay+ lfs.Stream.ReadBytes(buff,NBstay,Min(256-NBstay,lfs.Stream.BytesAvailable))
            If Rbuff = 256 Then
                Lbuff = bc.LastIndexOf(buff,CRLF)
            Else
                Lbuff = Rbuff-2
            End If
            Log(" bytesavailable",lfs.Stream.BytesAvailable)
            NBstay = Rbuff-Lbuff-2
            Log("lbuff: ",Lbuff, " Rbuff: ",Rbuff," NBstay: ",NBstay):Log(" ")
            readString2(bc.SubString2(buff,0,Lbuff+2))
            If NBstay >0 Then
                bc.ArrayCopy2(buff,Lbuff+2,buff,0,NBstay)
            End If
            
        Loop  'Next
        lfs.Close
    Else
        Log("error open /StringFile.txt")
    End If
End Sub
Sub readString2(buff() As Byte)
    For Each s() As Byte In bc.Split(buff, LF)
        If s.Length <> 0 Then
            Log(s)
        End If
    Next
End Sub
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
rLittleFS.1.12.zip
6.2 KB · Views: 283

This file name is 1.12, but lib version is 1.11 in the .xml file inside.
Compilation is OK for ESP8266, selfreboot is here, the log is:

 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User

But it does not hung with ESP32. (E (5017) esp_littlefs: Failed to initialize LittleFS).



If to restart MCU we have all is OK:

 
Last edited:
Upvote 0

RJB

Active Member
Licensed User
Longtime User
Finally!
I had updated the Arduino IDE from V1.x.x to V2.x.x and the Arduino ESP32 board from V1.x.x to V3.x.x
In this circumstance LITTLEFS goes from being an addition library to being built in.
It therefore has to be removed with the libraries manager in Arduino.
It also means that, if you have any inline-C references to LITTLEFS, they have to be changed to LittleFS, i.e. no longer all uppercase.
ref.: https://github.com/lorol/LITTLEFS
Hope that helps others avoid the wasted hours I've spent!
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…