-->
Page 2 of 3

Re: OTA erases SPIFFS?

PostPosted: Mon Aug 13, 2018 12:32 pm
by picstart
So far my projects using OTA have worked. Now OTA consumes CPU cycles and the OTA handle must be called frequently so watch out for delay(xx) statements and any other code that might be blocking OTA and not giving OTA the cycles it needs. I'm unsure what might happen if the OTA is starved it should just fail or freeze during the upload but potentially your Spiffs is active and it gets impacted. Often you wrap a long delay(xx) as many smaller ones with a call to OTA before each small delay.

Re: OTA erases SPIFFS?

PostPosted: Mon Aug 13, 2018 5:38 pm
by JimDrew
My code is about as simple as it gets. There are no "delays" required. You just call the update command with a path to the new firmware to flash and it returns with an error or success. This has worked perfectly for a couple of years, but I have never had a SPIFFS setup before.

Code: Select all#include <ESP8266httpUpdate.h>

  t_httpUpdate_return ret = ESPhttpUpdate.update("http://www.urlpath.com/subpath/update.bin");

  switch (ret) {
    case HTTP_UPDATE_FAILED:
      Serial.printf("Update failed! - %s", ESPhttpUpdate.getLastErrorString().c_str());
      Serial.println();
      break;

    case HTTP_UPDATE_NO_UPDATES:
      Serial.println("Latest firmware is already installed!");
      Serial.println();
      break;

    case HTTP_UPDATE_OK:
      Serial.println("Update complete - rebooting!");
      Serial.println();
      delay(2000);
      ESP.Restart();
      break;
  }
}


Is there a known problem using a 3M SPIFFS partition? I am going to try a 1M partition (which is not big enough for my application) to see if that somehow works. Maybe there is bug that wipes out the 1st 2M or something?

Re: OTA erases SPIFFS?

PostPosted: Tue Aug 14, 2018 3:19 am
by btidey
I've used 1M, 2M, 3M SPIFFS and OTA without issue.

I use the browser OTA method rather than the ESPhttpUpdate.update method so there may be some difference there.

Re: OTA erases SPIFFS?

PostPosted: Tue Aug 14, 2018 6:54 pm
by JimDrew
What is the "browser" method?