diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index eec6591b..91da6cc9 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -108,7 +108,7 @@ #include "optiboot_xflash.h" #endif //XFLASH -#ifdef EMERGENCY_DUMP +#ifdef XFLASH_DUMP #include "xflash_dump.h" #endif @@ -1610,15 +1610,27 @@ void setup() if (tmc2130_home_enabled == 0xff) tmc2130_home_enabled = 0; #endif //TMC2130 -#ifdef EMERGENCY_DUMP - if(xfdump_check_crash() && eeprom_read_byte((uint8_t*)EEPROM_CRASH_ACKNOWLEDGED) != 1) +#ifdef XFLASH_DUMP { - // prevent the prompt to reappear once acknowledged - eeprom_update_byte((uint8_t*)EEPROM_CRASH_ACKNOWLEDGED, 1); - lcd_show_fullscreen_message_and_wait_P( - _i("!!!FIRMWARE CRASH!!!\n" - "Debug data available for analysis. " - "Contact support to submit details.")); + dump_crash_reason crash_reason; + if(xfdump_check_state(&crash_reason)) + { + // always signal to the host that a dump is available for retrieval + puts_P(_N("// action:dump_available")); + +#ifdef EMERGENCY_DUMP + if(crash_reason != dump_crash_reason::manual && + eeprom_read_byte((uint8_t*)EEPROM_CRASH_ACKNOWLEDGED) != 1) + { + // prevent the prompt to reappear once acknowledged + eeprom_update_byte((uint8_t*)EEPROM_CRASH_ACKNOWLEDGED, 1); + lcd_show_fullscreen_message_and_wait_P( + _i("!!!FIRMWARE CRASH!!!\n" + "Debug data available for analysis. " + "Contact support to submit details.")); + } +#endif + } } #endif diff --git a/Firmware/xflash_dump.cpp b/Firmware/xflash_dump.cpp index b9d2679a..290a8d99 100644 --- a/Firmware/xflash_dump.cpp +++ b/Firmware/xflash_dump.cpp @@ -8,28 +8,22 @@ #include "xflash.h" #include "Marlin.h" // for softReset -bool xfdump_check_state() +bool xfdump_check_state(dump_crash_reason* reason) { uint32_t magic; XFLASH_SPI_ENTER(); xflash_rd_data(DUMP_OFFSET + offsetof(dump_t, header.magic), (uint8_t*)&magic, sizeof(magic)); - - return magic == DUMP_MAGIC; -} - - -bool xfdump_check_crash() -{ - // check_state will call SPI_ENTER for us - if(!xfdump_check_state()) + if (magic != DUMP_MAGIC) return false; - dump_crash_reason reason; - xflash_rd_data(DUMP_OFFSET + offsetof(dump_t, header.crash_reason), - (uint8_t*)&reason, sizeof(reason)); - return (reason != dump_crash_reason::manual); + if (reason) + { + xflash_rd_data(DUMP_OFFSET + offsetof(dump_t, header.crash_reason), + (uint8_t*)reason, sizeof(*reason)); + } + return true; } diff --git a/Firmware/xflash_dump.h b/Firmware/xflash_dump.h index 18e1c684..658ecd2d 100644 --- a/Firmware/xflash_dump.h +++ b/Firmware/xflash_dump.h @@ -4,8 +4,6 @@ #ifdef XFLASH_DUMP void xfdump_reset(); // reset XFLASH dump state -bool xfdump_check_state(); // return true if a dump is present -bool xfdump_check_crash(); // return true if a dump is present and is a crash dump void xfdump_dump(); // create a new SRAM memory dump enum class dump_crash_reason : uint8_t @@ -15,6 +13,9 @@ enum class dump_crash_reason : uint8_t watchdog, }; +// return true if a dump is present, save type in "reason" if provided +bool xfdump_check_state(dump_crash_reason* reason = NULL); + // create a new dump containing registers and SRAM, then reset void xfdump_full_dump_and_reset(dump_crash_reason crash = dump_crash_reason::manual);