Skip to content

Commit 7e5fb84

Browse files
gneworldGUIDINGLI
authored andcommitted
coredump: add architecture-specific registers dump, including NVIC and MPU
Signed-off-by: wanggang26 <[email protected]>
1 parent 39690a9 commit 7e5fb84

File tree

13 files changed

+167
-3
lines changed

13 files changed

+167
-3
lines changed

arch/arm/Kconfig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1288,6 +1288,13 @@ config ARM_MPU_EARLY_RESET
12881288

12891289
Note: This can be used without MPU Support enabled.
12901290

1291+
config ARM_COREDUMP_REGION
1292+
bool "Add coredump region"
1293+
depends on COREDUMP
1294+
default n
1295+
---help---
1296+
Add coredump region includes nvic and mpu for cortex-M.
1297+
12911298
config ARCH_HAVE_LOWVECTORS
12921299
bool
12931300

arch/arm/src/armv6-m/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ set(SRCS
3232
arm_trigger_irq.c
3333
arm_vectors.c)
3434

35-
if(CONFIG_DEBUG_FEATURES)
35+
if((DEFINED CONFIG_DEBUG_FEATURES AND CONFIG_DEBUG_FEATURES)
36+
OR (DEFINED CONFIG_ARM_COREDUMP_REGION AND CONFIG_ARM_COREDUMP_REGION))
3637
list(APPEND SRCS arm_dumpnvic.c)
3738
endif()
3839

arch/arm/src/armv6-m/Make.defs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ CMN_CSRCS += arm_schedulesigaction.c arm_sigdeliver.c arm_svcall.c
2929
CMN_CSRCS += arm_systemreset.c arm_tcbinfo.c arm_vectors.c
3030
CMN_CSRCS += arm_trigger_irq.c
3131

32-
ifeq ($(CONFIG_DEBUG_FEATURES),y)
32+
ifneq ($(filter y,$(CONFIG_DEBUG_FEATURES)$(CONFIG_ARM_COREDUMP_REGION)),)
3333
CMN_CSRCS += arm_dumpnvic.c
3434
endif
3535

arch/arm/src/armv6-m/arm_dumpnvic.c

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
****************************************************************************/
2424

2525
#include <nuttx/config.h>
26-
26+
#include <nuttx/coredump.h>
2727
#include <sys/types.h>
2828
#include <debug.h>
2929

@@ -87,3 +87,22 @@ void arm_dumpnvic(const char *msg)
8787
}
8888

8989
#endif /* CONFIG_DEBUG_FEATURES */
90+
91+
#ifdef CONFIG_ARM_COREDUMP_REGION
92+
93+
/****************************************************************************
94+
* Function: arm_coredump_add_region
95+
*
96+
* Description:
97+
* Dump all NVIC registers during a core dump.
98+
*
99+
****************************************************************************/
100+
101+
void arm_coredump_add_region(void)
102+
{
103+
coredump_add_memory_region((uint32_t *)ARMV6M_NVIC1_BASE,
104+
ARMV6M_NVIC_IPR7 + 4 - ARMV6M_NVIC1_BASE,
105+
PF_REGISTER);
106+
}
107+
108+
#endif /* CONFIG_ARM_COREDUMP_REGION */

arch/arm/src/armv7-m/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,8 @@ if(CONFIG_ARM_MPU OR CONFIG_ARM_MPU_EARLY_RESET)
6666
list(APPEND SRCS arm_mpu.c)
6767
endif()
6868

69+
if(CONFIG_ARM_COREDUMP_REGION)
70+
list(APPEND SRCS arm_dumpnvic.c)
71+
endif()
72+
6973
target_sources(arch PRIVATE ${SRCS})

arch/arm/src/armv7-m/Make.defs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,7 @@ endif
5555
ifneq ($(filter y,$(CONFIG_ARM_MPU) $(CONFIG_ARM_MPU_EARLY_RESET)),)
5656
CMN_CSRCS += arm_mpu.c
5757
endif
58+
59+
ifeq ($(CONFIG_ARM_COREDUMP_REGION),y)
60+
CMN_CSRCS += arm_dumpnvic.c
61+
endif

