diff --git a/components/esp32/panic.c b/components/esp32/panic.c index 3cf0e894e..23ecdc3da 100644 --- a/components/esp32/panic.c +++ b/components/esp32/panic.c @@ -227,7 +227,10 @@ void panicHandler(XtExcFrame *frame) void xt_unhandled_exception(XtExcFrame *frame) { int *regs = (int *)frame; - int x; + int x=0; + + //Disable all interrupts, so a backtrace isn't interrupted by needless stuff + asm volatile("wsr %0,INTENABLE\nesync\n"::"r"(x)); haltOtherCore(); panicPutStr("Guru Meditation Error of type "); diff --git a/components/freertos/xtensa_int_alias.S b/components/freertos/xtensa_int_alias.S deleted file mode 100644 index 5e121daee..000000000 --- a/components/freertos/xtensa_int_alias.S +++ /dev/null @@ -1,5 +0,0 @@ - - .global xt_highint5 - .global _xt_highint5 - .weak xt_highint5 - .set xt_highint5, _xt_highint5 diff --git a/components/freertos/xtensa_vector_defaults.S b/components/freertos/xtensa_vector_defaults.S index 4270c06c9..a527cc5f6 100644 --- a/components/freertos/xtensa_vector_defaults.S +++ b/components/freertos/xtensa_vector_defaults.S @@ -5,10 +5,29 @@ #include "soc/soc.h" /* -This file contains the default handlers for the high interrupt levels. The default behavious -is to just exit the interrupt. +This file contains the default handlers for the high interrupt levels as well as some specialized exceptions. +The default behaviour is to just exit the interrupt or call the panic handler on the exceptions */ + +#if XCHAL_HAVE_DEBUG + .global xt_debugexception + .weak xt_debugexception + .set xt_debugexception, _xt_debugexception + .section .iram1,"ax" + .type _xt_debugexception,@function + .align 4 + +_xt_debugexception: + movi a0,PANIC_RSN_DEBUGEXCEPTION + wsr a0,EXCCAUSE + call0 _xt_panic /* does not return */ + rsr a0, EXCSAVE+XCHAL_DEBUGLEVEL + rfi XCHAL_DEBUGLEVEL + +#endif /* Debug exception */ + + #if XCHAL_NUM_INTLEVELS >=2 && XCHAL_EXCM_LEVEL <2 && XCHAL_DEBUGLEVEL !=2 .global xt_highint2 .weak xt_highint2 diff --git a/components/freertos/xtensa_vectors.S b/components/freertos/xtensa_vectors.S index 108173206..47e09944b 100644 --- a/components/freertos/xtensa_vectors.S +++ b/components/freertos/xtensa_vectors.S @@ -469,28 +469,10 @@ Debug Exception. .section .DebugExceptionVector.text, "ax" .global _DebugExceptionVector .align 4 - + .global xt_debugexception _DebugExceptionVector: - - #ifdef XT_SIMULATOR - /* - In the simulator, let the debugger (if any) handle the debug exception, - or simply stop the simulation: - */ - wsr a2, EXCSAVE+XCHAL_DEBUGLEVEL /* save a2 where sim expects it */ - movi a2, SYS_gdb_enter_sktloop - simcall /* have ISS handle debug exc. */ - #elif 0 /* change condition to 1 to use the HAL minimal debug handler */ - wsr a3, EXCSAVE+XCHAL_DEBUGLEVEL - movi a3, xthal_debugexc_defhndlr_nw /* use default debug handler */ - jx a3 - #else - wsr a0, EXCSAVE+XCHAL_DEBUGLEVEL /* save original a0 somewhere */ - movi a0,PANIC_RSN_DEBUGEXCEPTION - wsr a0,EXCCAUSE - call0 _xt_panic /* does not return */ - rfi XCHAL_DEBUGLEVEL /* make a0 point here not later */ - #endif + wsr a0, EXCSAVE+XCHAL_DEBUGLEVEL /* preserve a0 */ + call0 xt_debugexception /* load exception handler */ .end literal_prefix