Prevent watchdog reset in setup() (#21776)

Cause `manage_heaters` to only reset the watchdog and return until `setup()` is completed.

Co-authored-by: Scott Lahteine <github@thinkyhead.com>
This commit is contained in:
Victor Oliveira 2021-05-02 23:37:54 -03:00 committed by Scott Lahteine
parent 7957408497
commit 7378afc6d8
6 changed files with 6 additions and 46 deletions

View file

@ -35,18 +35,6 @@ void safe_delay(millis_t ms) {
thermalManager.manage_heater(); // This keeps us safe if too many small safe_delay() calls are made thermalManager.manage_heater(); // This keeps us safe if too many small safe_delay() calls are made
} }
#if ENABLED(MARLIN_DEV_MODE)
void early_safe_delay(millis_t ms) {
while (ms > 50) {
ms -= 50;
delay(50);
watchdog_refresh();
}
delay(ms);
watchdog_refresh();
}
#endif
// A delay to provide brittle hosts time to receive bytes // A delay to provide brittle hosts time to receive bytes
#if ENABLED(SERIAL_OVERRUN_PROTECTION) #if ENABLED(SERIAL_OVERRUN_PROTECTION)

View file

@ -26,11 +26,6 @@
#include "../core/millis_t.h" #include "../core/millis_t.h"
void safe_delay(millis_t ms); // Delay ensuring that temperatures are updated and the watchdog is kept alive. void safe_delay(millis_t ms); // Delay ensuring that temperatures are updated and the watchdog is kept alive.
#if ENABLED(MARLIN_DEV_MODE)
void early_safe_delay(millis_t ms); // Delay ensuring that the watchdog is kept alive. Can be used before the Temperature ISR starts.
#else
inline void early_safe_delay(millis_t ms) { safe_delay(ms); }
#endif
#if ENABLED(SERIAL_OVERRUN_PROTECTION) #if ENABLED(SERIAL_OVERRUN_PROTECTION)
void serial_delay(const millis_t ms); void serial_delay(const millis_t ms);

View file

@ -370,11 +370,6 @@
#endif #endif
#endif #endif
// If platform requires early initialization of watchdog to properly boot
#if ENABLED(USE_WATCHDOG) && defined(ARDUINO_ARCH_SAM)
#define EARLY_WATCHDOG 1
#endif
// Full Touch Screen needs 'tft/xpt2046' // Full Touch Screen needs 'tft/xpt2046'
#if EITHER(TOUCH_SCREEN, HAS_TFT_LVGL_UI) #if EITHER(TOUCH_SCREEN, HAS_TFT_LVGL_UI)
#define HAS_TFT_XPT2046 1 #define HAS_TFT_XPT2046 1

View file

@ -160,14 +160,14 @@ bool MarlinUI::detected() { return true; }
#endif #endif
u8g.firstPage(); u8g.firstPage();
do { draw_custom_bootscreen(f); } while (u8g.nextPage()); do { draw_custom_bootscreen(f); } while (u8g.nextPage());
if (frame_time) early_safe_delay(frame_time); if (frame_time) safe_delay(frame_time);
} }
#ifndef CUSTOM_BOOTSCREEN_TIMEOUT #ifndef CUSTOM_BOOTSCREEN_TIMEOUT
#define CUSTOM_BOOTSCREEN_TIMEOUT 2500 #define CUSTOM_BOOTSCREEN_TIMEOUT 2500
#endif #endif
#if CUSTOM_BOOTSCREEN_TIMEOUT #if CUSTOM_BOOTSCREEN_TIMEOUT
early_safe_delay(CUSTOM_BOOTSCREEN_TIMEOUT); safe_delay(CUSTOM_BOOTSCREEN_TIMEOUT);
#endif #endif
} }
#endif // SHOW_CUSTOM_BOOTSCREEN #endif // SHOW_CUSTOM_BOOTSCREEN
@ -226,7 +226,7 @@ bool MarlinUI::detected() { return true; }
constexpr millis_t frame_time = MARLIN_BOOTSCREEN_FRAME_TIME; constexpr millis_t frame_time = MARLIN_BOOTSCREEN_FRAME_TIME;
LOOP_L_N(f, COUNT(marlin_bootscreen_animation)) { LOOP_L_N(f, COUNT(marlin_bootscreen_animation)) {
draw_bootscreen_bmp((uint8_t*)pgm_read_ptr(&marlin_bootscreen_animation[f])); draw_bootscreen_bmp((uint8_t*)pgm_read_ptr(&marlin_bootscreen_animation[f]));
if (frame_time) early_safe_delay(frame_time); if (frame_time) safe_delay(frame_time);
} }
#endif #endif
} }
@ -235,7 +235,7 @@ bool MarlinUI::detected() { return true; }
void MarlinUI::show_marlin_bootscreen() { void MarlinUI::show_marlin_bootscreen() {
for (uint8_t q = bootscreen_pages; q--;) { for (uint8_t q = bootscreen_pages; q--;) {
draw_marlin_bootscreen(q == 0); draw_marlin_bootscreen(q == 0);
if (q) early_safe_delay((BOOTSCREEN_TIMEOUT) / bootscreen_pages); if (q) safe_delay((BOOTSCREEN_TIMEOUT) / bootscreen_pages);
} }
} }

