You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by je...@apache.org on 2021/06/28 10:50:40 UTC
[mynewt-core] branch master updated: hw/bsp/nordic_pca10095: Add
reduced size crash dumps
This is an automated email from the ASF dual-hosted git repository.
jerzy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git
The following commit(s) were added to refs/heads/master by this push:
new 1dd1ee4 hw/bsp/nordic_pca10095: Add reduced size crash dumps
1dd1ee4 is described below
commit 1dd1ee4db8292574df02a2725bc7e9ae31de9857
Author: Jerzy Kasenberg <je...@codecoup.pl>
AuthorDate: Thu Jun 24 10:55:40 2021 +0200
hw/bsp/nordic_pca10095: Add reduced size crash dumps
So far crash dumps had whole RAM image stored in flash.
If flash area assigned to coredumps were to small, end
of RAM was not dumped (including interrupt stack).
This adds possibility to skip dumping unused heap space.
This can reduce size of core dumps.
---
hw/bsp/nordic_pca10095/src/hal_bsp.c | 15 +++++++++++++++
hw/bsp/nordic_pca10095/syscfg.yml | 7 +++++++
hw/bsp/nordic_pca10095_net/src/hal_bsp.c | 15 +++++++++++++++
hw/bsp/nordic_pca10095_net/syscfg.yml | 7 +++++++
4 files changed, 44 insertions(+)
diff --git a/hw/bsp/nordic_pca10095/src/hal_bsp.c b/hw/bsp/nordic_pca10095/src/hal_bsp.c
index 23a7f2e..38e6dde 100644
--- a/hw/bsp/nordic_pca10095/src/hal_bsp.c
+++ b/hw/bsp/nordic_pca10095/src/hal_bsp.c
@@ -33,12 +33,18 @@
/*
* What memory to include in coredump.
*/
+#if !MYNEWT_VAL(COREDUMP_SKIP_UNUSED_HEAP)
static const struct hal_bsp_mem_dump dump_cfg[] = {
[0] = {
.hbmd_start = &_ram_start,
.hbmd_size = RAM_SIZE
}
};
+#else
+static struct hal_bsp_mem_dump dump_cfg[2];
+extern uint8_t __StackLimit;
+extern uint8_t __StackTop;
+#endif
const struct hal_flash *
hal_bsp_flash_dev(uint8_t id)
@@ -60,6 +66,15 @@ hal_bsp_flash_dev(uint8_t id)
const struct hal_bsp_mem_dump *
hal_bsp_core_dump(int *area_cnt)
{
+#if MYNEWT_VAL(COREDUMP_SKIP_UNUSED_HEAP)
+ /* Interrupt stack first */
+ dump_cfg[0].hbmd_start = &__StackLimit;
+ dump_cfg[0].hbmd_size = &__StackTop - &__StackLimit;
+ /* RAM from _ram_start to end of used heap */
+ dump_cfg[1].hbmd_start = &_ram_start;
+ dump_cfg[1].hbmd_size = (uint8_t *)_sbrk(0) - &_ram_start;
+#endif
+
*area_cnt = sizeof(dump_cfg) / sizeof(dump_cfg[0]);
return dump_cfg;
}
diff --git a/hw/bsp/nordic_pca10095/syscfg.yml b/hw/bsp/nordic_pca10095/syscfg.yml
index 25b462f..a3a09de 100644
--- a/hw/bsp/nordic_pca10095/syscfg.yml
+++ b/hw/bsp/nordic_pca10095/syscfg.yml
@@ -30,6 +30,13 @@ syscfg.defs:
When enabled Network Core of nRF5340 is started on init.
value: 0
+ COREDUMP_SKIP_UNUSED_HEAP:
+ description: >
+ Store whole RAM in crash dump.
+ When 1 only part of heap that was used will be dumped, that
+ can reduce size of crash dump.
+ value: 0
+
syscfg.vals:
# Set default pins for peripherals
UART_0_PIN_TX: 20
diff --git a/hw/bsp/nordic_pca10095_net/src/hal_bsp.c b/hw/bsp/nordic_pca10095_net/src/hal_bsp.c
index e0b1845..2c3445d 100644
--- a/hw/bsp/nordic_pca10095_net/src/hal_bsp.c
+++ b/hw/bsp/nordic_pca10095_net/src/hal_bsp.c
@@ -34,12 +34,18 @@
/*
* What memory to include in coredump.
*/
+#if !MYNEWT_VAL(COREDUMP_SKIP_UNUSED_HEAP)
static const struct hal_bsp_mem_dump dump_cfg[] = {
[0] = {
.hbmd_start = &_ram_start,
.hbmd_size = RAM_SIZE
}
};
+#else
+static struct hal_bsp_mem_dump dump_cfg[2];
+extern uint8_t __StackLimit;
+extern uint8_t __StackTop;
+#endif
const struct hal_flash *
hal_bsp_flash_dev(uint8_t id)
@@ -62,6 +68,15 @@ hal_bsp_flash_dev(uint8_t id)
const struct hal_bsp_mem_dump *
hal_bsp_core_dump(int *area_cnt)
{
+#if MYNEWT_VAL(COREDUMP_SKIP_UNUSED_HEAP)
+ /* Interrupt stack first */
+ dump_cfg[0].hbmd_start = &__StackLimit;
+ dump_cfg[0].hbmd_size = &__StackTop - &__StackLimit;
+ /* RAM from _ram_start to end of used heap */
+ dump_cfg[1].hbmd_start = &_ram_start;
+ dump_cfg[1].hbmd_size = (uint8_t *)_sbrk(0) - &_ram_start;
+#endif
+
*area_cnt = sizeof(dump_cfg) / sizeof(dump_cfg[0]);
return dump_cfg;
}
diff --git a/hw/bsp/nordic_pca10095_net/syscfg.yml b/hw/bsp/nordic_pca10095_net/syscfg.yml
index 1952147..dcb3a56 100644
--- a/hw/bsp/nordic_pca10095_net/syscfg.yml
+++ b/hw/bsp/nordic_pca10095_net/syscfg.yml
@@ -21,6 +21,13 @@ syscfg.defs:
description: 'Set to indicate that BSP has NRF5340 NET'
value: 1
+ COREDUMP_SKIP_UNUSED_HEAP:
+ description: >
+ Store whole RAM in crash dump.
+ When 1 only part of heap that was used will be dumped, that
+ can reduce size of crash dump.
+ value: 0
+
syscfg.vals:
# Set default pins for peripherals
UART_0_PIN_TX: 20