Skip to content

Commit 4f90f3c

Browse files
committed
Merge branch 'coredump_conditional_builds' into 'master'
change(coredump): make conditional build in cmake based on config options Closes IDF-13794 See merge request espressif/esp-idf!41698
2 parents ffad794 + 0d97c63 commit 4f90f3c

File tree

15 files changed

+55
-71
lines changed

15 files changed

+55
-71
lines changed

components/espcoredump/CMakeLists.txt

Lines changed: 36 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,36 +4,46 @@ if(${target} STREQUAL "linux")
44
return() # This component is not supported by the POSIX/Linux simulator
55
endif()
66

7-
set(srcs "src/core_dump_init.c"
8-
"src/core_dump_common.c"
9-
"src/core_dump_flash.c"
10-
"src/core_dump_uart.c"
11-
"src/core_dump_elf.c"
12-
"src/core_dump_sha.c")
7+
set(srcs "")
8+
set(includes "")
9+
set(priv_includes "")
10+
set(priv_requires
11+
esp_partition spi_flash bootloader_support mbedtls esp_rom soc esp_system esp_driver_gpio esp_app_format)
1312

14-
set(includes "include")
15-
set(priv_includes "include_core_dump")
13+
if(CONFIG_ESP_COREDUMP_ENABLE)
14+
list(APPEND srcs "src/core_dump_init.c"
15+
"src/core_dump_common.c"
16+
"src/core_dump_elf.c"
17+
"src/core_dump_sha.c")
1618

17-
idf_build_get_property(target IDF_TARGET)
19+
if(CONFIG_ESP_COREDUMP_ENABLE_TO_UART)
20+
list(APPEND srcs "src/core_dump_uart.c")
21+
elseif(CONFIG_ESP_COREDUMP_ENABLE_TO_FLASH)
22+
list(APPEND srcs "src/core_dump_flash.c")
23+
endif()
1824

19-
if(CONFIG_IDF_TARGET_ARCH_XTENSA)
20-
list(APPEND srcs "src/port/xtensa/core_dump_port.c")
21-
list(APPEND includes "include/port/xtensa")
22-
list(APPEND priv_includes "include_core_dump/port/xtensa")
23-
elseif(CONFIG_IDF_TARGET_ARCH_RISCV)
24-
list(APPEND srcs "src/port/riscv/core_dump_port.c")
25-
list(APPEND includes "include/port/riscv")
26-
list(APPEND priv_includes "include_core_dump/port/riscv")
27-
endif()
25+
list(APPEND includes "include")
26+
list(APPEND priv_includes "include_core_dump")
2827

29-
idf_component_register(SRCS ${srcs}
30-
INCLUDE_DIRS ${includes}
31-
PRIV_INCLUDE_DIRS ${priv_includes}
32-
LDFRAGMENTS linker.lf
33-
PRIV_REQUIRES esp_partition spi_flash bootloader_support mbedtls esp_rom soc esp_system
34-
esp_driver_gpio
35-
)
28+
if(CONFIG_IDF_TARGET_ARCH_XTENSA)
29+
list(APPEND srcs "src/port/xtensa/core_dump_port.c")
30+
list(APPEND includes "include/port/xtensa")
31+
list(APPEND priv_includes "include_core_dump/port/xtensa")
32+
elseif(CONFIG_IDF_TARGET_ARCH_RISCV)
33+
list(APPEND srcs "src/port/riscv/core_dump_port.c")
34+
list(APPEND includes "include/port/riscv")
35+
list(APPEND priv_includes "include_core_dump/port/riscv")
36+
endif()
37+
38+
idf_component_register(SRCS ${srcs}
39+
INCLUDE_DIRS ${includes}
40+
PRIV_INCLUDE_DIRS ${priv_includes}
41+
LDFRAGMENTS linker.lf
42+
PRIV_REQUIRES ${priv_requires}
43+
)
3644

3745
# make sure 'core_dump_init' object file is considered by the linker
3846
target_link_libraries(${COMPONENT_LIB} INTERFACE "-u esp_system_include_coredump_init")
39-
target_link_libraries(${COMPONENT_LIB} PRIVATE idf::esp_app_format)
47+
else()
48+
idf_component_register(PRIV_REQUIRES ${priv_requires})
49+
endif()

components/espcoredump/include/esp_core_dump.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#include <stddef.h>
1111
#include "esp_err.h"
1212
#include "esp_private/panic_internal.h"
13-
#include "esp_core_dump_summary_port.h"
1413

