🍻 Get/clear reset source earlier

Followup to #23075
x301
Scott Lahteine 3 years ago committed by Scott Lahteine
parent 9fffed7160
commit 9b76b58b79

@ -1104,6 +1104,10 @@ void setup() {
tmc_standby_setup(); // TMC Low Power Standby pins must be set early or they're not usable tmc_standby_setup(); // TMC Low Power Standby pins must be set early or they're not usable
// Check startup - does nothing if bootloader sets MCUSR to 0
const byte mcu = HAL_get_reset_source();
HAL_clear_reset_source();
#if ENABLED(MARLIN_DEV_MODE) #if ENABLED(MARLIN_DEV_MODE)
auto log_current_ms = [&](PGM_P const msg) { auto log_current_ms = [&](PGM_P const msg) {
SERIAL_ECHO_START(); SERIAL_ECHO_START();
@ -1232,15 +1236,14 @@ void setup() {
SETUP_RUN(esp_wifi_init()); SETUP_RUN(esp_wifi_init());
// Check startup - does nothing if bootloader sets MCUSR to 0 // Report Reset Reason
const byte mcu = HAL_get_reset_source();
if (mcu & RST_POWER_ON) SERIAL_ECHOLNPGM(STR_POWERUP); if (mcu & RST_POWER_ON) SERIAL_ECHOLNPGM(STR_POWERUP);
if (mcu & RST_EXTERNAL) SERIAL_ECHOLNPGM(STR_EXTERNAL_RESET); if (mcu & RST_EXTERNAL) SERIAL_ECHOLNPGM(STR_EXTERNAL_RESET);
if (mcu & RST_BROWN_OUT) SERIAL_ECHOLNPGM(STR_BROWNOUT_RESET); if (mcu & RST_BROWN_OUT) SERIAL_ECHOLNPGM(STR_BROWNOUT_RESET);
if (mcu & RST_WATCHDOG) SERIAL_ECHOLNPGM(STR_WATCHDOG_RESET); if (mcu & RST_WATCHDOG) SERIAL_ECHOLNPGM(STR_WATCHDOG_RESET);
if (mcu & RST_SOFTWARE) SERIAL_ECHOLNPGM(STR_SOFTWARE_RESET); if (mcu & RST_SOFTWARE) SERIAL_ECHOLNPGM(STR_SOFTWARE_RESET);
HAL_clear_reset_source();
// Identify myself as Marlin x.x.x
SERIAL_ECHOLNPGM("Marlin " SHORT_BUILD_VERSION); SERIAL_ECHOLNPGM("Marlin " SHORT_BUILD_VERSION);
#if defined(STRING_DISTRIBUTION_DATE) && defined(STRING_CONFIG_H_AUTHOR) #if defined(STRING_DISTRIBUTION_DATE) && defined(STRING_CONFIG_H_AUTHOR)
SERIAL_ECHO_MSG( SERIAL_ECHO_MSG(

Loading…
Cancel
Save