build: clean up the mess of ifdefs from platform into a scons-configured hal
This commit is contained in:
@@ -3,10 +3,6 @@
|
||||
|
||||
#include <EEPROM.h>
|
||||
|
||||
#ifdef BOARD_ESP8266
|
||||
#include <ESP8266WiFi.h>
|
||||
#endif
|
||||
|
||||
#ifdef PLATFORM_PHOTON
|
||||
LEDStatus serialStatus = LEDStatus(RGB_COLOR_ORANGE, LED_PATTERN_FADE, LED_SPEED_FAST, LED_PRIORITY_BACKGROUND);
|
||||
LEDStatus configStatus = LEDStatus(RGB_COLOR_YELLOW, LED_PATTERN_FADE, LED_SPEED_NORMAL, LED_PRIORITY_IMPORTANT);
|
||||
@@ -14,21 +10,6 @@ retained bool LAST_BOOT_WAS_FLASH;
|
||||
retained bool LAST_BOOT_WAS_SERIAL;
|
||||
#endif
|
||||
|
||||
#ifndef __NOINIT_ATTR // Pre-defined on esp32
|
||||
#define __NOINIT_ATTR __attribute__ ((section (".noinit")))
|
||||
#endif
|
||||
|
||||
#define SAFE_MODE_MAGIC 6942
|
||||
|
||||
__NOINIT_ATTR uint8_t s_rebootCount;
|
||||
__NOINIT_ATTR uint16_t s_forceSafeMode;
|
||||
|
||||
void
|
||||
BootOptions::forceSafeMode()
|
||||
{
|
||||
s_forceSafeMode = SAFE_MODE_MAGIC;
|
||||
}
|
||||
|
||||
void
|
||||
BootOptions::initPins()
|
||||
{
|
||||
@@ -53,40 +34,7 @@ BootOptions::BootOptions()
|
||||
configStatus.setActive(isSetup);
|
||||
serialStatus.setActive(isSerial);
|
||||
#endif
|
||||
#ifdef BOARD_ESP32
|
||||
resetReason = esp_reset_reason();
|
||||
crashCount = s_rebootCount;
|
||||
if (resetReason >= 4) { // TODO: These values are defined in
|
||||
// esp32/rom/rtc.h, but not sure if that's included
|
||||
// on platformio builds
|
||||
if (crashCount++ >= 3) {
|
||||
// Boot into safe mode if the watchdog reset us three times in a row.
|
||||
isSafeMode = true;
|
||||
}
|
||||
} else {
|
||||
crashCount = 0;
|
||||
}
|
||||
s_rebootCount = crashCount;
|
||||
#endif
|
||||
#ifdef BOARD_ESP8266
|
||||
struct rst_info resetInfo = *ESP.getResetInfoPtr();
|
||||
resetReason = resetInfo.reason;
|
||||
crashCount = s_rebootCount;
|
||||
if (resetInfo.reason == REASON_SOFT_WDT_RST || resetInfo.reason == REASON_WDT_RST || resetInfo.reason == REASON_EXCEPTION_RST) {
|
||||
if (crashCount++ >= 3) {
|
||||
// Boot into safe mode if the watchdog reset us three times in a row.
|
||||
isSafeMode = true;
|
||||
}
|
||||
} else {
|
||||
crashCount = 0;
|
||||
}
|
||||
s_rebootCount = crashCount;
|
||||
|
||||
if (resetInfo.reason > 0 && s_forceSafeMode == SAFE_MODE_MAGIC) {
|
||||
isSafeMode = true;
|
||||
s_forceSafeMode = 0;
|
||||
}
|
||||
#endif
|
||||
PlatformImpl<>::initBootOptions(*this);
|
||||
}
|
||||
|
||||
void
|
||||
|
Reference in New Issue
Block a user