fix cortex m0/m0+ fault backtrace in armcc

1. no support for mrseq for cortex m0/m0+ cpu instructions set
This commit is contained in:
daishengdong
2020-06-03 17:26:37 +08:00
parent 479dc02d79
commit f7195c79a7
11 changed files with 49 additions and 29 deletions

View File

@@ -78,7 +78,7 @@ __PORT__ void port_standby_mode_enter(void)
#if TOS_CFG_FAULT_BACKTRACE_EN > 0u #if TOS_CFG_FAULT_BACKTRACE_EN > 0u
__PORT__ void port_fault_diagnosis(void) __PORT__ void port_fault_diagnosis(void)
{ {
k_fault_log_writer("fault diagnosis does not supported in CORTEX M0\n"); k_fault_log_writer("fault diagnosis is not supported in CORTEX M0\n");
} }
/*------------------ RealView Compiler -----------------*/ /*------------------ RealView Compiler -----------------*/
@@ -90,10 +90,16 @@ __PORT__ __ASM__ void HardFault_Handler(void)
IMPORT fault_backtrace IMPORT fault_backtrace
MOV r0, lr MOV r0, lr
TST lr, #0x04 MOVS r1, #0x04
ITE EQ TST r0, r1
MRSEQ r1, MSP BEQ _LD_MSP
MRSNE r1, PSP MRS r1, PSP
B _EXIT
_LD_MSP
MRS r1, MSP
_EXIT
BL fault_backtrace BL fault_backtrace
} }
@@ -104,10 +110,14 @@ __PORT__ void __NAKED__ HardFault_Handler(void)
{ {
__ASM__ __VOLATILE__ ( __ASM__ __VOLATILE__ (
"MOV r0, lr\n\t" "MOV r0, lr\n\t"
"TST lr, #0x04\n\t" "MOVS r1, #0x04\n\t"
"ITE EQ\n\t" "TST r0, r1\n\t"
"MRSEQ r1, MSP\n\t" "BEQ _LD_MSP\n\t"
"MRSNE r1, PSP\n\t" "MRS r1, PSP\n\t"
"B _EXIT\n\t"
"_LD_MSP:\n\t"
"MRS r1, MSP\n\t"
"_EXIT:\n\t"
"BL fault_backtrace\n\t" "BL fault_backtrace\n\t"
); );
} }

View File

@@ -78,7 +78,7 @@ __PORT__ void port_standby_mode_enter(void)
#if TOS_CFG_FAULT_BACKTRACE_EN > 0u #if TOS_CFG_FAULT_BACKTRACE_EN > 0u
__PORT__ void port_fault_diagnosis(void) __PORT__ void port_fault_diagnosis(void)
{ {
k_fault_log_writer("fault diagnosis does not supported in CORTEX M0\n"); k_fault_log_writer("fault diagnosis is not supported in CORTEX M0\n");
} }
/*------------------ RealView Compiler -----------------*/ /*------------------ RealView Compiler -----------------*/

View File

@@ -78,7 +78,7 @@ __PORT__ void port_standby_mode_enter(void)
#if TOS_CFG_FAULT_BACKTRACE_EN > 0u #if TOS_CFG_FAULT_BACKTRACE_EN > 0u
__PORT__ void port_fault_diagnosis(void) __PORT__ void port_fault_diagnosis(void)
{ {
k_fault_log_writer("fault diagnosis does not supported in CORTEX M0\n"); k_fault_log_writer("fault diagnosis is not supported in CORTEX M0\n");
} }
/*------------------ RealView Compiler -----------------*/ /*------------------ RealView Compiler -----------------*/

View File

@@ -92,7 +92,7 @@ __PORT__ void port_standby_mode_enter(void)
#if TOS_CFG_FAULT_BACKTRACE_EN > 0u #if TOS_CFG_FAULT_BACKTRACE_EN > 0u
__PORT__ void port_fault_diagnosis(void) __PORT__ void port_fault_diagnosis(void)
{ {
// k_fault_log_writer("fault diagnosis does not supported in CORTEX M0\n"); // k_fault_log_writer("fault diagnosis is not supported in CORTEX a7\n");
} }
#if 0 #if 0

View File

@@ -95,7 +95,7 @@ __PORT__ void port_standby_mode_enter(void)
#if TOS_CFG_FAULT_BACKTRACE_EN > 0u #if TOS_CFG_FAULT_BACKTRACE_EN > 0u
__PORT__ void port_fault_diagnosis(void) __PORT__ void port_fault_diagnosis(void)
{ {
k_fault_log_writer("fault diagnosis does not supported in CORTEX M0\n"); k_fault_log_writer("fault diagnosis is not supported in CORTEX M0+\n");
} }
/*------------------ RealView Compiler -----------------*/ /*------------------ RealView Compiler -----------------*/
@@ -107,10 +107,16 @@ __PORT__ __ASM__ void HardFault_Handler(void)
IMPORT fault_backtrace IMPORT fault_backtrace
MOV r0, lr MOV r0, lr
TST lr, #0x04 MOVS r1, #0x04
ITE EQ TST r0, r1
MRSEQ r1, MSP BEQ _LD_MSP
MRSNE r1, PSP MRS r1, PSP
B _EXIT
_LD_MSP
MRS r1, MSP
_EXIT
BL fault_backtrace BL fault_backtrace
} }
@@ -121,10 +127,14 @@ __PORT__ void __NAKED__ HardFault_Handler(void)
{ {
__ASM__ __VOLATILE__ ( __ASM__ __VOLATILE__ (
"MOV r0, lr\n\t" "MOV r0, lr\n\t"
"TST lr, #0x04\n\t" "MOVS r1, #0x04\n\t"
"ITE EQ\n\t" "TST r0, r1\n\t"
"MRSEQ r1, MSP\n\t" "BEQ _LD_MSP\n\t"
"MRSNE r1, PSP\n\t" "MRS r1, PSP\n\t"
"B _EXIT\n\t"
"_LD_MSP:\n\t"
"MRS r1, MSP\n\t"
"_EXIT:\n\t"
"BL fault_backtrace\n\t" "BL fault_backtrace\n\t"
); );
} }