1514
#ifdef __cplusplus
1615
extern "C" {
@@ -20,6 +19,8 @@ extern "C" {
2019

2120
#if CONFIG_ESP_COREDUMP_ENABLE_TO_FLASH
2221

22+
#include "esp_core_dump_summary_port.h"
23+
2324
/**
2425
* @brief Core dump summary, Most meaningful contents of the core dump
2526
* are accommodated in this structure

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

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

15-
#if CONFIG_ESP_COREDUMP_ENABLE_TO_FLASH
16-
1715
/**
1816
* @brief Backtrace information
1917
*
@@ -40,8 +38,6 @@ typedef struct {
4038
uint32_t exc_a[8]; /* A0-A7 registers when the exception caused */
4139
} esp_core_dump_summary_extra_info_t;
4240

43-
#endif /* CONFIG_ESP_COREDUMP_ENABLE_TO_FLASH */
44-
4541
#ifdef __cplusplus
4642
}
4743
#endif

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

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

16-
#if CONFIG_ESP_COREDUMP_ENABLE_TO_FLASH
17-
1816
#define EPCx_REGISTER_COUNT XCHAL_NUM_INTLEVELS
1917

2018
/**
@@ -39,8 +37,6 @@ typedef struct {
3937
uint8_t epcx_reg_bits; /*!< Bit mask of available EPCx registers */
4038
} esp_core_dump_summary_extra_info_t;
4139

42-
#endif /* CONFIG_ESP_COREDUMP_ENABLE_TO_FLASH */
43-
4440
#ifdef __cplusplus
4541
}
4642
#endif

components/espcoredump/src/core_dump_common.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
*/
66
#include "sdkconfig.h"
77

8-
#if CONFIG_ESP_COREDUMP_ENABLE
9-
108
#include <string.h>
119
#include <stdbool.h>
1210
#include "soc/soc_memory_layout.h"
@@ -345,5 +343,3 @@ void esp_core_dump_write(panic_info_t *info)
345343
esp_core_dump_write_internal(info);
346344
esp_core_dump_print_write_end();
347345
}
348-
349-
#endif // CONFIG_ESP_COREDUMP_ENABLE

components/espcoredump/src/core_dump_elf.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
*/
66
#include "sdkconfig.h"
77

8-
#if CONFIG_ESP_COREDUMP_ENABLE
9-
108
#include <string.h>
119
#include "esp_attr.h"
1210
#include "esp_partition.h"
@@ -1061,5 +1059,3 @@ esp_err_t esp_core_dump_get_summary(esp_core_dump_summary_t *summary)
10611059
}
10621060

10631061
#endif // CONFIG_ESP_COREDUMP_ENABLE_TO_FLASH
1064-
1065-
#endif // CONFIG_ESP_COREDUMP_ENABLE

components/espcoredump/src/core_dump_flash.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
*/
66
#include "sdkconfig.h"
77

8-
#if CONFIG_ESP_COREDUMP_ENABLE_TO_FLASH
9-
108
#include <string.h>
119
#include "esp_partition.h"
1210
#include "esp_log.h"
@@ -522,5 +520,3 @@ esp_err_t esp_core_dump_image_get(size_t* out_addr, size_t *out_size)
522520

523521
return ESP_OK;
524522
}
525-
526-
#endif // CONFIG_ESP_COREDUMP_ENABLE_TO_FLASH

components/espcoredump/src/core_dump_init.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
*/
66
#include "sdkconfig.h"
77

8-
#if CONFIG_ESP_COREDUMP_ENABLE
9-
108
#include "esp_private/startup_internal.h"
119
#include "esp_core_dump.h"
1210

@@ -20,5 +18,3 @@ ESP_SYSTEM_INIT_FN(init_coredump, SECONDARY, BIT(0), 130)
2018
esp_core_dump_init();
2119
return ESP_OK;
2220
}
23-
24-
#endif /* CONFIG_ESP_COREDUMP_ENABLE */

components/espcoredump/src/core_dump_sha.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
*/
66
#include "sdkconfig.h"
77

8-
#if CONFIG_ESP_COREDUMP_ENABLE
9-
108
#include <string.h>
119
#include "esp_core_dump_types.h"
1210

@@ -123,5 +121,3 @@ static uint32_t core_dump_sha_finish(core_dump_checksum_ctx cks_ctx, core_dump_c
123121

124122
return core_dump_sha_size();
125123
}
126-
127-
#endif // CONFIG_ESP_COREDUMP_ENABLE

components/espcoredump/src/core_dump_uart.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
*/
66
#include "sdkconfig.h"
77

8-
#if CONFIG_ESP_COREDUMP_ENABLE_TO_UART
9-
108
#include <string.h>
119
#include "soc/uart_reg.h"
1210
#include "soc/gpio_periph.h"
@@ -178,5 +176,3 @@ void esp_core_dump_init(void)
178176
{
179177
ESP_COREDUMP_LOGI("Init core dump to UART");
180178
}
181-
182-
#endif // CONFIG_ESP_COREDUMP_ENABLE_TO_UART

0 commit comments

Comments
 (0)