Skip to content

Commit f8dc035

Browse files
authored
Merge pull request #11139 from sethitow/stm32f413-crash-capture
STM32F413 Crash Capture
2 parents 174cac7 + 4c4b95e commit f8dc035

File tree

5 files changed

+53
-7
lines changed

5 files changed

+53
-7
lines changed

platform/mbed_lib.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,10 @@
228228
"DISCO_F407VG": {
229229
"crash-capture-enabled": true,
230230
"fatal-error-auto-reboot-enabled": true
231+
},
232+
"DISCO_F413ZH": {
233+
"crash-capture-enabled": true,
234+
"fatal-error-auto-reboot-enabled": true
231235
}
232236
}
233237
}

targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F413xH/device/TOOLCHAIN_ARM_MICRO/stm32f413xh.sct

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,12 @@
5454
; Total: 118 vectors = 472 bytes (0x1D8) to be reserved in RAM
5555
#define VECTOR_SIZE 0x1D8
5656

57-
#define RAM_FIXED_SIZE (MBED_BOOT_STACK_SIZE+VECTOR_SIZE)
57+
#define MBED_CRASH_REPORT_RAM_SIZE 0x100
58+
59+
#define MBED_IRAM1_START (MBED_RAM_START + VECTOR_SIZE + MBED_CRASH_REPORT_RAM_SIZE)
60+
#define MBED_IRAM1_SIZE (MBED_RAM_SIZE - VECTOR_SIZE - MBED_CRASH_REPORT_RAM_SIZE)
61+
62+
#define RAM_FIXED_SIZE (MBED_BOOT_STACK_SIZE+VECTOR_SIZE+MBED_CRASH_REPORT_RAM_SIZE)
5863