View File

@@ -95,7 +95,7 @@ __PORT__ void port_standby_mode_enter(void)
#if TOS_CFG_FAULT_BACKTRACE_EN > 0u #if TOS_CFG_FAULT_BACKTRACE_EN > 0u
__PORT__ void port_fault_diagnosis(void) __PORT__ void port_fault_diagnosis(void)
{ {
k_fault_log_writer("fault diagnosis does not supported in CORTEX M0\n"); k_fault_log_writer("fault diagnosis is not supported in CORTEX M0+\n");
} }
/*------------------ RealView Compiler -----------------*/ /*------------------ RealView Compiler -----------------*/

View File

@@ -95,7 +95,7 @@ __PORT__ void port_standby_mode_enter(void)
#if TOS_CFG_FAULT_BACKTRACE_EN > 0u #if TOS_CFG_FAULT_BACKTRACE_EN > 0u
__PORT__ void port_fault_diagnosis(void) __PORT__ void port_fault_diagnosis(void)
{ {
k_fault_log_writer("fault diagnosis does not supported in CORTEX M0\n"); k_fault_log_writer("fault diagnosis is not supported in CORTEX M0+\n");
} }
/*------------------ RealView Compiler -----------------*/ /*------------------ RealView Compiler -----------------*/

View File

@@ -95,7 +95,7 @@ __PORT__ void port_standby_mode_enter(void)
#if TOS_CFG_FAULT_BACKTRACE_EN > 0u #if TOS_CFG_FAULT_BACKTRACE_EN > 0u
__PORT__ void port_fault_diagnosis(void) __PORT__ void port_fault_diagnosis(void)
{ {
k_fault_log_writer("fault diagnosis does not supported in CORTEX M0\n"); k_fault_log_writer("fault diagnosis is not supported in CORTEX M23\n");
} }
/*------------------ RealView Compiler -----------------*/ /*------------------ RealView Compiler -----------------*/

View File

@@ -16,7 +16,7 @@
*---------------------------------------------------------------------------*/ *---------------------------------------------------------------------------*/
#include "tos_k.h" #include "tos_k.h"
#include "core_cm0plus.h" #include "core_cm23.h"
__PORT__ void port_cpu_reset(void) __PORT__ void port_cpu_reset(void)
{ {
@@ -95,7 +95,7 @@ __PORT__ void port_standby_mode_enter(void)
#if TOS_CFG_FAULT_BACKTRACE_EN > 0u #if TOS_CFG_FAULT_BACKTRACE_EN > 0u
__PORT__ void port_fault_diagnosis(void) __PORT__ void port_fault_diagnosis(void)
{ {
k_fault_log_writer("fault diagnosis does not supported in CORTEX M0\n"); k_fault_log_writer("fault diagnosis is not supported in CORTEX M23\n");
} }
/*------------------ RealView Compiler -----------------*/ /*------------------ RealView Compiler -----------------*/

View File

@@ -16,7 +16,7 @@
*---------------------------------------------------------------------------*/ *---------------------------------------------------------------------------*/
#include "tos_k.h" #include "tos_k.h"
#include "core_cm0plus.h" #include "core_cm23.h"
__PORT__ void port_cpu_reset(void) __PORT__ void port_cpu_reset(void)
{ {
@@ -95,7 +95,7 @@ __PORT__ void port_standby_mode_enter(void)
#if TOS_CFG_FAULT_BACKTRACE_EN > 0u #if TOS_CFG_FAULT_BACKTRACE_EN > 0u
__PORT__ void port_fault_diagnosis(void) __PORT__ void port_fault_diagnosis(void)
{ {
k_fault_log_writer("fault diagnosis does not supported in CORTEX M0\n"); k_fault_log_writer("fault diagnosis is not supported in CORTEX M23\n");
} }
/*------------------ RealView Compiler -----------------*/ /*------------------ RealView Compiler -----------------*/

View File

@@ -103,7 +103,7 @@ __PORT__ void port_standby_mode_enter(void)
#if TOS_CFG_FAULT_BACKTRACE_EN > 0u #if TOS_CFG_FAULT_BACKTRACE_EN > 0u
__PORT__ void port_fault_diagnosis(void) __PORT__ void port_fault_diagnosis(void)
{ {
k_fault_log_writer("fault diagnosis does not supported in MSP430\n"); k_fault_log_writer("fault diagnosis is not supported in MSP430\n");
} }