Browse Source

Implement EMERGENCY_DUMP for offline analysis

If EMERGENCY_DUMP is defined, crash and dump using the new xflash dump
functionality instead of just continuing with an error message.

When an emergency crash is stored, the first restart after a crash
displays a message that debug data is available and to contact support
to submit the crash for analysis.
Yuri D'Elia 3 years ago
parent
commit
c089ac5341
3 changed files with 29 additions and 1 deletions
  1. 16 0
      Firmware/Marlin_main.cpp
  2. 3 1
      Firmware/eeprom.h
  3. 10 0
      Firmware/ultralcd.cpp

+ 16 - 0
Firmware/Marlin_main.cpp

@@ -108,6 +108,10 @@
 #include "optiboot_xflash.h"
 #endif //XFLASH
 
+#ifdef EMERGENCY_DUMP
+#include "xflash_dump.h"
+#endif
+
 #ifdef BLINKM
 #include "BlinkM.h"
 #include "Wire.h"
@@ -1606,6 +1610,18 @@ 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)
+    {
+        // 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
+
 #ifdef UVLO_SUPPORT
   if (eeprom_read_byte((uint8_t*)EEPROM_UVLO) != 0) { //previous print was terminated by UVLO
 /*

+ 3 - 1
Firmware/eeprom.h

@@ -327,6 +327,7 @@ static_assert(sizeof(Sheets) == EEPROM_SHEETS_SIZEOF, "Sizeof(Sheets) is not EEP
 | 0x0D05 3333		| uint32_t	| EEPROM_JOB_ID							| ???			| 00 00 00 00h			| Job ID used by host software						| D3 only		| D3 Ax0d05 C4
 | 0x0D04 3332		| uint8_t	| EEPROM_ECOOL_ENABLE					| ffh 255		| ^						| Disable extruder motor scaling for non-farm print	| LCD menu		| D3 Ax0d04 C1
 | ^					| ^			| ^										| 2ah 42		| ^						| Enable extruder motor scaling for non-farm print	| ^				| D3 Ax0d04 C1
+| 0x0D03 3321		| uint8_t	| EEPROM_CRASH_ACKNOWLEDGED				| 01h 1			| ff/00					| Disable crash report after first acknowledgment	| D21/D22		| D3 Ax0d03 C1
 
 | Address begin		| Bit/Type 	| Name 									| Valid values	| Default/FactoryReset	| Description 										| Gcode/Function| Debug code
 | :--:				| :--: 		| :--: 									| :--:			| :--:					| :--:												| :--:			| :--:
@@ -541,9 +542,10 @@ static Sheets * const EEPROM_Sheets_base = (Sheets*)(EEPROM_SHEETS_BASE);
 #define EEPROM_JOB_ID (EEPROM_UVLO_TRAVEL_ACCELL-4) //uint32_t
 
 #define EEPROM_ECOOL_ENABLE (EEPROM_JOB_ID-1) // uint8_t
+#define EEPROM_CRASH_ACKNOWLEDGED (EEPROM_ECOOL_ENABLE-1) // uint8_t
 
 //This is supposed to point to last item to allow EEPROM overrun check. Please update when adding new items.
-#define EEPROM_LAST_ITEM EEPROM_ECOOL_ENABLE
+#define EEPROM_LAST_ITEM EEPROM_CRASH_ACKNOWLEDGED
 // !!!!!
 // !!!!! this is end of EEPROM section ... all updates MUST BE inserted before this mark !!!!!
 // !!!!!

+ 10 - 0
Firmware/ultralcd.cpp

@@ -6683,12 +6683,22 @@ static void lcd_main_menu()
 
 }
 
+#ifdef EMERGENCY_DUMP
+#include "xflash_dump.h"
+
+void stack_error() {
+    WRITE(BEEPER, HIGH);
+    eeprom_update_byte((uint8_t*)EEPROM_CRASH_ACKNOWLEDGED, 0);
+    xfdump_full_dump_and_reset(true);
+}
+#else
 void stack_error() {
 	Sound_MakeCustom(1000,0,true);
 	lcd_display_message_fullscreen_P(_i("Error - static memory has been overwritten"));////MSG_STACK_ERROR c=20 r=4
 	//err_triggered = 1;
 	 while (1) delay_keep_alive(1000);
 }
+#endif
 
 #ifdef DEBUG_STEPPER_TIMER_MISSED
 bool stepper_timer_overflow_state = false;