Skip to content

Commit 521f3e3

Browse files
committed
Merge branch 'coredump_breaking_changes' into 'master'
change(coredump): drop binary format and crc checksum Closes IDF-9020 and IDFGH-14364 See merge request espressif/esp-idf!40324
2 parents 4e03698 + d1df341 commit 521f3e3

File tree

49 files changed

+110
-612
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+110
-612
lines changed

components/espcoredump/CMakeLists.txt

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ set(srcs "src/core_dump_init.c"
99
"src/core_dump_flash.c"
1010
"src/core_dump_uart.c"
1111
"src/core_dump_elf.c"
12-
"src/core_dump_binary.c"
13-
"src/core_dump_sha.c"
14-
"src/core_dump_crc.c")
12+
"src/core_dump_sha.c")
1513

1614
set(includes "include")
1715
set(priv_includes "include_core_dump")
@@ -38,7 +36,4 @@ idf_component_register(SRCS ${srcs}
3836

3937
# make sure 'core_dump_init' object file is considered by the linker
4038
target_link_libraries(${COMPONENT_LIB} INTERFACE "-u esp_system_include_coredump_init")
41-
42-
if(CONFIG_ESP_COREDUMP_DATA_FORMAT_ELF)
43-
target_link_libraries(${COMPONENT_LIB} PRIVATE idf::esp_app_format)
44-
endif()
39+
target_link_libraries(${COMPONENT_LIB} PRIVATE idf::esp_app_format)

components/espcoredump/Kconfig

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -22,35 +22,10 @@ menu "Core dump"
2222
bool "None"
2323
endchoice
2424

25-
choice ESP_COREDUMP_DATA_FORMAT
26-
prompt "Core dump data format"
27-
default ESP_COREDUMP_DATA_FORMAT_ELF
28-
depends on !ESP_COREDUMP_ENABLE_TO_NONE
29-
help
30-
Select the data format for core dump.
31-
config ESP_COREDUMP_DATA_FORMAT_BIN
32-
bool "Binary format"
33-
config ESP_COREDUMP_DATA_FORMAT_ELF
34-
bool "ELF format"
35-
endchoice
36-
37-
choice ESP_COREDUMP_CHECKSUM
38-
prompt "Core dump data integrity check"
39-
default ESP_COREDUMP_CHECKSUM_CRC32
40-
depends on !ESP_COREDUMP_ENABLE_TO_NONE
41-
help
42-
Select the integrity check for the core dump.
43-
config ESP_COREDUMP_CHECKSUM_CRC32
44-
bool "Use CRC32 for integrity verification"
45-
config ESP_COREDUMP_CHECKSUM_SHA256
46-
bool "Use SHA256 for integrity verification"
47-
depends on ESP_COREDUMP_DATA_FORMAT_ELF
48-
endchoice
49-
5025
config ESP_COREDUMP_CAPTURE_DRAM
5126
bool "Include whole .bss and .data sections and heap data into core dump file"
5227
default n
53-
depends on ESP_COREDUMP_DATA_FORMAT_ELF
28+
depends on ESP_COREDUMP_ENABLE
5429
help
5530
Storing these sections can help with easier debugging and troubleshooting.
5631
However, additional storage space will be required in the core dump partition.
@@ -69,6 +44,8 @@ menu "Core dump"
6944
config ESP_COREDUMP_ENABLE
7045
bool
7146
default F
47+
select ESP_COREDUMP_DATA_FORMAT_ELF
48+
select ESP_COREDUMP_CHECKSUM_SHA256
7249
help
7350
Enables/disable core dump module.
7451

@@ -129,7 +106,7 @@ menu "Core dump"
129106

130107
config ESP_COREDUMP_SUMMARY_STACKDUMP_SIZE
131108
int "Size of the stack dump buffer"
132-
depends on ESP_COREDUMP_DATA_FORMAT_ELF && ESP_COREDUMP_ENABLE_TO_FLASH && IDF_TARGET_ARCH_RISCV
109+
depends on ESP_COREDUMP_ENABLE_TO_FLASH && IDF_TARGET_ARCH_RISCV
133110
range 512 4096
134111
default 1024
135112
help

components/espcoredump/include/esp_core_dump.h

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -18,7 +18,7 @@ extern "C" {
1818

1919
#define APP_ELF_SHA256_SZ (CONFIG_APP_RETRIEVE_LEN_ELF_SHA + 1)
2020

21-
#if CONFIG_ESP_COREDUMP_ENABLE_TO_FLASH && CONFIG_ESP_COREDUMP_DATA_FORMAT_ELF
21+
#if CONFIG_ESP_COREDUMP_ENABLE_TO_FLASH
2222

2323
/**
2424
* @brief Core dump summary, Most meaningful contents of the core dump
@@ -34,7 +34,7 @@ typedef struct {
3434
esp_core_dump_summary_extra_info_t ex_info; /*!< Architecture specific extra data */
3535
} esp_core_dump_summary_t;
3636

37-
#endif /* CONFIG_ESP_COREDUMP_ENABLE_TO_FLASH && CONFIG_ESP_COREDUMP_DATA_FORMAT_ELF */
37+
#endif /* CONFIG_ESP_COREDUMP_ENABLE_TO_FLASH */
3838

3939
/**************************************************************************************/
4040
/******************************** EXCEPTION MODE API **********************************/
@@ -52,27 +52,17 @@ void esp_core_dump_init(void);
5252
/**************************************************************************************/
5353

5454
/**
55-
* Core dump file consists of header and data (in binary or ELF format) for every task in the system at the moment of crash.
55+
* Core dump file consists of header and data (in ELF format) for every task in the system at the moment of crash.
5656
* For the data integrity, a checksum is used at the end of core the dump data.
5757
* The structure of core dump file is described below in details.
5858
* 1) Core dump starts with header:
5959
* 1.1) TOTAL_LEN is total length of core dump data in flash including the checksum. Size is 4 bytes.
6060
* 1.2) VERSION field keeps 4 byte version of core dump.
61-
* 1.2) TASKS_NUM is the number of tasks for which data are stored. Size is 4 bytes. Unused in ELF format
62-
* 1.3) TCB_SIZE is the size of task's TCB structure. Size is 4 bytes. Unused in ELF format
63-
* 1.4) MEM_SEG_NUM is the number of memory segment. Size is 4 bytes. Unused in ELF format
64-
* 1.5) CHIP_REV is the revision of the chip. Size is 4 bytes.
65-
* 2) Core dump header is followed by the data for every task in the system. Data part is differs for the binary
66-
* and elf formats.
61+
* 1.3) CHIP_REV is the revision of the chip. Size is 4 bytes.
62+
* 2) Core dump header is followed by the data for every task in the system.
6763
* 2.1) The core dump file uses a subset of the ELF structures to store the crash information.
6864
* Loadable ELF segments and ELF notes (ELF.PT_NOTE) used with a special name and type (CORE, NT_PRSTATUS type)
69-
* 2.2) In Binary format task data are started with the task header:
70-
* 2.2.1) TCB_ADDR is the address of TCB in memory. Size is 4 bytes.
71-
* 2.2.2) STACK_TOP is the top of task's stack (address of the topmost stack item). Size is 4 bytes.
72-
* 2.2.3) STACK_END is the end of task's stack (address from which task's stack starts). Size is 4 bytes.
73-
* 2.2.4) Task header is followed by TCB data. Size is TCB_SIZE bytes.
74-
* 2.2.5) Task's stack is placed after TCB data. Size is (STACK_END - STACK_TOP) bytes.
75-
* 2.3) The checksum is placed at the end of the data.
65+
* 2.2) The checksum is placed at the end of the data.
7666
* 3) The structure of the uart data is the same as the data stored in flash
7767
* 3.1) Uart data is printed in base64 format surrounded with special messages to help user recognize the start and
7868
* end of actual data.
@@ -123,7 +113,7 @@ esp_err_t esp_core_dump_image_get(size_t* out_addr, size_t *out_size);
123113
*/
124114
esp_err_t esp_core_dump_image_erase(void);
125115

126-
#if CONFIG_ESP_COREDUMP_ENABLE_TO_FLASH && CONFIG_ESP_COREDUMP_DATA_FORMAT_ELF
116+
#if CONFIG_ESP_COREDUMP_ENABLE_TO_FLASH
127117

128118
/**
129119
* @brief Get panic reason from the core dump.
@@ -171,7 +161,7 @@ esp_err_t esp_core_dump_get_panic_reason(char *reason_buffer, size_t buffer_size
171161
*/
172162
esp_err_t esp_core_dump_get_summary(esp_core_dump_summary_t *summary);
173163

174-
#endif /* CONFIG_ESP_COREDUMP_ENABLE_TO_FLASH && CONFIG_ESP_COREDUMP_DATA_FORMAT_ELF */
164+
#endif /* CONFIG_ESP_COREDUMP_ENABLE_TO_FLASH */
175165

176166
#ifdef __cplusplus
177167
}

