mirror of
https://github.com/espressif/esp-idf.git
synced 2026-04-27 11:03:11 +00:00
Merge branch 'fix/log-dram-early-direct-rom-printf' into 'master'
fix(esp_log): Add Kconfig option to disable usage of esp_rom_vprintf when this function is in IRAM and not ROM Closes IDFGH-17376 See merge request espressif/esp-idf!46640
This commit is contained in:
@@ -194,6 +194,7 @@ The following options will reduce IRAM usage of some ESP-IDF features:
|
||||
- Disable :ref:`CONFIG_LIBC_LOCKS_PLACE_IN_IRAM` if no ISRs that run while cache is disabled (i.e. IRAM ISRs) use libc lock APIs.
|
||||
:CONFIG_ESP_ROM_HAS_SUBOPTIMAL_NEWLIB_ON_MISALIGNED_MEMORY: - Disable :ref:`CONFIG_LIBC_OPTIMIZED_MISALIGNED_ACCESS` to save approximately 1000 bytes of IRAM, at the cost of reduced performance.
|
||||
:SOC_SPIRAM_SUPPORTED: - Enable :ref:`CONFIG_ESP_EVENT_LOOP_IN_EXT_RAM` to force ``esp_event`` to place event loop related allocations in external RAM instead of internal RAM.
|
||||
:not CONFIG_ESP_ROM_HAS_VPRINTF_FUNC: - When using **Log V2**, disable :ref:`CONFIG_LOG_API_CONSTRAINED_ENV_SAFE` to remove ``esp_rom_vprintf`` from IRAM, saving ~1.2 KB. This means ``ESP_LOGx`` will no longer safely fall back to ROM-based printing in ISRs or with cache disabled. Use ``ESP_DRAM_LOGx`` explicitly for constrained-environment logging. See :doc:`/api-reference/system/log` for details.
|
||||
|
||||
.. only:: esp32
|
||||
|
||||
|
||||
@@ -656,6 +656,23 @@ The following measurements were performed using the ``esp_timer`` example with d
|
||||
|
||||
Enabling **Log V2** increases IRAM usage while reducing the overall application binary size, Flash code, and data usage.
|
||||
|
||||
.. only:: not CONFIG_ESP_ROM_HAS_VPRINTF_FUNC
|
||||
|
||||
Reducing IRAM Usage in Log V2
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
The IRAM increase in **Log V2** is primarily caused by ``esp_rom_vprintf``, which is compiled into IRAM (~1.2 KB) on {IDF_TARGET_NAME}. This function is referenced as the fallback formatter for constrained environments (ISR, cache disabled) in the ``esp_log_vprintf()`` inline function.
|
||||
|
||||
On chips where IRAM and DRAM share the same memory pool, this also reduces available heap by the same amount.
|
||||
|
||||
To eliminate this cost, disable :ref:`CONFIG_LOG_API_CONSTRAINED_ENV_SAFE` (enabled by default). When disabled:
|
||||
|
||||
- ``ESP_DRAM_LOGx`` and ``ESP_EARLY_LOGx`` expand directly to ``esp_rom_printf()`` (a true ROM function, zero IRAM cost), bypassing the ``esp_log()`` pipeline entirely.
|
||||
- Normal ``ESP_LOGx`` calls in constrained environments (ISR, cache disabled) will use the standard ``vprintf`` function. If ``vprintf`` resides in flash, such calls may crash. Use ``ESP_DRAM_LOGx`` for any logging that must work with cache disabled or from an ISR.
|
||||
- ``esp_rom_vprintf`` is never referenced, so the linker excludes it from the binary.
|
||||
|
||||
When enabled, the original **Log V2** behavior is preserved: all constrained-environment logs route through ``esp_log()`` and use ``esp_rom_vprintf`` as the formatter for early/DRAM logs.
|
||||
|
||||
Logging to Host via JTAG
|
||||
------------------------
|
||||
|
||||
|
||||
Reference in New Issue
Block a user