Skip to content

Commit f27911c

Browse files
fix: ensure watchdog doesn't interrupt fault tracer (#740)
Sprinkle some watchdog feeds
1 parent f1917ee commit f27911c

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

hal_st/cortex/FaultTracer.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ namespace hal
2323
static_assert(__CORTEX_M >= 0x3U);
2424
if (this->tracerProvider)
2525
{
26+
FeedWatchdog();
2627
auto& tracer = this->tracerProvider();
2728
tracer.Trace() << "*** Hard fault! ***";
2829
DumpCurrentInterruptStackAndAbort(tracer);
@@ -36,6 +37,7 @@ namespace hal
3637
{
3738
if (tracerProvider)
3839
{
40+
FeedWatchdog();
3941
auto& tracer = tracerProvider();
4042
tracer.Trace() << "*** Fault: " << fault << " ***";
4143
DumpCurrentInterruptStackAndAbort(tracer);
@@ -72,6 +74,7 @@ namespace hal
7274
void DefaultFaultTracer::DumpCfsrContents(uint32_t cfsr, services::Tracer& tracer) const
7375
{
7476
/* Memory Manage Faults */
77+
FeedWatchdog();
7578
if (cfsr & SCB_CFSR_IACCVIOL_Msk)
7679
tracer.Trace() << " MemManageFault: Instruction access violation";
7780
if (cfsr & SCB_CFSR_DACCVIOL_Msk)
@@ -86,6 +89,7 @@ namespace hal
8689
tracer.Trace() << " MemManageFault: MMFAR valid";
8790

8891
/* Bus Faults */
92+
FeedWatchdog();
8993
if (cfsr & SCB_CFSR_IBUSERR_Msk)
9094
tracer.Trace() << " BusFault: Instruction bus error";
9195
if (cfsr & SCB_CFSR_PRECISERR_Msk)
@@ -102,13 +106,14 @@ namespace hal
102106
tracer.Trace() << " BusFault: BFAR valid";
103107

104108
/* Usage Faults */
109+
FeedWatchdog();
105110
if (cfsr & SCB_CFSR_UNDEFINSTR_Msk)
106111
tracer.Trace() << " UsageFault: Illegal instruction";
107112
if (cfsr & SCB_CFSR_INVSTATE_Msk)
108113
tracer.Trace() << " UsageFault: Invalid state";
109114
if (cfsr & SCB_CFSR_INVPC_Msk)
110115
tracer.Trace() << " UsageFault: Invalid PC load usage fault";
111-
// Ignoring NOCP
116+
// Ignoring NOCP
112117
#if defined(SCB_CFSR_STKOF_Msk)
113118
if (cfsr & SCB_CFSR_STKOF_Msk)
114119
tracer.Trace() << " UsageFault: Stack overflow";
@@ -148,6 +153,7 @@ namespace hal
148153
auto lr = interruptContext.stack[5];
149154
auto pc = interruptContext.stack[6];
150155
auto psr = interruptContext.stack[7];
156+
FeedWatchdog();
151157
tracer.Trace() << "Stack frame";
152158
tracer.Trace() << " R0 : 0x" << infra::hex << infra::Width(8, '0') << r0; // Usually contains the parameter values
153159
tracer.Trace() << " R1 : 0x" << infra::hex << infra::Width(8, '0') << r1; // Usually contains the parameter values
@@ -162,6 +168,7 @@ namespace hal
162168
auto MemManageFaultAddress = SCB->MMFAR;
163169
auto BusFaultAddress = SCB->BFAR;
164170

171+
FeedWatchdog();
165172
tracer.Trace() << "FSR/FAR:";
166173
tracer.Trace() << " HFSR: 0x" << infra::hex << infra::Width(8, '0') << SCB->HFSR;
167174
if (SCB->HFSR & SCB_HFSR_VECTTBL_Msk)
@@ -172,6 +179,7 @@ namespace hal
172179
tracer.Trace() << " FORCED (Hard Fault)";
173180
tracer.Trace() << " CFSR: 0x" << infra::hex << infra::Width(8, '0') << cfsr;
174181
DumpCfsrContents(cfsr, tracer);
182+
FeedWatchdog();
175183
tracer.Trace() << " DFSR: 0x" << infra::hex << infra::Width(8, '0') << SCB->DFSR;
176184
tracer.Trace() << " AFSR: 0x" << infra::hex << infra::Width(8, '0') << SCB->AFSR;
177185
if (cfsr & SCB_CFSR_MMARVALID_Msk)

0 commit comments

Comments
 (0)