diff options
author | Harald Welte <laforge@gnumonks.org> | 2017-05-07 22:44:31 +0200 |
---|---|---|
committer | Harald Welte <laforge@gnumonks.org> | 2017-05-07 23:10:02 +0200 |
commit | f8c83a4d6404bf6b4b7f40d412be91c78bd21f02 (patch) | |
tree | 216f09f9884e3e2a7ef73f8863f9b0de5bd33b6c /firmware/atmel_softpack_libraries | |
parent | 28174982b6a4face3f58bd9e4e5479c30766a5db (diff) |
Make hardfault handler a bit more verbose
Diffstat (limited to 'firmware/atmel_softpack_libraries')
-rw-r--r-- | firmware/atmel_softpack_libraries/libchip_sam3s/source/exceptions.c | 48 |
1 files changed, 47 insertions, 1 deletions
diff --git a/firmware/atmel_softpack_libraries/libchip_sam3s/source/exceptions.c b/firmware/atmel_softpack_libraries/libchip_sam3s/source/exceptions.c index 1f023b8..2cbf458 100644 --- a/firmware/atmel_softpack_libraries/libchip_sam3s/source/exceptions.c +++ b/firmware/atmel_softpack_libraries/libchip_sam3s/source/exceptions.c @@ -81,7 +81,7 @@ struct hardfault_args { void hard_fault_handler_c(struct hardfault_args *args)
{
- printf("HardFault\r\n");
+ printf("\r\nHardFault\r\n");
printf("R0=%08x, R1=%08x, R2=%08x, R3=%08x, R12=%08x\r\n",
args->r0, args->r1, args->r2, args->r3, args->r12);
printf("LR[R14]=%08x, PC[R15]=%08x, PSR=%08x\r\n",
@@ -90,6 +90,52 @@ void hard_fault_handler_c(struct hardfault_args *args) SCB->BFAR, SCB->CFSR, SCB->HFSR);
printf("DFSR=%08x, AFSR=%08x, SHCSR=%08x\r\n",
SCB->DFSR, SCB->CFSR, SCB->SHCSR);
+
+ if (SCB->HFSR & 0x40000000)
+ printf("FORCED ");
+ if (SCB->HFSR & 0x00000002)
+ printf("VECTTBL ");
+
+ uint32_t ufsr = SCB->CFSR >> 16;
+ if (ufsr & 0x0200)
+ printf("DIVBYZERO ");
+ if (ufsr & 0x0100)
+ printf("UNALIGNED ");
+ if (ufsr & 0x0008)
+ printf("NOCP ");
+ if (ufsr & 0x0004)
+ printf("INVPC ");
+ if (ufsr & 0x0002)
+ printf("INVSTATE ");
+ if (ufsr & 0x0001)
+ printf("UNDEFINSTR ");
+
+ uint32_t bfsr = (SCB->CFSR >> 8) & 0xff;
+ if (bfsr & 0x80)
+ printf("BFARVALID ");
+ if (bfsr & 0x10)
+ printf("STKERR ");
+ if (bfsr & 0x08)
+ printf("UNSTKERR ");
+ if (bfsr & 0x04)
+ printf("IMPRECISERR ");
+ if (bfsr & 0x02)
+ printf("PRECISERR ");
+ if (bfsr & 0x01)
+ printf("IBUSERR ");
+
+ uint32_t mmfsr = (SCB->CFSR & 0xff);
+ if (mmfsr & 0x80)
+ printf("MMARVALID ");
+ if (mmfsr & 0x10)
+ printf("MSTKERR ");
+ if (mmfsr & 0x08)
+ printf("MUNSTKERR ");
+ if (mmfsr & 0x02)
+ printf("DACCVIOL ");
+ if (mmfsr & 0x01)
+ printf("IACCVIOL ");
+
while ( 1 ) ;
}
|