@@ -743,8 +743,8 @@ static volatile uint32_t& bl_last_boottime = *(RTC_USER_MEM + 32);
743743static volatile uint32_t & bl_crashcounter = *(RTC_USER_MEM + 33 );
744744static volatile uint32_t & bl_actiontracker = *(RTC_USER_MEM + 34 );
745745
746- static inline ResetReason rebootReason () {
747- uint32_t resetReason = system_get_rst_info ()->reason ;
746+ static inline ResetReason rebootReason () {
747+ uint32_t resetReason = system_get_rst_info ()->reason ;
748748 if (resetReason == REASON_EXCEPTION_RST
749749 || resetReason == REASON_WDT_RST
750750 || resetReason == REASON_SOFT_WDT_RST)
@@ -771,7 +771,7 @@ static inline ResetReason rebootReason() {
771771}
772772
773773#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 4, 0)
774- static inline uint32_t getRtcMillis () { return esp_rtc_get_time_us () / 1000 ; }
774+ static inline uint32_t getRtcMillis () { return esp_rtc_get_time_us () / 1000 ; }
775775#elif ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(3, 3, 0)
776776static inline uint32_t getRtcMillis () { return rtc_time_slowclk_to_us (rtc_time_get (), rtc_clk_slow_freq_get_hz ()) / 1000 ; }
777777#endif
@@ -785,7 +785,7 @@ static bool detectBootLoop() {
785785 uint32_t rtctime = getRtcMillis ();
786786 bool result = false ;
787787
788- switch (rebootReason ()) {
788+ switch (rebootReason ()) {
789789 case ResetReason::Power:
790790 bl_actiontracker = BOOTLOOP_ACTION_RESTORE; // init action tracker if not an intentional reboot (e.g. from OTA or bootloop handler)
791791 // fall through
@@ -796,6 +796,7 @@ static bool detectBootLoop() {
796796
797797 case ResetReason::Crash:
798798 {
799+ DEBUG_PRINTLN (F (" crash detected!" ));
799800 uint32_t rebootinterval = rtctime - bl_last_boottime;
800801 if (rebootinterval < BOOTLOOP_INTERVAL_MILLIS) {
801802 bl_crashcounter++;
@@ -808,17 +809,17 @@ static bool detectBootLoop() {
808809 // Reset counter on long intervals to track only consecutive short-interval crashes
809810 bl_crashcounter = 0 ;
810811 // TODO: crash reporting goes here
811- }
812+ }
812813 break ;
813814 }
814-
815+
815816 case ResetReason::Brownout:
816817 // crash due to brownout can't be detected unless using flash memory to store bootloop variables
817818 DEBUG_PRINTLN (F (" brownout detected" ));
818819 // restoreConfig(); // TODO: blindly restoring config if brownout detected is a bad idea, need a better way (if at all)
819820 break ;
820821 }
821-
822+
822823 bl_last_boottime = rtctime; // store current runtime for next reboot
823824
824825 return result;
0 commit comments