diff --git a/components/esp_common/CMakeLists.txt b/components/esp_common/CMakeLists.txt index 827c6ead46..ba77a6b87f 100644 --- a/components/esp_common/CMakeLists.txt +++ b/components/esp_common/CMakeLists.txt @@ -1,9 +1,11 @@ idf_build_get_property(target IDF_TARGET) if(${target} STREQUAL "linux") - # Header only library for linux - idf_component_register(INCLUDE_DIRS include) - return() + set(ldfragments) + set(srcs "src/esp_err_check_linux.c") +else() + set(ldfragments common.lf soc.lf) + set(srcs) endif() list(APPEND srcs "src/esp_err_to_name.c") @@ -11,7 +13,7 @@ list(APPEND srcs "src/esp_err_to_name.c") # Note: esp_ipc, esp_pm added as a public requirement to keep compatibility as to be located here. idf_component_register(SRCS "${srcs}" INCLUDE_DIRS include - LDFRAGMENTS "common.lf" "soc.lf") + LDFRAGMENTS ${ldfragments}) set_property(TARGET ${COMPONENT_LIB} APPEND PROPERTY LINK_INTERFACE_MULTIPLICITY 4) diff --git a/components/nvs_flash/test_nvs_host/esp_error_check_stub.cpp b/components/esp_common/src/esp_err_check_linux.c similarity index 54% rename from components/nvs_flash/test_nvs_host/esp_error_check_stub.cpp rename to components/esp_common/src/esp_err_check_linux.c index 34d8704e7b..fec85070db 100644 --- a/components/nvs_flash/test_nvs_host/esp_error_check_stub.cpp +++ b/components/esp_common/src/esp_err_check_linux.c @@ -1,4 +1,14 @@ -#include "catch.hpp" +/* + * SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + * + * This file provides a simple version of _esp_error_check_failed which is used on Linux target. + * For chip targets, esp_system component provides an implementation which uses esp_rom_printf and + * takes the possibility of the cache being disabled into account. + */ +#include +#include #include "esp_err.h" #include "sdkconfig.h" diff --git a/components/esp_common/src/esp_err_to_name.c b/components/esp_common/src/esp_err_to_name.c index 2001b036d2..b8352c4d0e 100644 --- a/components/esp_common/src/esp_err_to_name.c +++ b/components/esp_common/src/esp_err_to_name.c @@ -7,6 +7,10 @@ //Do not edit this file because it is autogenerated by gen_esp_err_to_name.py #include +#if __has_include() +// for strlcpy +#include +#endif #include "esp_err.h" #if __has_include("soc/soc.h") #include "soc/soc.h" diff --git a/components/esp_common/src/esp_err_to_name.c.in b/components/esp_common/src/esp_err_to_name.c.in index 56a48ee28f..389600d536 100644 --- a/components/esp_common/src/esp_err_to_name.c.in +++ b/components/esp_common/src/esp_err_to_name.c.in @@ -7,6 +7,10 @@ @COMMENT@ #include +#if __has_include() +// for strlcpy +#include +#endif #include "esp_err.h" #if __has_include("soc/soc.h") #include "soc/soc.h" diff --git a/components/nvs_flash/test_nvs_host/Makefile b/components/nvs_flash/test_nvs_host/Makefile index 10669bfb6f..a7843759f5 100644 --- a/components/nvs_flash/test_nvs_host/Makefile +++ b/components/nvs_flash/test_nvs_host/Makefile @@ -2,7 +2,6 @@ TEST_PROGRAM=test_nvs all: $(TEST_PROGRAM) SOURCE_FILES = \ - esp_error_check_stub.cpp \ $(addprefix ../src/, \ nvs_types.cpp \ nvs_api.cpp \ @@ -30,7 +29,7 @@ SOURCE_FILES = \ test_nvs_initialization.cpp \ main.cpp -SOURCE_FILES_C = ../../esp_rom/linux/esp_rom_crc.c +SOURCE_FILES_C = ../../esp_rom/linux/esp_rom_crc.c ../../esp_common/src/esp_err_check_linux.c ifeq ($(shell $(CC) -v 2>&1 | grep -c "clang version"), 1) COMPILER := clang diff --git a/examples/protocols/sockets/tcp_client/components/esp_stubs/esp_stubs/esp_stubs.c b/examples/protocols/sockets/tcp_client/components/esp_stubs/esp_stubs/esp_stubs.c index 42ef914aaf..51141e0bc5 100644 --- a/examples/protocols/sockets/tcp_client/components/esp_stubs/esp_stubs/esp_stubs.c +++ b/examples/protocols/sockets/tcp_client/components/esp_stubs/esp_stubs/esp_stubs.c @@ -9,14 +9,6 @@ extern void app_main(void); -void _esp_error_check_failed(esp_err_t rc, const char *file, int line, const char *function, const char *expression) -{ - ESP_LOGE("ESP_ERROR_CHECK", "Failed with esp_err_t: 0x%x", rc); - ESP_LOGE("ESP_ERROR_CHECK", "Expression: %s", expression); - ESP_LOGE("ESP_ERROR_CHECK", "Functions: %s %s(%d)", function, file, line); - abort(); -} - esp_err_t esp_event_loop_create_default(void) { return ESP_OK;