From a614268c947880dbbea4a1c94c99042f50443a37 Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Tue, 15 Jun 2021 18:44:44 +0200 Subject: [PATCH] serial_dump_and_reset: do not call manage_heater with interrupts disabled Do not call manage_heater() in print_mem() if interrupts are already disabled. This means we're running inside the crash handler. --- Firmware/Dcodes.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Firmware/Dcodes.cpp b/Firmware/Dcodes.cpp index 09c412994..713f3ed5b 100644 --- a/Firmware/Dcodes.cpp +++ b/Firmware/Dcodes.cpp @@ -101,8 +101,10 @@ void print_mem(daddr_t address, daddr_t count, dcode_mem_t type, uint8_t countpe count_line--; count--; - // sporadically call manage heaters to avoid wdt - if(!((uint16_t)count % 8192)) + // sporadically call manage_heater, but only when interrupts are enabled (meaning + // print_mem is called by D2). Don't do anything otherwise: we are inside a crash + // handler where memory & stack needs to be preserved! + if((SREG & (1 << SREG_I)) && !((uint16_t)count % 8192)) manage_heater(); } putchar('\n');