diff --git a/sonoff/_changelog.ino b/sonoff/_changelog.ino index a07a74af0..226fdcec1 100644 --- a/sonoff/_changelog.ino +++ b/sonoff/_changelog.ino @@ -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 diff --git a/sonoff/settings.ino b/sonoff/settings.ino index 38e9bb3f3..d683eee79 100644 --- a/sonoff/settings.ino +++ b/sonoff/settings.ino @@ -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 diff --git a/sonoff/sonoff.ino b/sonoff/sonoff.ino index 4263ffa48..d8d6cba1d 100755 --- a/sonoff/sonoff.ino +++ b/sonoff/sonoff.ino @@ -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, "%")) {