WDR crash initial

This commit is contained in:
Voinea Dragos 2021-06-09 13:59:26 +03:00
parent 8c3d76f85f
commit 1e786c7f55
6 changed files with 38 additions and 11 deletions

View File

@ -1667,6 +1667,9 @@ void setup()
KEEPALIVE_STATE(NOT_BUSY);
#ifdef WATCHDOG
wdt_enable(WDTO_4S);
#ifdef XFLASH_DUMP
WDTCSR |= (1 << WDIE);
#endif //XFLASH_DUMP
#endif //WATCHDOG
}

View File

@ -1811,6 +1811,12 @@ static void lcd_dump_memory()
xfdump_dump();
lcd_return_to_status();
}
static void lcd_wdr_crash()
{
while (1);
}
#endif
@ -2007,6 +2013,7 @@ static void lcd_support_menu()
#ifdef MENU_DUMP
MENU_ITEM_FUNCTION_P(_i("Dump memory"), lcd_dump_memory);
MENU_ITEM_FUNCTION_P(PSTR("WDR crash"), lcd_wdr_crash);
#endif
#ifdef DEBUG_BUILD
MENU_ITEM_SUBMENU_P(PSTR("Debug"), lcd_menu_debug);////MSG_DEBUG c=18
@ -6704,7 +6711,7 @@ static void lcd_main_menu()
void stack_error() {
WRITE(BEEPER, HIGH);
eeprom_update_byte((uint8_t*)EEPROM_CRASH_ACKNOWLEDGED, 0);
xfdump_full_dump_and_reset(true);
xfdump_full_dump_and_reset(dump_crash_source::stack_error);
}
#else
void stack_error() {

View File

@ -6,6 +6,14 @@
#include "xflash_dump.h"
#ifdef XFLASH_DUMP
#include "xflash.h"
#include "Marlin.h"
ISR(WDT_vect)
{
WRITE(BEEPER, 1);
eeprom_update_byte((uint8_t*)EEPROM_CRASH_ACKNOWLEDGED, 0);
xfdump_full_dump_and_reset(dump_crash_source::watchdog);
}
bool xfdump_check_state()
{
@ -25,10 +33,10 @@ bool xfdump_check_crash()
if(!xfdump_check_state())
return false;
uint8_t crash;
xflash_rd_data(DUMP_OFFSET + offsetof(dump_t, header.crash),
dump_crash_source crash;
xflash_rd_data(DUMP_OFFSET + offsetof(dump_t, header.crash_type),
(uint8_t*)&crash, sizeof(crash));
return crash;
return (crash != dump_crash_source::manual);
}
@ -79,7 +87,7 @@ void xfdump_dump()
dump_header_t buf;
buf.magic = DUMP_MAGIC;
buf.regs_present = false;
buf.crash = false;
buf.crash_type = (uint8_t)dump_crash_source::manual;
// write sram only
xfdump_dump_core(buf, DUMP_OFFSET + offsetof(dump_t, data.sram),
@ -87,12 +95,12 @@ void xfdump_dump()
}
void xfdump_full_dump_and_reset(bool crash)
void xfdump_full_dump_and_reset(dump_crash_source crash)
{
dump_header_t buf;
buf.magic = DUMP_MAGIC;
buf.regs_present = true;
buf.crash = crash;
buf.crash_type = (uint8_t)crash;
// disable interrupts for a cleaner register dump
cli();
@ -101,7 +109,6 @@ void xfdump_full_dump_and_reset(bool crash)
xfdump_dump_core(buf, DUMP_OFFSET + offsetof(dump_t, data), 0, RAMEND);
// force a reset soon
wdt_enable(0);
while(true);
softReset();
}
#endif

View File

@ -8,7 +8,14 @@ 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_source : uint8_t
{
manual = 0,
stack_error,
watchdog,
};
// create a new dump containing registers and SRAM, then reset
void xfdump_full_dump_and_reset(bool crash = false);
void xfdump_full_dump_and_reset(dump_crash_source crash = dump_crash_source::manual);
#endif

View File

@ -20,7 +20,7 @@ struct dump_header_t
uint32_t magic;
uint8_t regs_present; // true when the lower segment containing registers is present
uint8_t crash; // true if triggered by EMERGENCY_DUMP
uint8_t crash_type; // uses values from dump_crash_source
};
struct dump_data_t

View File

@ -163,6 +163,9 @@ void xyzcal_meassure_leave(void)
ENABLE_STEPPER_DRIVER_INTERRUPT();
#ifdef WATCHDOG
wdt_enable(WDTO_4S);
#ifdef XFLASH_DUMP
WDTCSR |= (1 << WDIE);
#endif //XFLASH_DUMP
#endif //WATCHDOG
sm4_stop_cb = 0;
sm4_update_pos_cb = 0;