Continuing the discussion from Reading SD Card with ESP32 Troubles:
Hi,
with my ESP32, I noticed that SD cards were often no longer readable after updates were installed via httpupdate.
I use this function, which at least closes any open file with close() BEFORE starting the update.
void update_firmware() {
updateMeasuring(false); // In this function currently running measuring is finished and the file is closed via file.close();
WiFiClientSecure client;
client.setInsecure();
t_httpUpdate_return ret = httpUpdate.update(client, link_to_firmware_file);
switch (ret) {
case HTTP_UPDATE_FAILED:
Serial.printf("HTTP_UPDATE_FAILED Error (%d): %s\n", httpUpdate.getLastError(), httpUpdate.getLastErrorString().c_str());
break;
case HTTP_UPDATE_NO_UPDATES:
Serial.println("HTTP_UPDATE_NO_UPDATES");
break;
case HTTP_UPDATE_OK:
Serial.println("OK");
const char * httpType PROGMEM = "text/html";
server.send_P(200, httpType, settingPage);
break;
}
}
Does this ensure that everything should run correctly again after the restart (sd.begin() in void setup)? Or would I have to add an SD.end()?
Or what exactly do you mean by "effectivly powering it down, in order to get it to work again"?