Now the Crash reporter uses the configured BAUDRATE to send the report through the Programming port. And also shows the traceback of functions as discussed. For that latest feature to work, you need to compile the project with -funwind-tables and -mpoke-function-name compiler flags
This commit is contained in:
@ -24,6 +24,7 @@
|
||||
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
#include "../../Marlin.h"
|
||||
#include "backtrace/backtrace.h"
|
||||
|
||||
// Debug monitor that dumps to the Programming port all status when
|
||||
// an exception or WDT timeout happens - And then resets the board
|
||||
@ -57,8 +58,8 @@ static void TXBegin(void) {
|
||||
// Configure mode: 8bit, No parity, 1 bit stop
|
||||
UART->UART_MR = UART_MR_CHMODE_NORMAL | US_MR_CHRL_8_BIT | US_MR_NBSTOP_1_BIT | UART_MR_PAR_NO;
|
||||
|
||||
// Configure baudrate (asynchronous, no oversampling) to 250000 bauds
|
||||
UART->UART_BRGR = (SystemCoreClock / (250000 << 4));
|
||||
// Configure baudrate (asynchronous, no oversampling) to BAUDRATE bauds
|
||||
UART->UART_BRGR = (SystemCoreClock / (BAUDRATE << 4));
|
||||
|
||||
// Enable receiver and transmitter
|
||||
UART->UART_CR = UART_CR_RXEN | UART_CR_TXEN;
|
||||
@ -92,6 +93,30 @@ static void TXHex(uint32_t v) {
|
||||
}
|
||||
}
|
||||
|
||||
// Send Decimal number thru UART
|
||||
static void TXDec(uint32_t v) {
|
||||
if (!v) {
|
||||
TX('0');
|
||||
return;
|
||||
}
|
||||
|
||||
char nbrs[14];
|
||||
char *p = &nbrs[0];
|
||||
while (v != 0) {
|
||||
*p++ = '0' + (v % 10);
|
||||
v /= 10;
|
||||
}
|
||||
do {
|
||||
p--;
|
||||
TX(*p);
|
||||
} while (p != &nbrs[0]);
|
||||
}
|
||||
|
||||
// Dump a backtrace entry
|
||||
static void backtrace_dump_fn(int idx, const backtrace_t* bte, void* ctx) {
|
||||
TX('#'); TXDec(idx); TX(' '); TX(bte->name); TX(" @ ");TXHex((uint32_t)bte->address); TX('\n');
|
||||
}
|
||||
|
||||
/**
|
||||
* HardFaultHandler_C:
|
||||
* This is called from the HardFault_HandlerAsm with a pointer the Fault stack
|
||||
@ -142,6 +167,15 @@ void HardFault_HandlerC(unsigned long *hardfault_args, unsigned long cause) {
|
||||
// Bus Fault Address Register
|
||||
TX("BFAR : "); TXHex((*((volatile unsigned long *)(0xE000ED38)))); TX('\n');
|
||||
|
||||
// Perform a backtrace
|
||||
TX("\nBacktrace:\n\n");
|
||||
backtrace_frame_t btf;
|
||||
btf.sp = ((unsigned long)hardfault_args[7]);
|
||||
btf.fp = btf.sp;
|
||||
btf.lr = ((unsigned long)hardfault_args[5]);
|
||||
btf.pc = ((unsigned long)hardfault_args[6]);
|
||||
backtrace_dump(&btf, backtrace_dump_fn, nullptr);
|
||||
|
||||
// Reset controller
|
||||
NVIC_SystemReset();
|
||||
while(1) { WDT_Restart(WDT); }
|
||||
|
Reference in New Issue
Block a user