Skip to content

Commit

Permalink
🍻 Get/clear reset source earlier
Browse files Browse the repository at this point in the history
Followup to #23075
  • Loading branch information
thinkyhead committed Nov 4, 2021
1 parent f53d627 commit f6147e0
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions Marlin/src/MarlinCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1104,6 +1104,10 @@ void setup() {

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)
auto log_current_ms = [&](PGM_P const msg) {
SERIAL_ECHO_START();
Expand Down Expand Up @@ -1232,15 +1236,14 @@ void setup() {

SETUP_RUN(esp_wifi_init());

// Check startup - does nothing if bootloader sets MCUSR to 0
const byte mcu = HAL_get_reset_source();
// Report Reset Reason
if (mcu & RST_POWER_ON) SERIAL_ECHOLNPGM(STR_POWERUP);
if (mcu & RST_EXTERNAL) SERIAL_ECHOLNPGM(STR_EXTERNAL_RESET);
if (mcu & RST_BROWN_OUT) SERIAL_ECHOLNPGM(STR_BROWNOUT_RESET);
if (mcu & RST_WATCHDOG) SERIAL_ECHOLNPGM(STR_WATCHDOG_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);
#if defined(STRING_DISTRIBUTION_DATE) && defined(STRING_CONFIG_H_AUTHOR)
SERIAL_ECHO_MSG(
Expand Down

0 comments on commit f6147e0

Please sign in to comment.