From 207ac93d43857c3b4f636b91cc0979a446b5e90c Mon Sep 17 00:00:00 2001 From: Vikram Date: Mon, 6 Mar 2023 11:36:06 +0530 Subject: [PATCH 1/2] Optionally disable logs in espcoredump component Early log strings used by this component are placed in DRAM. Disabling these logs saves ~5KB of internal memory Signed-off-by: Vikram --- components/espcoredump/Kconfig | 8 ++++++++ .../espcoredump/include_core_dump/esp_core_dump_types.h | 7 ++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/components/espcoredump/Kconfig b/components/espcoredump/Kconfig index 623fc059ac1..88fe1db45b4 100644 --- a/components/espcoredump/Kconfig +++ b/components/espcoredump/Kconfig @@ -63,6 +63,14 @@ menu "Core dump" help Enables/disable core dump module. + config ESP_COREDUMP_LOGS + bool "Enable coredump logs for debugging" + depends on ESP_COREDUMP_ENABLE + default y + help + Enable/disable coredump logs. Logs strings from espcoredump component are + placed in DRAM. Disabling these helps to save ~5KB of internal memory. + config ESP_COREDUMP_MAX_TASKS_NUM int "Maximum number of tasks" depends on ESP_COREDUMP_ENABLE diff --git a/components/espcoredump/include_core_dump/esp_core_dump_types.h b/components/espcoredump/include_core_dump/esp_core_dump_types.h index 94949467dcd..869e47c5eaf 100644 --- a/components/espcoredump/include_core_dump/esp_core_dump_types.h +++ b/components/espcoredump/include_core_dump/esp_core_dump_types.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -18,7 +18,12 @@ extern "C" { #include "esp_private/panic_internal.h" #include "core_dump_checksum.h" +#if CONFIG_ESP_COREDUMP_LOGS #define ESP_COREDUMP_LOG( level, format, ... ) if (LOG_LOCAL_LEVEL >= level) { esp_rom_printf(DRAM_STR(format), esp_log_early_timestamp(), (const char *)TAG, ##__VA_ARGS__); } +#else +#define ESP_COREDUMP_LOG( level, format, ... ) // dummy define doing nothing +#endif + #define ESP_COREDUMP_LOGE( format, ... ) ESP_COREDUMP_LOG(ESP_LOG_ERROR, LOG_FORMAT(E, format), ##__VA_ARGS__) #define ESP_COREDUMP_LOGW( format, ... ) ESP_COREDUMP_LOG(ESP_LOG_WARN, LOG_FORMAT(W, format), ##__VA_ARGS__) #define ESP_COREDUMP_LOGI( format, ... ) ESP_COREDUMP_LOG(ESP_LOG_INFO, LOG_FORMAT(I, format), ##__VA_ARGS__) From 7687c5200cf0a1b621f474db6a00ee49269c7426 Mon Sep 17 00:00:00 2001 From: Vikram Date: Wed, 24 May 2023 17:48:33 +0530 Subject: [PATCH 2/2] Added description to disable coredump logs to ram_usage.rst Signed-off-by: Vikram --- docs/en/api-guides/performance/ram-usage.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/en/api-guides/performance/ram-usage.rst b/docs/en/api-guides/performance/ram-usage.rst index 5d8b8ab44dc..a24c695c50f 100644 --- a/docs/en/api-guides/performance/ram-usage.rst +++ b/docs/en/api-guides/performance/ram-usage.rst @@ -39,6 +39,7 @@ To minimize static memory use: - Declare structures, buffers, or other variables ``const`` whenever possible. Constant data can be stored in flash not RAM. This may require changing functions in the firmware to take ``const *`` arguments instead of mutable pointer arguments. These changes can also reduce the stack usage of some functions. :SOC_BT_SUPPORTED: - If using Bluedroid, setting the option :ref:`CONFIG_BT_BLE_DYNAMIC_ENV_MEMORY` will cause Bluedroid to allocate memory on initialization and free it on deinitialization. This doesn't necessarily reduce the peak memory usage, but changes it from static memory usage to runtime memory usage. + - If :doc:`Coredump ` component is enabled, `ESP_COREDUMP_LOG` macros will use ~5KB internal memory to place strings into DRAM. By disabling :ref:`CONFIG_ESP_COREDUMP_LOGS` option, these logs are disabled and the memory is reclaimed. .. _optimize-stack-sizes: