diff --git a/cpu/cortexm_common/vectors_cortexm.c b/cpu/cortexm_common/vectors_cortexm.c index 17fd205921..fa6f27e532 100644 --- a/cpu/cortexm_common/vectors_cortexm.c +++ b/cpu/cortexm_common/vectors_cortexm.c @@ -32,6 +32,7 @@ #include "board.h" #include "mpu.h" #include "panic.h" +#include "sched.h" #include "vectors_cortexm.h" #ifdef MODULE_PUF_SRAM #include "puf_sram.h" @@ -372,6 +373,20 @@ __attribute__((used)) void hard_fault_handler(uint32_t* sp, uint32_t corrupted, printf("EXC_RET: 0x%08" PRIx32 "\n", exc_return); if (!corrupted) { + /* Test if the EXC_RETURN returns to thread mode, + * to check if the hard fault happened in ISR context */ + if (exc_return & 0x08) { + kernel_pid_t active_pid = thread_getpid(); + printf("Active thread: %"PRIi16" \"%s\"\n", + active_pid, thread_getname(active_pid)); + } + else { + /* Print the interrupt number, NMI being -14, hardfault is -13, + * IRQ0 is 0 and so on */ + uint32_t psr = sp[7]; /* Program status register. */ + printf("Hard fault occured in ISR number %d\n", + (int)(psr & 0xff) - 16); + } puts("Attempting to reconstruct state for debugging..."); printf("In GDB:\n set $pc=0x%" PRIx32 "\n frame 0\n bt\n", pc); int stack_left = _stack_size_left(HARDFAULT_HANDLER_REQUIRED_STACK_SPACE); diff --git a/tests/pkg_fatfs_vfs/Makefile.ci b/tests/pkg_fatfs_vfs/Makefile.ci index bfa6164a4f..346833363d 100644 --- a/tests/pkg_fatfs_vfs/Makefile.ci +++ b/tests/pkg_fatfs_vfs/Makefile.ci @@ -9,6 +9,7 @@ BOARD_INSUFFICIENT_MEMORY := \ nucleo-f031k6 \ nucleo-l031k6 \ nucleo-f042k6 \ + nucleo-l031k6 \ stm32f030f4-demo \ telosb \ z1 \