View file

@ -420,10 +420,6 @@ const char str_t_thermal_runaway[] PROGMEM = STR_T_THERMAL_RUNAWAY,
// private: // private:
#if EARLY_WATCHDOG
bool Temperature::inited = false;
#endif
volatile bool Temperature::raw_temps_ready = false; volatile bool Temperature::raw_temps_ready = false;
#if ENABLED(PID_EXTRUSION_SCALING) #if ENABLED(PID_EXTRUSION_SCALING)
@ -1205,11 +1201,7 @@ void Temperature::min_temp_error(const heater_id_t heater_id) {
* - Update the heated bed PID output value * - Update the heated bed PID output value
*/ */
void Temperature::manage_heater() { void Temperature::manage_heater() {
if (marlin_state == MF_INITIALIZING) return watchdog_refresh(); // If Marlin isn't started, at least reset the watchdog!
#if EARLY_WATCHDOG
// If thermal manager is still not running, make sure to at least reset the watchdog!
if (!inited) return watchdog_refresh();
#endif
#if ENABLED(EMERGENCY_PARSER) #if ENABLED(EMERGENCY_PARSER)
if (emergency_parser.killed_by_M112) kill(M112_KILL_STR, nullptr, true); if (emergency_parser.killed_by_M112) kill(M112_KILL_STR, nullptr, true);
@ -1994,12 +1986,6 @@ void Temperature::init() {
TERN_(TEMP_SENSOR_1_IS_MAX6675, max6675_1.begin()); TERN_(TEMP_SENSOR_1_IS_MAX6675, max6675_1.begin());
#endif #endif
#if EARLY_WATCHDOG
// Flag that the thermalManager should be running
if (inited) return;
inited = true;
#endif
#if MB(RUMBA) #if MB(RUMBA)
// Disable RUMBA JTAG in case the thermocouple extension is plugged on top of JTAG connector // Disable RUMBA JTAG in case the thermocouple extension is plugged on top of JTAG connector
#define _AD(N) (TEMP_SENSOR_##N##_IS_AD595 || TEMP_SENSOR_##N##_IS_AD8495) #define _AD(N) (TEMP_SENSOR_##N##_IS_AD595 || TEMP_SENSOR_##N##_IS_AD8495)
@ -2192,7 +2178,7 @@ void Temperature::init() {
#endif #endif
// Wait for temperature measurement to settle // Wait for temperature measurement to settle
delay(250); //delay(250);
#if HAS_HOTEND #if HAS_HOTEND

View file

@ -419,10 +419,6 @@ class Temperature {
private: private:
#if ENABLED(EARLY_WATCHDOG)
static bool inited; // If temperature controller is running
#endif
static volatile bool raw_temps_ready; static volatile bool raw_temps_ready;
#if ENABLED(WATCH_HOTENDS) #if ENABLED(WATCH_HOTENDS)