components/espcoredump/include/port/riscv/esp_core_dump_summary_port.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ extern "C"
1212
{
1313
#endif
1414

15-
#if CONFIG_ESP_COREDUMP_ENABLE_TO_FLASH && CONFIG_ESP_COREDUMP_DATA_FORMAT_ELF
15+
#if CONFIG_ESP_COREDUMP_ENABLE_TO_FLASH
1616

1717
/**
1818
* @brief Backtrace information
@@ -40,7 +40,7 @@ typedef struct {
4040
uint32_t exc_a[8]; /* A0-A7 registers when the exception caused */
4141
} esp_core_dump_summary_extra_info_t;
4242

43-
#endif /* CONFIG_ESP_COREDUMP_ENABLE_TO_FLASH && CONFIG_ESP_COREDUMP_DATA_FORMAT_ELF */
43+
#endif /* CONFIG_ESP_COREDUMP_ENABLE_TO_FLASH */
4444

4545
#ifdef __cplusplus
4646
}

components/espcoredump/include/port/xtensa/esp_core_dump_summary_port.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ extern "C"
1313
{
1414
#endif
1515

16-
#if CONFIG_ESP_COREDUMP_ENABLE_TO_FLASH && CONFIG_ESP_COREDUMP_DATA_FORMAT_ELF
16+
#if CONFIG_ESP_COREDUMP_ENABLE_TO_FLASH
1717

1818
#define EPCx_REGISTER_COUNT XCHAL_NUM_INTLEVELS
1919

@@ -39,7 +39,7 @@ typedef struct {
3939
uint8_t epcx_reg_bits; /*!< Bit mask of available EPCx registers */
4040
} esp_core_dump_summary_extra_info_t;
4141

42-
#endif /* CONFIG_ESP_COREDUMP_ENABLE_TO_FLASH && CONFIG_ESP_COREDUMP_DATA_FORMAT_ELF */
42+
#endif /* CONFIG_ESP_COREDUMP_ENABLE_TO_FLASH */
4343

4444
#ifdef __cplusplus
4545
}

components/espcoredump/include_core_dump/core_dump_checksum.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -10,8 +10,7 @@
1010
*
1111
* This file contains all the functions required by the core dump component to
1212
* calculate checksums for data to write (or already written) on the flash.
13-
* Currently, both CRC32 and SHA256 are supported, but this interface is
14-
* implementation independent.
13+
* Currently, only SHA256 is supported.
1514
*/
1615

1716
#ifndef CORE_DUMP_CHECKSUM_H_
@@ -25,7 +24,7 @@ extern "C" {
2524

2625
/**
2726
* @brief Maximum possible length for a checksum (regardless of the
28-
* implentation). This can be modified in the future if a new implementation
27+
* implementation). This can be modified in the future if a new implementation
2928
* requires a larger size.
3029
*/
3130
#define COREDUMP_CHECKSUM_MAX_LEN 32

components/espcoredump/include_core_dump/esp_core_dump_common.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,9 @@ esp_err_t esp_core_dump_write_data(core_dump_write_data_t *wr_data, void *data,
137137
esp_err_t esp_core_dump_write_end(core_dump_write_data_t *wr_data);
138138

139139
/**
140-
* @brief Stores the core dump in either binary or ELF format.
140+
* @brief Stores the core dump in ELF format.
141141
*/
142-
esp_err_t esp_core_dump_store(void);
142+
esp_err_t esp_core_dump_write_elf(void);
143143

144144
/**
145145
* @brief Get TCB length, in bytes.

components/espcoredump/include_core_dump/esp_core_dump_port.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,10 @@ uint32_t esp_core_dump_get_stack(core_dump_task_header_t* task_snapshot,
106106
* @note The goal of this function is to check whether the task passed is the
107107
* task that crashed or not. If this is the case and if it didn't crash
108108
* within an ISR, its stack pointer will be set to the panic frame,
109-
* containing all the registers values when the error occured. This
109+
* containing all the registers values when the error occurred. This
110110
* function also checks if the TCB address is sane or not.
111111
*
112-
* @param task Pointer to the frame exception generated when the panic occured.
112+
* @param task Pointer to the frame exception generated when the panic occurred.
113113
*
114114
* @return True if the TCB is sane, false else.
115115
*/
@@ -120,7 +120,7 @@ bool esp_core_dump_check_task(core_dump_task_header_t *task);
120120
*
121121
* @note In practice, this function is used to fill the ELF file with the
122122
* PR_STATUS sections for all the existing tasks. This structure
123-
* contains the CPU registers value when the exception occured.
123+
* contains the CPU registers value when the exception occurred.
124124
*
125125
* @param task Task to dump the registers from.
126126
* @param reg_dump Pointer that will be filled with the registers dump.
@@ -152,7 +152,7 @@ void esp_core_dump_port_set_crashed_tcb(uint32_t handle);
152152
*/
153153
uint32_t esp_core_dump_get_extra_info(void **info);
154154

155-
#if CONFIG_ESP_COREDUMP_ENABLE_TO_FLASH && CONFIG_ESP_COREDUMP_DATA_FORMAT_ELF
155+
#if CONFIG_ESP_COREDUMP_ENABLE_TO_FLASH
156156

157157
/**
158158
* @brief Parse extra information into summary
@@ -180,7 +180,7 @@ void esp_core_dump_summary_parse_exc_regs(esp_core_dump_summary_t *summary, void
180180
*/
181181
void esp_core_dump_summary_parse_backtrace_info(esp_core_dump_bt_info_t *bt_info, const void *vaddr,
182182
const void *paddr, uint32_t stack_size);
183-
#endif /* CONFIG_ESP_COREDUMP_ENABLE_TO_FLASH && CONFIG_ESP_COREDUMP_DATA_FORMAT_ELF */
183+
#endif /* CONFIG_ESP_COREDUMP_ENABLE_TO_FLASH */
184184

185185
#ifdef __cplusplus
186186
}

components/espcoredump/include_core_dump/esp_core_dump_types.h

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -66,14 +66,9 @@ extern "C" {
6666
(((_maj_)&0xFF) << 8) | \
6767
(((_min_)&0xFF) << 0) \
6868
)
69-
#define COREDUMP_VERSION_BIN 0
7069
#define COREDUMP_VERSION_ELF 1
7170

72-
/* legacy bin coredumps (before IDF v4.1) has version set to 1 */
73-
#define COREDUMP_VERSION_BIN_LEGACY COREDUMP_VERSION_MAKE(COREDUMP_VERSION_BIN, 1) // -> 0x0001
74-
#define COREDUMP_VERSION_BIN_CURRENT COREDUMP_VERSION_MAKE(COREDUMP_VERSION_BIN, 3) // -> 0x0003
75-
#define COREDUMP_VERSION_ELF_CRC32 COREDUMP_VERSION_MAKE(COREDUMP_VERSION_ELF, 2) // -> 0x0102
76-
#define COREDUMP_VERSION_ELF_SHA256 COREDUMP_VERSION_MAKE(COREDUMP_VERSION_ELF, 3) // -> 0x0103
71+
#define COREDUMP_VERSION_ELF_SHA256 COREDUMP_VERSION_MAKE(COREDUMP_VERSION_ELF, 4) // -> 0x0104
7772
#define COREDUMP_CURR_TASK_MARKER 0xDEADBEEF
7873
#define COREDUMP_CURR_TASK_NOT_FOUND -1
7974

@@ -93,17 +88,6 @@ extern "C" {
9388

9489
typedef uint32_t core_dump_crc_t;
9590

96-
#if CONFIG_ESP_COREDUMP_CHECKSUM_CRC32
97-
98-
typedef struct {
99-
core_dump_crc_t crc;
100-
uint32_t total_bytes_checksum; /* Number of bytes used to calculate the checksum */
101-
} core_dump_crc_ctx_t;
102-
103-
typedef core_dump_crc_ctx_t checksum_ctx_t;
104-
105-
#else
106-
10791
#if CONFIG_IDF_TARGET_ESP32
10892
#include "mbedtls/sha256.h" /* mbedtls_sha256_context */
10993
typedef mbedtls_sha256_context sha256_ctx_t;
@@ -122,8 +106,6 @@ typedef struct {
122106

123107
typedef core_dump_sha_ctx_t checksum_ctx_t;
124108

125-
#endif
126-
127109
/**
128110
* @brief Chip ID associated to this implementation.
129111
*/
@@ -138,13 +120,10 @@ typedef struct _core_dump_write_data_t {
138120

139121
/**
140122
* @brief Core dump data header
141-
* This header predecesses the actual core dump data (ELF or binary). */
123+
* This header predecesses the actual core dump data (ELF). */
142124
typedef struct _core_dump_header_t {
143125
uint32_t data_len; /*!< Data length */
144126
uint32_t version; /*!< Core dump version */
145-
uint32_t tasks_num; /*!< Number of tasks */
146-
uint32_t tcb_sz; /*!< Size of a TCB, in bytes */
147-
uint32_t mem_segs_num; /*!< Number of memory segments */
148127
uint32_t chip_rev; /*!< Chip revision */
149128
} core_dump_header_t;
150129

components/espcoredump/linker.lf

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ entries:
4242
core_dump_common (noflash)
4343
core_dump_port (noflash)
4444
core_dump_elf (noflash)
45-
core_dump_binary (noflash)
46-
core_dump_crc (noflash)
4745
# ESP32 uses mbedtls for the sha and mbedtls is in the flash
4846
if IDF_TARGET_ESP32 = n:
4947
core_dump_sha (noflash)

0 commit comments

Comments
 (0)