xfdump: report to the host that a dump is available

As suggested by @3d-gussner, announce to the host that a dump is
available for retrieval using an action "dump_available".

Any kind of dump is announced (even if manually triggered).

To avoid reading from xflash twice, remove some duplication and return
the crash reason directly in xfdump_check_state().
This commit is contained in:
Yuri D'Elia 2021-06-11 19:21:51 +02:00
parent 31f416fd5e
commit 3187b96ca4
3 changed files with 32 additions and 25 deletions

View file

@ -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