Revert "6.1.1.14 Add boot loop detection"

This reverts commit b9a875d6fb.
This commit is contained in:
Theo Arends 2018-08-30 13:19:09 +02:00
parent b9a875d6fb
commit 3abdaaffb7
9 changed files with 13 additions and 53 deletions

View File

@ -1,7 +1,4 @@
/* 6.1.1.14 20180830 /* 6.1.1.13 20180828
* Add boot loop detection and try to fix
*
* 6.1.1.13 20180828
* Fix 6.1.1.12 regression of Mem and Var default handling (#3618) * Fix 6.1.1.12 regression of Mem and Var default handling (#3618)
* Optimizations * Optimizations
* Change define USE_ALL_SENSORS to USE_SENSORS as it doesn't contain all sensors due to duplicate I2C addresses * Change define USE_ALL_SENSORS to USE_SENSORS as it doesn't contain all sensors due to duplicate I2C addresses

View File

@ -236,7 +236,6 @@
#define D_CMND_SERIALSEND "SerialSend" #define D_CMND_SERIALSEND "SerialSend"
#define D_CMND_SERIALDELIMITER "SerialDelimiter" #define D_CMND_SERIALDELIMITER "SerialDelimiter"
#define D_CMND_BAUDRATE "Baudrate" #define D_CMND_BAUDRATE "Baudrate"
#define D_LOG_SOME_SETTINGS_RESET "Some settings have been reset"
// Commands xdrv_01_mqtt.ino // Commands xdrv_01_mqtt.ino
#define D_CMND_MQTTHOST "MqttHost" #define D_CMND_MQTTHOST "MqttHost"

View File

@ -94,7 +94,7 @@ typedef union { // Restricted by MISRA-C Rule 18.4 bu
uint32_t spare28 : 1; uint32_t spare28 : 1;
uint32_t spare29 : 1; uint32_t spare29 : 1;
uint32_t spare30 : 1; uint32_t spare30 : 1;
uint32_t user_esp8285_enable : 1; // bit 31 (v6.1.1.13) uint32_t spare31 : 1;
}; };
} SysBitfield3; } SysBitfield3;
@ -341,9 +341,7 @@ struct RTCMEM {
unsigned long energy_kWhtotal; // 008 unsigned long energy_kWhtotal; // 008
unsigned long pulse_counter[MAX_COUNTERS]; // 00C unsigned long pulse_counter[MAX_COUNTERS]; // 00C
power_t power; // 01C power_t power; // 01C
uint8_t fast_reboot_count; // 020 // 020 next free location
uint8_t spare_021[3]; // 021
// 024 next free location
} RtcSettings; } RtcSettings;
struct TIME_T { struct TIME_T {

View File

@ -85,7 +85,6 @@ typedef unsigned long power_t; // Power (Relay) type
#define STATES 20 // Number of states per second using 50 mSec interval #define STATES 20 // Number of states per second using 50 mSec interval
#define IMMINENT_RESET_FACTOR 10 // Factor to extent button hold time for imminent Reset to default 40 seconds using KEY_HOLD_TIME of 40 #define IMMINENT_RESET_FACTOR 10 // Factor to extent button hold time for imminent Reset to default 40 seconds using KEY_HOLD_TIME of 40
#define BOOT_LOOP_TIME 10 // Number of seconds to stop detecting boot loops
#define SYSLOG_TIMER 600 // Seconds to restore syslog_level #define SYSLOG_TIMER 600 // Seconds to restore syslog_level
#define SERIALLOG_TIMER 600 // Seconds to disable SerialLog #define SERIALLOG_TIMER 600 // Seconds to disable SerialLog
#define OTA_ATTEMPTS 5 // Number of times to try fetching the new firmware #define OTA_ATTEMPTS 5 // Number of times to try fetching the new firmware

View File

@ -1567,11 +1567,6 @@ void PerformEverySecond()
{ {
uptime++; uptime++;
if (BOOT_LOOP_TIME == uptime) {
RtcSettings.fast_reboot_count = 0;
RtcSettingsSave();
}
if ((4 == uptime) && (SONOFF_IFAN02 == Settings.module)) { // Microcontroller needs 3 seconds before accepting commands if ((4 == uptime) && (SONOFF_IFAN02 == Settings.module)) { // Microcontroller needs 3 seconds before accepting commands
SetDevicePower(1, SRC_RETRY); // Sync with default power on state microcontroller being Light ON and Fan OFF SetDevicePower(1, SRC_RETRY); // Sync with default power on state microcontroller being Light ON and Fan OFF
SetDevicePower(power, SRC_RETRY); // Set required power on state SetDevicePower(power, SRC_RETRY); // Set required power on state
@ -2318,7 +2313,7 @@ void GpioInit()
pin[i] = 99; pin[i] = 99;
} }
for (byte i = 0; i < MAX_GPIO_PIN; i++) { for (byte i = 0; i < MAX_GPIO_PIN; i++) {
mpin = ValidGPIO(i, my_module.gp.io[i]); mpin = my_module.gp.io[i];
// snprintf_P(log_data, sizeof(log_data), PSTR("DBG: gpio pin %d, mpin %d"), i, mpin); // snprintf_P(log_data, sizeof(log_data), PSTR("DBG: gpio pin %d, mpin %d"), i, mpin);
// AddLog(LOG_LEVEL_DEBUG); // AddLog(LOG_LEVEL_DEBUG);
@ -2328,7 +2323,7 @@ void GpioInit()
bitSet(switch_no_pullup, mpin - GPIO_SWT1_NP); bitSet(switch_no_pullup, mpin - GPIO_SWT1_NP);
mpin -= (GPIO_SWT1_NP - GPIO_SWT1); mpin -= (GPIO_SWT1_NP - GPIO_SWT1);
} }
else if ((mpin >= GPIO_KEY1_NP) && (mpin < (GPIO_KEY1_NP + MAX_KEYS))) { if ((mpin >= GPIO_KEY1_NP) && (mpin < (GPIO_KEY1_NP + MAX_KEYS))) {
bitSet(key_no_pullup, mpin - GPIO_KEY1_NP); bitSet(key_no_pullup, mpin - GPIO_KEY1_NP);
mpin -= (GPIO_KEY1_NP - GPIO_KEY1); mpin -= (GPIO_KEY1_NP - GPIO_KEY1);
} }
@ -2491,10 +2486,6 @@ void setup()
{ {
byte idx; byte idx;
RtcSettingsLoad();
RtcSettings.fast_reboot_count++;
RtcSettingsSave();
Serial.begin(baudrate); Serial.begin(baudrate);
delay(10); delay(10);
Serial.println(); Serial.println();
@ -2526,26 +2517,11 @@ void setup()
save_data_counter = Settings.save_data; save_data_counter = Settings.save_data;
sleep = Settings.sleep; sleep = Settings.sleep;
// Disable functionality as possible cause of fast reboot within BOOT_LOOP_TIME seconds (Exception or WDT) if ((resetInfo.reason == REASON_WDT_RST) || (resetInfo.reason == REASON_EXCEPTION_RST) || (resetInfo.reason == REASON_SOFT_WDT_RST) || OsWatchBlockedLoop()) {
if (RtcSettings.fast_reboot_count > 1) { // Restart twice
Settings.flag3.user_esp8285_enable = 0; // Disable ESP8285 Generic GPIOs interfering with flash SPI
if (RtcSettings.fast_reboot_count > 2) { // Restart 3 times
for (byte i = 0; i < MAX_RULE_SETS; i++) { for (byte i = 0; i < MAX_RULE_SETS; i++) {
if (bitRead(Settings.rule_stop, i)) { if (bitRead(Settings.rule_stop, i)) { bitWrite(Settings.rule_enabled, i, 0); }
bitWrite(Settings.rule_enabled, i, 0); // Disable rules causing boot loop
} }
} }
}
if (RtcSettings.fast_reboot_count > 3) { // Restarted 4 times
Settings.rule_enabled = 0; // Disable all rules
}
if (RtcSettings.fast_reboot_count > 4) { // Restarted 5 times
Settings.module = SONOFF_BASIC; // Use default module
Settings.last_module = SONOFF_BASIC; // Use default module
}
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_APPLICATION D_LOG_SOME_SETTINGS_RESET " (%d)"), RtcSettings.fast_reboot_count);
AddLog(LOG_LEVEL_DEBUG);
}
Settings.bootcount++; Settings.bootcount++;
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_APPLICATION D_BOOT_COUNT " %d"), Settings.bootcount); snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_APPLICATION D_BOOT_COUNT " %d"), Settings.bootcount);

View File

@ -20,7 +20,7 @@
#ifndef _SONOFF_VERSION_H_ #ifndef _SONOFF_VERSION_H_
#define _SONOFF_VERSION_H_ #define _SONOFF_VERSION_H_
#define VERSION 0x0601010E #define VERSION 0x0601010D
#define D_PROGRAMNAME "Sonoff-Tasmota" #define D_PROGRAMNAME "Sonoff-Tasmota"
#define D_AUTHOR "Theo Arends" #define D_AUTHOR "Theo Arends"

View File

@ -717,15 +717,6 @@ void ShowSource(int source)
} }
} }
uint8_t ValidGPIO(uint8_t pin, uint8_t gpio)
{
uint8_t result = gpio;
if ((WEMOS == Settings.module) && (!Settings.flag3.user_esp8285_enable)) {
if ((pin == 9) || (pin == 10)) { result = GPIO_NONE; } // Disable possible flash GPIO9 and GPIO10
}
return result;
}
/*********************************************************************************************\ /*********************************************************************************************\
* Sleep aware time scheduler functions borrowed from ESPEasy * Sleep aware time scheduler functions borrowed from ESPEasy
\*********************************************************************************************/ \*********************************************************************************************/

