Chat freely about anything...

User avatar
By PatrykW
#74953 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?