OTA update spiffs

User avatar
mbratch
Posts: 303
Joined: Fri Jun 11, 2021 1:51 pm

Re: OTA update spiffs

Postby mbratch » Sat Apr 16, 2022 2:27 pm

loboris wrote:
Wed Nov 29, 2017 8:33 am
chegewara wrote:Is there some way to OTA update spiffs partition?
Of course, it should be quite simple.
Use the OTA example as the base and esp_partition API to erase/write the partition.
- Put your spiffs image file on some http server.
- First find your spiffs partition using esp_partition_find(), get the start address and size.
- Erase the whole partition using esp_partition_erase_range().
- Download the chunks of spiffs image file and write to the partition using esp_partition_write().
- You can optionally use md5 checksum file to validate the written data (use md5 API and esp_partition_read().
I'm thinking about the case where my SPIFFS is an internal web page that interfaces to the application using a REST API. In this case, there is a functional dependency between the application and the SPIFFS image.

if I have a failure after I update the SPIFFS (e.g., something is wrong with the SPIFFs image, or something else is wrong with the OTA update) then I have no way to roll back to the old SPIFFS content. It seems I would need to do the SPIFFS update after I have verified the rest of my OTA update and then take my chances that the one and only SPIFFS partition update is successful.

Alternatively, I guess I could have two SPIFFS partitions, e.g., named "www_1" and "www_2", and then, in the code that uses the SPIFFS partition, access the SPIFFS partition that corresponds to the ota partition I booted from.

Who is online

Users browsing this forum: axellin and 123 guests