1
0
mirror of https://github.com/armink/CmBacktrace.git synced 2025-01-25 00:22:53 +08:00

1、【增加】存储器管理错误及总线错误具体地址的信息输出;

Signed-off-by: armink <armink.ztl@gmail.com>
This commit is contained in:
armink 2017-02-17 16:35:23 +08:00
parent 647c515665
commit f773a04522
3 changed files with 24 additions and 6 deletions

View File

@ -1,6 +1,6 @@
The MIT License (MIT) The MIT License (MIT)
Copyright (c) 2016 Armink (armink.ztl@gmail.com) Copyright (c) 2016-2017 Armink (armink.ztl@gmail.com)
Permission is hereby granted, free of charge, to any person obtaining Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the a copy of this software and associated documentation files (the

View File

@ -1,7 +1,7 @@
/* /*
* This file is part of the CmBacktrace Library. * This file is part of the CmBacktrace Library.
* *
* Copyright (c) 2016, Armink, <armink.ztl@gmail.com> * Copyright (c) 2016-2017, Armink, <armink.ztl@gmail.com>
* *
* Permission is hereby granted, free of charge, to any person obtaining * Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the * a copy of this software and associated documentation files (the
@ -118,6 +118,8 @@ enum {
PRINT_DFSR_DWTTRAP, PRINT_DFSR_DWTTRAP,
PRINT_DFSR_VCATCH, PRINT_DFSR_VCATCH,
PRINT_DFSR_EXTERNAL, PRINT_DFSR_EXTERNAL,
PRINT_MMAR,
PRINT_BFAR,
}; };
static const char *print_info[] = { static const char *print_info[] = {
@ -155,6 +157,8 @@ static const char *print_info[] = {
[PRINT_DFSR_DWTTRAP] = "Debug fault is caused by DWT match occurred", [PRINT_DFSR_DWTTRAP] = "Debug fault is caused by DWT match occurred",
[PRINT_DFSR_VCATCH] = "Debug fault is caused by Vector fetch occurred", [PRINT_DFSR_VCATCH] = "Debug fault is caused by Vector fetch occurred",
[PRINT_DFSR_EXTERNAL] = "Debug fault is caused by EDBGRQ signal asserted", [PRINT_DFSR_EXTERNAL] = "Debug fault is caused by EDBGRQ signal asserted",
[PRINT_MMAR] = "The memory management fault occurred address is %08x",
[PRINT_BFAR] = "The bus fault occurred address is %08x",
#elif (CMB_PRINT_LANGUAGE == CMB_PRINT_LANUUAGE_CHINESE) #elif (CMB_PRINT_LANGUAGE == CMB_PRINT_LANUUAGE_CHINESE)
[PRINT_FIRMWARE_INFO] = "<EFBFBD>̼<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƣ<EFBFBD>%s<><73>Ӳ<EFBFBD><D3B2><EFBFBD><EFBFBD>ţ<EFBFBD>%s<><73><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ţ<EFBFBD>%s", [PRINT_FIRMWARE_INFO] = "<EFBFBD>̼<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƣ<EFBFBD>%s<><73>Ӳ<EFBFBD><D3B2><EFBFBD><EFBFBD>ţ<EFBFBD>%s<><73><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ţ<EFBFBD>%s",
[PRINT_ASSERT_ON_THREAD] = "<EFBFBD><EFBFBD><EFBFBD>߳<EFBFBD>(%s)<29>з<EFBFBD><D0B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", [PRINT_ASSERT_ON_THREAD] = "<EFBFBD><EFBFBD><EFBFBD>߳<EFBFBD>(%s)<29>з<EFBFBD><D0B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>",
@ -189,6 +193,8 @@ static const char *print_info[] = {
[PRINT_DFSR_DWTTRAP] = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԭ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƥ<EFBFBD><EFBFBD>", [PRINT_DFSR_DWTTRAP] = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԭ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƥ<EFBFBD><EFBFBD>",
[PRINT_DFSR_VCATCH] = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԭ<EFBFBD>򣺷<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", [PRINT_DFSR_VCATCH] = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԭ<EFBFBD>򣺷<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>",
[PRINT_DFSR_EXTERNAL] = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԭ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ⲿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", [PRINT_DFSR_EXTERNAL] = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԭ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ⲿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>",
[PRINT_MMAR] = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD>ַ<EFBFBD><EFBFBD>%08x",
[PRINT_BFAR] = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ߴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD>ַ<EFBFBD><EFBFBD>%08x",
#else #else
#error "CMB_PRINT_LANGUAGE defined error in 'cmb_cfg.h'" #error "CMB_PRINT_LANGUAGE defined error in 'cmb_cfg.h'"
#endif #endif
@ -497,7 +503,9 @@ static void fault_diagnosis(void) {
#endif #endif
if (regs.mfsr.bits.MMARVALID) { if (regs.mfsr.bits.MMARVALID) {
//TODO if (regs.mfsr.bits.IACCVIOL || regs.mfsr.bits.DACCVIOL) {
cmb_println(print_info[PRINT_MMAR], regs.mmar);
}
} }
} }
/* Bus Fault */ /* Bus Fault */
@ -525,8 +533,11 @@ static void fault_diagnosis(void) {
#endif #endif
if (regs.bfsr.bits.BFARVALID) { if (regs.bfsr.bits.BFARVALID) {
//TODO if (regs.bfsr.bits.PRECISERR) {
cmb_println(print_info[PRINT_BFAR], regs.bfar);
}
} }
} }
/* Usage Fault */ /* Usage Fault */
if (regs.ufsr.value) { if (regs.ufsr.value) {
@ -674,6 +685,7 @@ void cm_backtrace_fault(uint32_t fault_handler_lr, uint32_t fault_handler_sp) {
#if (CMB_CPU_PLATFORM_TYPE != CMB_CPU_ARM_CORTEX_M0) #if (CMB_CPU_PLATFORM_TYPE != CMB_CPU_ARM_CORTEX_M0)
regs.syshndctrl.value = CMB_SYSHND_CTRL; // System Handler Control and State Register regs.syshndctrl.value = CMB_SYSHND_CTRL; // System Handler Control and State Register
regs.mfsr.value = CMB_NVIC_MFSR; // Memory Fault Status Register regs.mfsr.value = CMB_NVIC_MFSR; // Memory Fault Status Register
regs.mmar = CMB_NVIC_MMAR; // Memory Management Fault Address Register
regs.bfsr.value = CMB_NVIC_BFSR; // Bus Fault Status Register regs.bfsr.value = CMB_NVIC_BFSR; // Bus Fault Status Register
regs.bfar = CMB_NVIC_BFAR; // Bus Fault Manage Address Register regs.bfar = CMB_NVIC_BFAR; // Bus Fault Manage Address Register
regs.ufsr.value = CMB_NVIC_UFSR; // Usage Fault Status Register regs.ufsr.value = CMB_NVIC_UFSR; // Usage Fault Status Register

View File

@ -1,7 +1,7 @@
/* /*
* This file is part of the CmBacktrace Library. * This file is part of the CmBacktrace Library.
* *
* Copyright (c) 2016, Armink, <armink.ztl@gmail.com> * Copyright (c) 2016-2017, Armink, <armink.ztl@gmail.com>
* *
* Permission is hereby granted, free of charge, to any person obtaining * Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the * a copy of this software and associated documentation files (the
@ -34,7 +34,7 @@
#include <stdlib.h> #include <stdlib.h>
/* library software version number */ /* library software version number */
#define CMB_SW_VERSION "0.1.1" #define CMB_SW_VERSION "0.1.2"
#define CMB_CPU_ARM_CORTEX_M0 0 #define CMB_CPU_ARM_CORTEX_M0 0
#define CMB_CPU_ARM_CORTEX_M3 1 #define CMB_CPU_ARM_CORTEX_M3 1
@ -134,6 +134,11 @@
#define CMB_NVIC_DFSR (*(volatile unsigned short*)(0xE000ED30u)) #define CMB_NVIC_DFSR (*(volatile unsigned short*)(0xE000ED30u))
#endif #endif
/* memory management fault address register */
#ifndef CMB_NVIC_MMAR
#define CMB_NVIC_MMAR (*(volatile unsigned int*) (0xE000ED34u))
#endif
/* bus fault manage address register */ /* bus fault manage address register */
#ifndef CMB_NVIC_BFAR #ifndef CMB_NVIC_BFAR
#define CMB_NVIC_BFAR (*(volatile unsigned int*) (0xE000ED38u)) #define CMB_NVIC_BFAR (*(volatile unsigned int*) (0xE000ED38u))
@ -202,6 +207,7 @@ struct cmb_hard_fault_regs{
unsigned char MMARVALID : 1; // Indicates the MMAR is valid unsigned char MMARVALID : 1; // Indicates the MMAR is valid
} bits; } bits;
} mfsr; // Memory Management Fault Status Register (0xE000ED28) } mfsr; // Memory Management Fault Status Register (0xE000ED28)
unsigned int mmar; // Memory Management Fault Address Register (0xE000ED34)
union { union {
unsigned char value; unsigned char value;