-->
Page 1 of 1

problem with flashing firmware from SPIFFS

PostPosted: Wed Mar 28, 2018 2:45 am
by PatrykW
Hello everyone.
I wrote myself a function to flash a firmware image stored in SPIFFS, but for some reason it doesn't work properly. I'd appreciate if someone could take a look at it ;)
Code: Select allbool flashFirmware2() {
  digitalWrite(LED, LOW);
  File f = SPIFFS.open("/firmware.bin", "r");
  if(!f){
    Serial.println("[update] can't open the file");
    digitalWrite(LED, HIGH);
    return false;
  }
  Serial.println("[update] file opened");
  if( ESP.updateSketch(f, f.size(), false, false) ){
    Serial.println("[update] firmware written to flash");
  }else{
    Serial.println("[update] ERROR writing to flash");
    f.close();
    return false;
  }
  f.close();
  digitalWrite(LED, HIGH);
  return true;
}

When I call it, everything looks OK in the serial monitor, but the ESP doesn't work after reset.
The firmware in SPIFFS is obviously tested. Works just fine when flashed over serial port.
Any ideas what could be the problem here?

Re: problem with flashing firmware from SPIFFS

PostPosted: Sun Apr 22, 2018 1:40 am
by lapgoch
Hi.

Not sure but it looks like the ESP.updateSketch is used when updating with OTA.