Page 2 of 2

Re: OTA update spiffs

Posted: Sat Apr 16, 2022 2:27 pm
by mbratch
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.

Re: OTA update spiffs

Posted: Thu Jan 09, 2025 1:15 am
by chegewara
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.
I know it is veeeery old topic and old question, but the solution for it is very simple.
The part of web page responsible for spiffs update can be static code included in firmware instead of in spiffs.
In that case when spiffs update fails for some reason you still have working part responsible for update spiffs.

Re: OTA update spiffs

Posted: Sun Jan 12, 2025 1:10 am
by mbratch
I know it is veeeery old topic and old question, but the solution for it is very simple.
The part of web page responsible for spiffs update can be static code included in firmware instead of in spiffs.
In that case when spiffs update fails for some reason you still have working part responsible for update spiffs.
Thanks. I worked out a solution for my scenario which I am quite happy with. I documented it in another thread.