View File

@ -789,7 +789,7 @@ void HandleModuleConfiguration()
page += FPSTR(HTTP_SCRIPT_MODULE3); page += FPSTR(HTTP_SCRIPT_MODULE3);
for (byte i = 0; i < MAX_GPIO_PIN; i++) { for (byte i = 0; i < MAX_GPIO_PIN; i++) {
if (GPIO_USER == ValidGPIO(i, cmodule.gp.io[i])) { if (GPIO_USER == cmodule.gp.io[i]) {
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("sk(%d,%d);"), my_module.gp.io[i], i); // g0 - g16 snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("sk(%d,%d);"), my_module.gp.io[i], i); // g0 - g16
page += mqtt_data; page += mqtt_data;
} }
@ -803,10 +803,10 @@ void HandleModuleConfiguration()
page.replace(F("{mt"), stemp); page.replace(F("{mt"), stemp);
page += F("<br/><table>"); page += F("<br/><table>");
for (byte i = 0; i < MAX_GPIO_PIN; i++) { for (byte i = 0; i < MAX_GPIO_PIN; i++) {
if (GPIO_USER == ValidGPIO(i, cmodule.gp.io[i])) { if (GPIO_USER == cmodule.gp.io[i]) {
snprintf_P(stemp, 3, PINS_WEMOS +i*2); snprintf_P(stemp, 3, PINS_WEMOS +i*2);
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("<tr><td style='width:190px'>%s <b>" D_GPIO "%d</b> %s</td><td style='width:146px'><select id='g%d' name='g%d'></select></td></tr>"), snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("<tr><td style='width:190px'>%s <b>" D_GPIO "%d</b> %s</td><td style='width:146px'><select id='g%d' name='g%d'></select></td></tr>"),
(WEMOS==Settings.module)?stemp:"", i, (0==i)? D_SENSOR_BUTTON "1":(1==i)? D_SERIAL_OUT :(3==i)? D_SERIAL_IN :(9==i)? "<font color='red'>ESP8285</font>" :(10==i)? "<font color='red'>ESP8285</font>" :(12==i)? D_SENSOR_RELAY "1":(13==i)? D_SENSOR_LED "1i":(14==i)? D_SENSOR :"", i, i); (WEMOS==Settings.module)?stemp:"", i, (0==i)? D_SENSOR_BUTTON "1":(1==i)? D_SERIAL_OUT :(3==i)? D_SERIAL_IN :(12==i)? D_SENSOR_RELAY "1":(13==i)? D_SENSOR_LED "1i":(14==i)? D_SENSOR :"", i, i);
page += mqtt_data; page += mqtt_data;
} }
} }