Delay initial flash write

* Stop enforcing flashmode dout but it is still mandatory
 * Moved bootcount update (being first) flash write to 10 seconds after restart
This commit is contained in:
Theo Arends 2018-11-16 09:36:41 +01:00
parent a1ff029335
commit 9eacabc4f0
3 changed files with 11 additions and 8 deletions

View File

@ -1,5 +1,6 @@
/* 6.3.0.8 20181115
* Stop enforcing flashmode dout. Still mandatory but this a chk for possible future flash corruption
* Stop enforcing flashmode dout but it is still mandatory
* Moved bootcount update (being first) flash write to 10 seconds after restart
*
* 6.3.0.7 20181111
* Fix wifi connection errors using wifi disconnect and ESP.reset instead of ESP.restart

View File

@ -334,6 +334,7 @@ void SettingsErase(uint8_t type)
1 = Erase SDK parameter area at end of linker memory model (0x0FDxxx - 0x0FFFFF) solving possible wifi errors
*/
#ifndef BE_MINIMAL
bool result;
uint32_t _sectorStart = (ESP.getSketchSize() / SPI_FLASH_SEC_SIZE) + 1;
@ -362,6 +363,7 @@ void SettingsErase(uint8_t type)
}
OsWatchLoop();
}
#endif // BE_MINIMAL
}
// Copied from 2.4.0 as 2.3.0 is incomplete

View File

@ -1652,6 +1652,10 @@ void PerformEverySecond(void)
if (BOOT_LOOP_TIME == uptime) {
RtcReboot.fast_reboot_count = 0;
RtcRebootSave();
Settings.bootcount++; // Moved to here to stop flash writes during start-up
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_APPLICATION D_BOOT_COUNT " %d"), Settings.bootcount);
AddLog(LOG_LEVEL_DEBUG);
}
if ((4 == uptime) && (SONOFF_IFAN02 == Settings.module)) { // Microcontroller needs 3 seconds before accepting commands
@ -2635,13 +2639,13 @@ void setup(void)
mdns_delayed_start = Settings.param[P_MDNS_DELAYED_START];
seriallog_level = Settings.seriallog_level;
seriallog_timer = SERIALLOG_TIMER;
#ifndef USE_EMULATION
Settings.flag2.emulation = 0;
#endif // USE_EMULATION
syslog_level = Settings.syslog_level;
stop_flash_rotate = Settings.flag.stop_flash_rotate;
save_data_counter = Settings.save_data;
sleep = Settings.sleep;
#ifndef USE_EMULATION
Settings.flag2.emulation = 0;
#endif // USE_EMULATION
// Disable functionality as possible cause of fast restart within BOOT_LOOP_TIME seconds (Exception, WDT or restarts)
if (RtcReboot.fast_reboot_count > 1) { // Restart twice
@ -2667,10 +2671,6 @@ void setup(void)
AddLog(LOG_LEVEL_DEBUG);
}
Settings.bootcount++;
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_APPLICATION D_BOOT_COUNT " %d"), Settings.bootcount);
AddLog(LOG_LEVEL_DEBUG);
Format(mqtt_client, Settings.mqtt_client, sizeof(mqtt_client));
Format(mqtt_topic, Settings.mqtt_topic, sizeof(mqtt_topic));
if (strstr(Settings.hostname, "%")) {