Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ set(CORE_SRCS
cores/esp32/esp32-hal-i2c-ng.c
cores/esp32/esp32-hal-i2c-slave.c
cores/esp32/esp32-hal-ledc.c
cores/esp32/esp32-hal-log-wrapper.c
cores/esp32/esp32-hal-matrix.c
cores/esp32/esp32-hal-misc.c
cores/esp32/esp32-hal-periman.c
Expand Down Expand Up @@ -426,6 +427,13 @@ if(CONFIG_AUTOSTART_ARDUINO)
target_link_libraries(${COMPONENT_LIB} INTERFACE "-u _Z5setupv -u _Z4loopv")
endif()

# Add linker wrap flags for esp_log functions when CONFIG_DIAG_USE_EXTERNAL_LOG_WRAP is not enabled
# This provides wrapper functions required by WiFi library even when esp_diagnostics is not active
if(NOT CONFIG_DIAG_USE_EXTERNAL_LOG_WRAP)
target_link_libraries(${COMPONENT_LIB} INTERFACE "-Wl,--wrap=esp_log_write")
target_link_libraries(${COMPONENT_LIB} INTERFACE "-Wl,--wrap=esp_log_writev")
endif()

# This function adds a dependency on the given component if the component is included into the build.
function(maybe_add_component component_name)
idf_build_get_property(components BUILD_COMPONENTS)
Expand Down
42 changes: 42 additions & 0 deletions cores/esp32/esp32-hal-log-wrapper.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/

#include "sdkconfig.h"

/*
* This file provides wrapper implementations for esp_log_write and esp_log_writev
* when CONFIG_DIAG_USE_EXTERNAL_LOG_WRAP is not enabled.
*
* When CONFIG_DIAG_USE_EXTERNAL_LOG_WRAP is enabled, the esp_diagnostics component
* provides these wrappers. However, when it's disabled, WiFi libraries still expect
* these wrapper functions to exist, causing linker errors.
*
* This implementation provides simple pass-through wrappers that call the real
* ESP-IDF logging functions, ensuring compatibility without requiring esp_diagnostics.
*/

#ifndef CONFIG_DIAG_USE_EXTERNAL_LOG_WRAP

#include <stdarg.h>
#include "esp_log.h"

// Declare the real functions that will be wrapped by the linker
void __real_esp_log_write(esp_log_level_t level, const char *tag, const char *format, ...);
void __real_esp_log_writev(esp_log_level_t level, const char *tag, const char *format, va_list args);

// Wrapper implementations that simply call through to the real functions
void __wrap_esp_log_write(esp_log_level_t level, const char *tag, const char *format, ...) {
va_list args;
va_start(args, format);
__real_esp_log_writev(level, tag, format, args);
va_end(args);
Comment thread
lucasssvaz marked this conversation as resolved.
}

void __wrap_esp_log_writev(esp_log_level_t level, const char *tag, const char *format, va_list args) {
__real_esp_log_writev(level, tag, format, args);
}

#endif // !CONFIG_DIAG_USE_EXTERNAL_LOG_WRAP
5 changes: 0 additions & 5 deletions idf_component_examples/hello_world/sdkconfig.defaults
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,3 @@ CONFIG_AUTOSTART_ARDUINO=y
CONFIG_FREERTOS_HZ=1000
# end of FREERTOS
# end of Component config

#
# DIAGNOSTICS
#
CONFIG_DIAG_USE_EXTERNAL_LOG_WRAP=y
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,3 @@ CONFIG_AUTOSTART_ARDUINO=y
CONFIG_FREERTOS_HZ=1000
# end of FREERTOS
# end of Component config

#
# DIAGNOSTICS
#
CONFIG_DIAG_USE_EXTERNAL_LOG_WRAP=y
Loading