B4R Library rESP8266FileSystem (SPIFFS)

Discussion in 'B4R Libraries' started by Erel, Feb 22, 2017.

  1. Erel

    Erel Administrator Staff Member Licensed User

    ESP8266 comes with built-in file system provisioned on the chip flash. The file system is useful for storing persistent information.

    The size available varies but on most devices it is more than 1mb. See the table here: https://github.com/esp8266/Arduino/blob/master/doc/filesystem.rst

    rESP8266FileSystem API is almost identical to rSD API: https://www.b4x.com/android/forum/threads/sd-cards.65994/#content

    A modified version of the file transfer example is attached.
    You need to run the B4J program and the B4R program.
    It supports uploading and downloading files.

    The file system has some limitations, see this link for more information: https://github.com/esp8266/Arduino/blob/master/doc/filesystem.rst#file-system-limitations

    Updates

    This library is now an internal library.
    V1.10 adds support for ESP32 boards.
    You need to add this line to the main module when compiling to ESP32:
    Code:
    #DefineExtra: #define SKIP_B4RNEW
     

    Attached Files:

    Last edited: Jul 19, 2018
  2. max123

    max123 Active Member Licensed User

    Last edited: Jun 20, 2017
    Erel likes this.
  3. Erel

    Erel Administrator Staff Member Licensed User

    I've updated the links.
     
    max123 and maXim like this.
  4. max123

    max123 Active Member Licensed User

    I've tried this but without success on my NodeMCU.

    I compile OK, but when I press "List File" button on B4J app, ESP start to list all flash files and then crashes...
    I've encountered many times this error using Arduino IDE, usually putting a yield() within a long loop prevent a watchdog timer to overflow and
    solves the problem.To speed up the execution, yield() can be called not all times, but just every tot time, in C++ eg. like this:

    Code:
    if ((count % 1000) == 0) yield();
    What is equivalent to yield() on B4R? I can use Delay(0)?

    I attached my log:
     
    Last edited: Jun 20, 2017
  5. Erel

    Erel Administrator Staff Member Licensed User

    My guess is that you are overflowing the stack buffer.

    Increase #StackBufferUsage (start with 2000).
     
    Last edited: Jun 20, 2017
  6. max123

    max123 Active Member Licensed User

    Yes, Bingo! ;)

    It works without need of WDT reset, just increased the StackBufferSize to 2000 bytes

    But now I've a new problem, I count files with this code, it count 118 files and this is ok, but the log show a strange result as count of files...
    See on the log a number inside a first square bracket, as you can see strange results. I use a local UInt variable to count all files, if I declare fileCount as Global do not work at all.

    This is the code:
    Code:
    Sub ListFiles
        
    Dim fileCount As UInt = 0
        
    For Each f As File In fs.ListFiles("/")
            fileCount = fileCount + 
    1
            
    Log("[", fileCount, "]   [ ", f.Name, " ]    ", f.Size, " bytes     StackBufferUsage: ", StackBufferUsage)
            astream.Write(f.Name).Write(
    Array As Byte(10))
        
    Next
        astream.Write(
    Array As Byte(0xff0xff0xff))
    End Sub
    This is my log:
     
  7. Erel

    Erel Administrator Staff Member Licensed User

    Please start a new thread for this in the questions forum.
     
  8. max123

    max123 Active Member Licensed User

  9. Johan Hormaza

    Johan Hormaza Active Member Licensed User

    @Erel and to create a new file that can fill, how would it be?
    Thank you
     
  10. Erel

    Erel Administrator Staff Member Licensed User

    Please start a new thread in the questions forum and make sure not to limit your questions to a single member.
     
    Johan Hormaza likes this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice