Merge pull request #14718 from bergzand/pr/cortexm_common/hard_fault_add_thread_info
cortexm_common: Add thread info to hard fault handler
This commit is contained in:
commit
f963089b28
@ -32,6 +32,7 @@
|
|||||||
#include "board.h"
|
#include "board.h"
|
||||||
#include "mpu.h"
|
#include "mpu.h"
|
||||||
#include "panic.h"
|
#include "panic.h"
|
||||||
|
#include "sched.h"
|
||||||
#include "vectors_cortexm.h"
|
#include "vectors_cortexm.h"
|
||||||
#ifdef MODULE_PUF_SRAM
|
#ifdef MODULE_PUF_SRAM
|
||||||
#include "puf_sram.h"
|
#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);
|
printf("EXC_RET: 0x%08" PRIx32 "\n", exc_return);
|
||||||
|
|
||||||
if (!corrupted) {
|
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...");
|
puts("Attempting to reconstruct state for debugging...");
|
||||||
printf("In GDB:\n set $pc=0x%" PRIx32 "\n frame 0\n bt\n", pc);
|
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);
|
int stack_left = _stack_size_left(HARDFAULT_HANDLER_REQUIRED_STACK_SPACE);
|
||||||
|
|||||||
@ -9,6 +9,7 @@ BOARD_INSUFFICIENT_MEMORY := \
|
|||||||
nucleo-f031k6 \
|
nucleo-f031k6 \
|
||||||
nucleo-l031k6 \
|
nucleo-l031k6 \
|
||||||
nucleo-f042k6 \
|
nucleo-f042k6 \
|
||||||
|
nucleo-l031k6 \
|
||||||
stm32f030f4-demo \
|
stm32f030f4-demo \
|
||||||
telosb \
|
telosb \
|
||||||
z1 \
|
z1 \
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user