fix(coredump): do not build sources when coredump is not enabled

This commit is contained in:
Erhan Kurubas
2025-08-02 08:27:27 +03:00
parent 51f8f625ec
commit 50ab1bff4b
8 changed files with 42 additions and 25 deletions

View File

@@ -80,6 +80,7 @@ void esp_core_dump_init(void);
*/ */
void esp_core_dump_write(panic_info_t *info); void esp_core_dump_write(panic_info_t *info);
#if CONFIG_ESP_COREDUMP_ENABLE_TO_FLASH
/** /**
* @brief Check integrity of coredump data in flash. * @brief Check integrity of coredump data in flash.
* This function reads the coredump data while calculating their checksum. If it * This function reads the coredump data while calculating their checksum. If it
@@ -113,8 +114,6 @@ esp_err_t esp_core_dump_image_get(size_t* out_addr, size_t *out_size);
*/ */
esp_err_t esp_core_dump_image_erase(void); esp_err_t esp_core_dump_image_erase(void);
#if CONFIG_ESP_COREDUMP_ENABLE_TO_FLASH
/** /**
* @brief Get panic reason from the core dump. * @brief Get panic reason from the core dump.
* *

View File

@@ -1,11 +1,14 @@
/* /*
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
#include "sdkconfig.h"
#if CONFIG_ESP_COREDUMP_ENABLE
#include <string.h> #include <string.h>
#include <stdbool.h> #include <stdbool.h>
#include "sdkconfig.h"
#include "soc/soc_memory_layout.h" #include "soc/soc_memory_layout.h"
#include "freertos/FreeRTOS.h" #include "freertos/FreeRTOS.h"
#include "esp_private/freertos_debug.h" #include "esp_private/freertos_debug.h"
@@ -18,8 +21,6 @@
const static char TAG[] __attribute__((unused)) = "esp_core_dump_common"; const static char TAG[] __attribute__((unused)) = "esp_core_dump_common";
#if CONFIG_ESP_COREDUMP_ENABLE
#define COREDUMP_GET_MEMORY_SIZE(end, start) (end - start) #define COREDUMP_GET_MEMORY_SIZE(end, start) (end - start)
/** /**
@@ -345,4 +346,4 @@ void esp_core_dump_write(panic_info_t *info)
esp_core_dump_print_write_end(); esp_core_dump_print_write_end();
} }
#endif #endif // CONFIG_ESP_COREDUMP_ENABLE

View File

@@ -3,11 +3,14 @@
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
#include "sdkconfig.h"
#if CONFIG_ESP_COREDUMP_ENABLE
#include <string.h> #include <string.h>
#include "esp_attr.h" #include "esp_attr.h"
#include "esp_partition.h" #include "esp_partition.h"
#include "esp_flash_encrypt.h" #include "esp_flash_encrypt.h"
#include "sdkconfig.h"
#include "core_dump_checksum.h" #include "core_dump_checksum.h"
#include "esp_core_dump_port.h" #include "esp_core_dump_port.h"
#include "esp_core_dump_port_impl.h" #include "esp_core_dump_port_impl.h"
@@ -1021,3 +1024,5 @@ esp_err_t esp_core_dump_get_summary(esp_core_dump_summary_t *summary)
} }
#endif // CONFIG_ESP_COREDUMP_ENABLE_TO_FLASH #endif // CONFIG_ESP_COREDUMP_ENABLE_TO_FLASH
#endif // CONFIG_ESP_COREDUMP_ENABLE

View File

@@ -1,8 +1,12 @@
/* /*
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
#include "sdkconfig.h"
#if CONFIG_ESP_COREDUMP_ENABLE_TO_FLASH
#include <string.h> #include <string.h>
#include "esp_partition.h" #include "esp_partition.h"
#include "esp_log.h" #include "esp_log.h"
@@ -18,8 +22,6 @@
const static char TAG[] __attribute__((unused)) = "esp_core_dump_flash"; const static char TAG[] __attribute__((unused)) = "esp_core_dump_flash";
#if CONFIG_ESP_COREDUMP_ENABLE_TO_FLASH
typedef struct _core_dump_partition_t { typedef struct _core_dump_partition_t {
/* Core dump partition start. */ /* Core dump partition start. */
uint32_t start; uint32_t start;
@@ -398,8 +400,6 @@ esp_err_t esp_core_dump_image_check(void)
return ESP_OK; return ESP_OK;
} }
#endif
esp_err_t esp_core_dump_image_erase(void) esp_err_t esp_core_dump_image_erase(void)
{ {
/* If flash is encrypted, we can only write blocks of 16 bytes, let's always /* If flash is encrypted, we can only write blocks of 16 bytes, let's always
@@ -522,3 +522,5 @@ esp_err_t esp_core_dump_image_get(size_t* out_addr, size_t *out_size)
return ESP_OK; return ESP_OK;
} }
#endif // CONFIG_ESP_COREDUMP_ENABLE_TO_FLASH

View File

@@ -1,11 +1,12 @@
/* /*
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2024-2025 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
#include "sdkconfig.h" #include "sdkconfig.h"
#if CONFIG_ESP_COREDUMP_ENABLE
#include <string.h> #include <string.h>
#include "esp_core_dump_types.h" #include "esp_core_dump_types.h"
@@ -122,3 +123,5 @@ static uint32_t core_dump_sha_finish(core_dump_checksum_ctx cks_ctx, core_dump_c
return core_dump_sha_size(); return core_dump_sha_size();
} }
#endif // CONFIG_ESP_COREDUMP_ENABLE

View File

@@ -1,8 +1,12 @@
/* /*
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
#include "sdkconfig.h"
#if CONFIG_ESP_COREDUMP_ENABLE_TO_UART
#include <string.h> #include <string.h>
#include "soc/uart_reg.h" #include "soc/uart_reg.h"
#include "soc/gpio_periph.h" #include "soc/gpio_periph.h"
@@ -16,8 +20,6 @@
const static char TAG[] __attribute__((unused)) = "esp_core_dump_uart"; const static char TAG[] __attribute__((unused)) = "esp_core_dump_uart";
#if CONFIG_ESP_COREDUMP_ENABLE_TO_UART
void esp_core_dump_print_write_start(void) __attribute__((alias("esp_core_dump_uart_print_write_start"))); void esp_core_dump_print_write_start(void) __attribute__((alias("esp_core_dump_uart_print_write_start")));
void esp_core_dump_print_write_end(void) __attribute__((alias("esp_core_dump_uart_print_write_end"))); void esp_core_dump_print_write_end(void) __attribute__((alias("esp_core_dump_uart_print_write_end")));
esp_err_t esp_core_dump_write_init(void) __attribute__((alias("esp_core_dump_uart_hw_init"))); esp_err_t esp_core_dump_write_init(void) __attribute__((alias("esp_core_dump_uart_hw_init")));
@@ -176,4 +178,5 @@ void esp_core_dump_init(void)
{ {
ESP_COREDUMP_LOGI("Init core dump to UART"); ESP_COREDUMP_LOGI("Init core dump to UART");
} }
#endif
#endif // CONFIG_ESP_COREDUMP_ENABLE_TO_UART

View File

@@ -9,6 +9,10 @@
* @brief Core dump port implementation for RISC-V based boards. * @brief Core dump port implementation for RISC-V based boards.
*/ */
#include "sdkconfig.h"
#if CONFIG_ESP_COREDUMP_ENABLE
#include <string.h> #include <string.h>
#include <stdbool.h> #include <stdbool.h>
#include "soc/soc_memory_layout.h" #include "soc/soc_memory_layout.h"
@@ -29,8 +33,6 @@ const static char TAG[] __attribute__((unused)) = "esp_core_dump_port";
#define COREDUMP_FAKE_STACK_START 0x20000000U #define COREDUMP_FAKE_STACK_START 0x20000000U
#define COREDUMP_FAKE_STACK_LIMIT 0x30000000U #define COREDUMP_FAKE_STACK_LIMIT 0x30000000U
#if CONFIG_ESP_COREDUMP_ENABLE
#define min(a,b) ((a) < (b) ? (a) : (b)) #define min(a,b) ((a) < (b) ? (a) : (b))
#define max(a,b) ((a) < (b) ? (b) : (a)) #define max(a,b) ((a) < (b) ? (b) : (a))
@@ -447,4 +449,4 @@ void esp_core_dump_summary_parse_backtrace_info(esp_core_dump_bt_info_t *bt_info
#endif /* #if CONFIG_ESP_COREDUMP_ENABLE_TO_FLASH */ #endif /* #if CONFIG_ESP_COREDUMP_ENABLE_TO_FLASH */
#endif #endif /* CONFIG_ESP_COREDUMP_ENABLE_TO_FLASH */

View File

@@ -9,6 +9,10 @@
* @brief Core dump port implementation for Xtensa based boards. * @brief Core dump port implementation for Xtensa based boards.
*/ */
#include "sdkconfig.h"
#if CONFIG_ESP_COREDUMP_ENABLE
#include <string.h> #include <string.h>
#include <stdbool.h> #include <stdbool.h>
#include "soc/soc_memory_layout.h" #include "soc/soc_memory_layout.h"
@@ -121,8 +125,6 @@ typedef struct {
uint32_t reserved; uint32_t reserved;
} __attribute__((packed)) xtensa_elf_reg_dump_t; } __attribute__((packed)) xtensa_elf_reg_dump_t;
#if CONFIG_ESP_COREDUMP_ENABLE
static XtExcFrame s_fake_stack_frame = { static XtExcFrame s_fake_stack_frame = {
.pc = (UBaseType_t) COREDUMP_FAKE_STACK_START, // task entrypoint fake_ptr .pc = (UBaseType_t) COREDUMP_FAKE_STACK_START, // task entrypoint fake_ptr
.a0 = (UBaseType_t) 0, // to terminate GDB backtrace .a0 = (UBaseType_t) 0, // to terminate GDB backtrace
@@ -565,4 +567,4 @@ void esp_core_dump_summary_parse_backtrace_info(esp_core_dump_bt_info_t *bt_info
#endif /* #if CONFIG_ESP_COREDUMP_ENABLE_TO_FLASH */ #endif /* #if CONFIG_ESP_COREDUMP_ENABLE_TO_FLASH */
#endif #endif /* CONFIG_ESP_COREDUMP_ENABLE_TO_FLASH */