How to access the SPIFFS

Issue #178 resolved
connochaetes created an issue

Hello.

Is it possible to write to the “serial peripheral interface flash file system” (SPIFFS) via Microblocks?


I am using a Citilab ED1. I am able to write to my board’s SPIFFS using “curl” (BMPs for the display, WAVs for the speaker). By writing to the SPIFFS via Microblocks, I would be able to create a power loss proof data collection device.

I know that I am able to open an existing Microblocks script directly from my board. But in my experience this feature doesn’t save a variable’s value.

Any help would be welcome.

Comments (6)

  1. John Maloney repo owner

    The “Files” library in the “Other” folder allows you to read and write files on ESP devices.

    The latest version of MicroBlocks (v1.0.9) also allows you to transfer files to/from the filesystem on ESP boards including the Citilab ED1. Your ESP board must have firmware v106 or later.

    Since this feature is new still “alpha”, you need to enable “show advanced blocks” to use it. Then, with your ESP board connected, you will find two new commands in the file menu:

    put file on board
    get file from board
    

    Note that putting large files to the board is slow (due to slow write times for the serial Flash chip) and there is not yet any sort of progress indicator so you just need to be patient. Getting files from the board is faster, although still much slower than a USB memory stick.

  2. connochaetes reporter

    Having a block for this feature would be great. (I just read this description of one of Snap!'s libraries: "Eisenberg's Law: Anything that can be done from the GUI should be doable from the programming language, and vice versa.") Is this kind of thing intended? - Greetings & thanks for your work.

  3. John Maloney repo owner

    I’m not sure exactly what block(s) you are suggesting.

    Since the file transfers must be initiated from the IDE but the block code runs on the board (which might not even be connected to the IDE), it doesn’t make sense to have blocks that initiate file transfer with the IDE.

    Some other ideas:

    If you have a WiFi enabled board, you might write a MicroBlocks library to upload files to a server, perhaps using WebDAV or sftp. (We have no plans to do that, but it might be a fun project for someone.)

    Another option would be to write a Snap! program do file transfers with the board. The file transfer protocol is documented here:

    https://bitbucket.org/john_maloney/smallvm/src/master/misc/SERIAL_PROTOCOL.md

    But maybe you have something else in mind?

  4. connochaetes reporter

    As you guessed right, my thought was of the kind of a general wondering (thinking out loudly, in german “herumspinnen”). “What would be, IF the microcontroller would be connected via USB to a notebook?” So, thank you for answering friendly.


    At this moment, the ESP32 board is using the “http block” in order to read/write the data. On the other end, there’s webspace with a (small) PHP script - just capable to manage reading and writing. Obviously, you are able to read/write via “Snap!” from a notebook, too.

    I was just looking for inspiration on this topic. So, again: Thank you.

  5. Log in to comment