5964
LR_IROM1 MBED_APP_START MBED_APP_SIZE { ; load region size_region
6065

@@ -64,7 +69,11 @@ LR_IROM1 MBED_APP_START MBED_APP_SIZE { ; load region size_region
6469
.ANY (+RO)
6570
}
6671

67-
RW_IRAM1 (MBED_RAM_START+VECTOR_SIZE) (MBED_RAM_SIZE-VECTOR_SIZE) { ; RW data
72+
RW_m_crash_data (MBED_RAM_START+VECTOR_SIZE) EMPTY MBED_CRASH_REPORT_RAM_SIZE { ; RW data
73+
}
74+
75+
76+
RW_IRAM1 MBED_IRAM1_START MBED_IRAM1_SIZE { ; RW data
6877
.ANY (+RW +ZI)
6978
}
7079

targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F413xH/device/TOOLCHAIN_ARM_STD/stm32f413xh.sct

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,17 @@
4343

4444
#define Stack_Size MBED_BOOT_STACK_SIZE
4545

46+
#define MBED_RAM_START 0x20000000
47+
; 320KB SRAM (0x50000)
48+
#define MBED_RAM_SIZE 0x50000
49+
#define MBED_VECTTABLE_RAM_START (MBED_RAM_START)
50+
; Total: 118 vectors = 472 bytes (0x1D8) to be reserved in RAM
51+
#define MBED_VECTTABLE_RAM_SIZE 0x1D8
52+
#define MBED_CRASH_REPORT_RAM_START (MBED_VECTTABLE_RAM_START + MBED_VECTTABLE_RAM_SIZE)
53+
#define MBED_CRASH_REPORT_RAM_SIZE 0x100
54+
#define MBED_RAM0_START (MBED_CRASH_REPORT_RAM_START + MBED_CRASH_REPORT_RAM_SIZE)
55+
#define MBED_RAM0_SIZE (MBED_RAM_SIZE - MBED_VECTTABLE_RAM_SIZE - MBED_CRASH_REPORT_RAM_SIZE)
56+
4657
LR_IROM1 MBED_APP_START MBED_APP_SIZE { ; load region size_region
4758

4859
ER_IROM1 MBED_APP_START MBED_APP_SIZE { ; load address = execution address
@@ -51,13 +62,14 @@ LR_IROM1 MBED_APP_START MBED_APP_SIZE { ; load region size_region
5162
.ANY (+RO)
5263
}
5364

54-
; 320KB SRAM (0x50000)
55-
; Total: 118 vectors = 472 bytes (0x1D8) to be reserved in RAM
56-
RW_IRAM1 (0x20000000+0x1D8) (0x50000-0x1D8-Stack_Size) { ; RW data
65+
RW_m_crash_data MBED_CRASH_REPORT_RAM_START EMPTY MBED_CRASH_REPORT_RAM_SIZE { ; RW data
66+
}
67+
68+
RW_IRAM1 (MBED_RAM0_START) (MBED_RAM0_SIZE-Stack_Size) { ; RW data
5769
.ANY (+RW +ZI)
5870
}
5971

60-
ARM_LIB_STACK (0x20000000+0x50000) EMPTY -Stack_Size { ; stack
72+
ARM_LIB_STACK (MBED_RAM0_START+MBED_RAM0_SIZE) EMPTY -Stack_Size { ; stack
6173
}
6274
}
6375

targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F413xH/device/TOOLCHAIN_GCC_ARM/STM32F413xH.ld

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212

1313
STACK_SIZE = MBED_BOOT_STACK_SIZE;
1414

15+
M_CRASH_DATA_RAM_SIZE = 0x100;
16+
1517
/* Linker script to configure memory regions. */
1618
MEMORY
1719
{
@@ -91,6 +93,18 @@ SECTIONS
9193
__etext = .;
9294
_sidata = .;
9395

96+
.crash_data_ram :
97+
{
98+
. = ALIGN(8);
99+
__CRASH_DATA_RAM__ = .;
100+
__CRASH_DATA_RAM_START__ = .; /* Create a global symbol at data start */
101+
KEEP(*(.keep.crash_data_ram))
102+
*(.m_crash_data_ram) /* This is a user defined section */
103+
. += M_CRASH_DATA_RAM_SIZE;
104+
. = ALIGN(8);
105+
__CRASH_DATA_RAM_END__ = .; /* Define a global symbol at data end */
106+
} > RAM
107+
94108
.data : AT (__etext)
95109
{
96110
__data_start__ = .;

targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F413xH/device/TOOLCHAIN_IAR/stm32f413xx.icf

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,21 @@ define symbol __region_ROM_end__ = MBED_APP_START + MBED_APP_SIZE - 1;
99
/* [RAM = 320kb = 0x50000] Vector table dynamic copy: 118 vectors = 472 bytes (0x1D8) to be reserved in RAM */
1010
define symbol __NVIC_start__ = 0x20000000;
1111
define symbol __NVIC_end__ = 0x200001D7;
12-
define symbol __region_RAM_start__ = 0x200001D8; /* Aligned on 8 bytes */
12+
define symbol __region_CRASH_DATA_RAM_start__ = 0x200001D8;
13+
define symbol __region_CRASH_DATA_RAM_end__ = 0x200002D7;
14+
define symbol __region_RAM_start__ = 0x200002D8; /* Aligned on 8 bytes */
1315
define symbol __region_RAM_end__ = 0x2004FFFF;
1416

1517
/* Memory regions */
1618
define memory mem with size = 4G;
1719
define region ROM_region = mem:[from __region_ROM_start__ to __region_ROM_end__];
20+
define region CRASH_DATA_RAM_region = mem:[from __region_CRASH_DATA_RAM_start__ to __region_CRASH_DATA_RAM_end__];
1821
define region RAM_region = mem:[from __region_RAM_start__ to __region_RAM_end__];
1922

23+
/* Define Crash Data Symbols */
24+
define exported symbol __CRASH_DATA_RAM_START__ = __region_CRASH_DATA_RAM_start__;
25+
define exported symbol __CRASH_DATA_RAM_END__ = __region_CRASH_DATA_RAM_end__;
26+
2027
/* Stack and Heap */
2128
if (!isdefinedsymbol(MBED_BOOT_STACK_SIZE)) {
2229
define symbol MBED_BOOT_STACK_SIZE = 0x400;

0 commit comments

Comments
 (0)