Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions arch/arm/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -1288,6 +1288,13 @@ config ARM_MPU_EARLY_RESET

Note: This can be used without MPU Support enabled.

config ARM_COREDUMP_REGION
bool "Add coredump region"
depends on COREDUMP
default n
---help---
Add coredump region includes nvic and mpu for cortex-M.

config ARCH_HAVE_LOWVECTORS
bool

Expand Down
3 changes: 2 additions & 1 deletion arch/arm/src/armv6-m/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ set(SRCS
arm_trigger_irq.c
arm_vectors.c)

if(CONFIG_DEBUG_FEATURES)
if((DEFINED CONFIG_DEBUG_FEATURES AND CONFIG_DEBUG_FEATURES)
OR (DEFINED CONFIG_ARM_COREDUMP_REGION AND CONFIG_ARM_COREDUMP_REGION))
list(APPEND SRCS arm_dumpnvic.c)
endif()

Expand Down
2 changes: 1 addition & 1 deletion arch/arm/src/armv6-m/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ CMN_CSRCS += arm_schedulesigaction.c arm_sigdeliver.c arm_svcall.c
CMN_CSRCS += arm_systemreset.c arm_tcbinfo.c arm_vectors.c
CMN_CSRCS += arm_trigger_irq.c

ifeq ($(CONFIG_DEBUG_FEATURES),y)
ifneq ($(filter y,$(CONFIG_DEBUG_FEATURES)$(CONFIG_ARM_COREDUMP_REGION)),)
CMN_CSRCS += arm_dumpnvic.c
endif

Expand Down
21 changes: 20 additions & 1 deletion arch/arm/src/armv6-m/arm_dumpnvic.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
****************************************************************************/

#include <nuttx/config.h>

#include <nuttx/coredump.h>
#include <sys/types.h>
#include <debug.h>

Expand Down Expand Up @@ -87,3 +87,22 @@ void arm_dumpnvic(const char *msg)
}

#endif /* CONFIG_DEBUG_FEATURES */

#ifdef CONFIG_ARM_COREDUMP_REGION

/****************************************************************************
* Function: arm_coredump_add_region
*
* Description:
* Dump all NVIC registers during a core dump.
*
****************************************************************************/

void arm_coredump_add_region(void)
{
coredump_add_memory_region((uint32_t *)ARMV6M_NVIC1_BASE,
ARMV6M_NVIC_IPR7 + 4 - ARMV6M_NVIC1_BASE,
PF_REGISTER);
}

#endif /* CONFIG_ARM_COREDUMP_REGION */
4 changes: 4 additions & 0 deletions arch/arm/src/armv7-m/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,8 @@ if(CONFIG_ARM_MPU OR CONFIG_ARM_MPU_EARLY_RESET)
list(APPEND SRCS arm_mpu.c)
endif()

if(CONFIG_ARM_COREDUMP_REGION)
list(APPEND SRCS arm_dumpnvic.c)
endif()

target_sources(arch PRIVATE ${SRCS})
4 changes: 4 additions & 0 deletions arch/arm/src/armv7-m/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,7 @@ endif
ifneq ($(filter y,$(CONFIG_ARM_MPU) $(CONFIG_ARM_MPU_EARLY_RESET)),)
CMN_CSRCS += arm_mpu.c
endif

ifeq ($(CONFIG_ARM_COREDUMP_REGION),y)
CMN_CSRCS += arm_dumpnvic.c
endif
56 changes: 56 additions & 0 deletions arch/arm/src/armv7-m/arm_dumpnvic.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/****************************************************************************
* arch/arm/src/armv7-m/arm_dumpnvic.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/

/****************************************************************************
* Included Files
****************************************************************************/

#include <nuttx/config.h>
#include <nuttx/coredump.h>
#include <sys/types.h>
#include <debug.h>

#include <nuttx/irq.h>

#include "arm_internal.h"
#include "nvic.h"

/****************************************************************************
* Public Functions
****************************************************************************/

#ifdef CONFIG_ARM_COREDUMP_REGION

/****************************************************************************
* Function: arm_coredump_add_region
*
* Description:
* Dump all NVIC registers during a core dump.
*
****************************************************************************/

void arm_coredump_add_region(void)
{
coredump_add_memory_region((uint32_t *)ARMV7M_NVIC_BASE,
NVIC_CID3 + 4 - ARMV7M_NVIC_BASE,
PF_REGISTER);
}

#endif /* CONFIG_ARM_COREDUMP_REGION */
4 changes: 4 additions & 0 deletions arch/arm/src/armv8-m/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,8 @@ if(CONFIG_ARCH_TRUSTZONE_SECURE)
list(APPEND SRCS arm_gen_nonsecfault.c)
endif()

if(CONFIG_ARM_COREDUMP_REGION)
list(APPEND SRCS arm_dumpnvic.c)
endif()

target_sources(arch PRIVATE ${SRCS})
4 changes: 4 additions & 0 deletions arch/arm/src/armv8-m/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,7 @@ endif
ifeq ($(CONFIG_ARCH_TRUSTZONE_SECURE),y)
CMN_CSRCS += arm_gen_nonsecfault.c
endif

ifeq ($(CONFIG_ARM_COREDUMP_REGION),y)
CMN_CSRCS += arm_dumpnvic.c
endif
56 changes: 56 additions & 0 deletions arch/arm/src/armv8-m/arm_dumpnvic.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/****************************************************************************
* arch/arm/src/armv8-m/arm_dumpnvic.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/

/****************************************************************************
* Included Files
****************************************************************************/

#include <nuttx/config.h>
#include <nuttx/coredump.h>
#include <sys/types.h>
#include <debug.h>

#include <nuttx/irq.h>

#include "arm_internal.h"
#include "nvic.h"

/****************************************************************************
* Public Functions
****************************************************************************/

#ifdef CONFIG_ARM_COREDUMP_REGION

/****************************************************************************
* Function: arm_coredump_add_region
*
* Description:
* Dump all NVIC registers during a core dump.
*
****************************************************************************/

void arm_coredump_add_region(void)
{
coredump_add_memory_region((uint32_t *)ARMV8M_NVIC_BASE,
NVIC_CID3 + 4 - ARMV8M_NVIC_BASE,
PF_REGISTER);
}

#endif /* CONFIG_ARM_COREDUMP_REGION */
4 changes: 4 additions & 0 deletions arch/arm/src/common/arm_initialize.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,10 @@ void up_initialize(void)
arm_usbinitialize();
#endif

#ifdef CONFIG_ARM_COREDUMP_REGION
arm_coredump_add_region();
#endif

/* Initialize the L2 cache if present and selected */

arm_l2ccinitialize();
Expand Down
4 changes: 4 additions & 0 deletions arch/arm/src/common/arm_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,10 @@ int arm_gen_nonsecurefault(int irq, uint32_t *regs);
void arm_stack_check_init(void) noinstrument_function;
#endif

#ifdef CONFIG_ARM_COREDUMP_REGION
void arm_coredump_add_region(void);
#endif

#undef EXTERN
#ifdef __cplusplus
}
Expand Down
1 change: 1 addition & 0 deletions include/nuttx/coredump.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

#include <nuttx/streams.h>
#include <nuttx/memoryregion.h>
#include <nuttx/elf.h>

/****************************************************************************
* Pre-processor Definitions
Expand Down