esp32otaarduino-esp32

ESP32 OTA update including data folder in bin firmware


I saw there are few libs and tutorial about esp32 OTA update but as far as I saw this is working only for the code and not for the data folder. In my case I have a web server which store all html, css, js etc under "data" folder. Is there any way to have OTA update including these files as well?

Thanks


Solution

  • There are two tools that you can use from the command line to do what you're asking.

    First you'll need to make a binary file containing an image of the filesystem - you can't update individual files, you'll have to overwrite the entire filesystem, which means you'll lose any data your program might have stored there.

    Then you'll need to do an OTA update of the filesystem.

    To make the binary file you'll use spiffsgen.py. You can download it from here. You'll need a working copy of Python on your computer to use it:

    python3 spiffsgen.py 409600 data filesystem.bin
    

    You should replace

    The maximum size of the binary file will depend on the the partition scheme you choose for your ESP32's flash storage; obviously the minimum must be large enough to hold the files you want to copy.

    Once you've generated the filesystem you can upload it via OTA using espota.py. The same tool can upload firmware or filesystem images, and works with

    python3 espota.py -s -r -f .pio/build/lolin32/spiffs.bin -I ip-address -p 3232
    

    Your application will need to use the ArduinoOTA library in order to support this. The library has built-in support for filesystem updates; your Arduino code doesn't need to do anything special to support it.