arch/arm/src/armv7-m/arm_dumpnvic.c

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/****************************************************************************
2+
* arch/arm/src/armv7-m/arm_dumpnvic.c
3+
*
4+
* Licensed to the Apache Software Foundation (ASF) under one or more
5+
* contributor license agreements. See the NOTICE file distributed with
6+
* this work for additional information regarding copyright ownership. The
7+
* ASF licenses this file to you under the Apache License, Version 2.0 (the
8+
* "License"); you may not use this file except in compliance with the
9+
* License. You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
15+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
16+
* License for the specific language governing permissions and limitations
17+
* under the License.
18+
*
19+
****************************************************************************/
20+
21+
/****************************************************************************
22+
* Included Files
23+
****************************************************************************/
24+
25+
#include <nuttx/config.h>
26+
#include <nuttx/coredump.h>
27+
#include <sys/types.h>
28+
#include <debug.h>
29+
30+
#include <nuttx/irq.h>
31+
32+
#include "arm_internal.h"
33+
#include "nvic.h"
34+
35+
/****************************************************************************
36+
* Public Functions
37+
****************************************************************************/
38+
39+
#ifdef CONFIG_ARM_COREDUMP_REGION
40+
41+
/****************************************************************************
42+
* Function: arm_coredump_add_region
43+
*
44+
* Description:
45+
* Dump all NVIC registers during a core dump.
46+
*
47+
****************************************************************************/
48+
49+
void arm_coredump_add_region(void)
50+
{
51+
coredump_add_memory_region((uint32_t *)ARMV7M_NVIC_BASE,
52+
NVIC_CID3 + 4 - ARMV7M_NVIC_BASE,
53+
PF_REGISTER);
54+
}
55+
56+
#endif /* CONFIG_ARM_COREDUMP_REGION */

arch/arm/src/armv8-m/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,8 @@ if(CONFIG_ARCH_TRUSTZONE_SECURE)
7171
list(APPEND SRCS arm_gen_nonsecfault.c)
7272
endif()
7373

74+
if(CONFIG_ARM_COREDUMP_REGION)
75+
list(APPEND SRCS arm_dumpnvic.c)
76+
endif()
77+
7478
target_sources(arch PRIVATE ${SRCS})

arch/arm/src/armv8-m/Make.defs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,7 @@ endif
6060
ifeq ($(CONFIG_ARCH_TRUSTZONE_SECURE),y)
6161
CMN_CSRCS += arm_gen_nonsecfault.c
6262
endif
63+
64+
ifeq ($(CONFIG_ARM_COREDUMP_REGION),y)
65+
CMN_CSRCS += arm_dumpnvic.c
66+
endif

arch/arm/src/armv8-m/arm_dumpnvic.c

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/****************************************************************************
2+
* arch/arm/src/armv8-m/arm_dumpnvic.c
3+
*
4+
* Licensed to the Apache Software Foundation (ASF) under one or more
5+
* contributor license agreements. See the NOTICE file distributed with
6+
* this work for additional information regarding copyright ownership. The
7+
* ASF licenses this file to you under the Apache License, Version 2.0 (the
8+
* "License"); you may not use this file except in compliance with the
9+
* License. You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
15+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
16+
* License for the specific language governing permissions and limitations
17+
* under the License.
18+
*
19+
****************************************************************************/
20+
21+
/****************************************************************************
22+
* Included Files
23+
****************************************************************************/
24+
25+
#include <nuttx/config.h>
26+
#include <nuttx/coredump.h>
27+
#include <sys/types.h>
28+
#include <debug.h>
29+
30+
#include <nuttx/irq.h>
31+
32+
#include "arm_internal.h"
33+
#include "nvic.h"
34+
35+
/****************************************************************************
36+
* Public Functions
37+
****************************************************************************/
38+
39+
#ifdef CONFIG_ARM_COREDUMP_REGION
40+
41+
/****************************************************************************
42+
* Function: arm_coredump_add_region
43+
*
44+
* Description:
45+
* Dump all NVIC registers during a core dump.
46+
*
47+
****************************************************************************/
48+
49+
void arm_coredump_add_region(void)
50+
{
51+
coredump_add_memory_region((uint32_t *)ARMV8M_NVIC_BASE,
52+
NVIC_CID3 + 4 - ARMV8M_NVIC_BASE,
53+
PF_REGISTER);
54+
}
55+
56+
#endif /* CONFIG_ARM_COREDUMP_REGION */

0 commit comments

Comments
 (0)