Merge branch 'feature/linux_esp_err_support' into 'master'

feat(esp_common): Support ESP_ERROR_CHECK_ macros on Linux

Closes IDFGH-12933

See merge request espressif/esp-idf!31320
This commit is contained in:
Konstantin Kondrashov 2024-06-06 22:17:28 +08:00
commit 391aabf73f
7 changed files with 40 additions and 6 deletions

View File

@ -2,13 +2,11 @@ idf_build_get_property(target IDF_TARGET)
if(${target} STREQUAL "linux")
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")
set(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}"

View File

@ -3,10 +3,12 @@ idf_build_get_property(target IDF_TARGET)
# On Linux, we only support a few features, hence this simple component registration
if(${target} STREQUAL "linux")
idf_component_register(SRCS "esp_system.c"
"esp_err.c"
"port/soc/linux/reset_reason.c"
"port/soc/linux/system_internal.c"
"port/esp_system_linux.c"
INCLUDE_DIRS "include")
INCLUDE_DIRS "include"
PRIV_REQUIRES spi_flash)
return()
endif()

View File

@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@ -108,6 +108,27 @@ TEST_CASE("heap_size_stubs", "[esp_system]")
TEST_ASSERT_EQUAL(UINT32_MAX, esp_get_minimum_free_heap_size());
}
esp_err_t esp_ok_func(void)
{
return ESP_OK;
}
esp_err_t esp_fail_func(void)
{
return ESP_FAIL;
}
TEST_CASE("ESP_ERROR_CHECK_WITHOUT_ABORT", "[esp_system]")
{
ESP_ERROR_CHECK_WITHOUT_ABORT(esp_ok_func());
ESP_ERROR_CHECK_WITHOUT_ABORT(esp_fail_func());
}
TEST_CASE("ESP_ERROR_CHECK", "[esp_system]")
{
ESP_ERROR_CHECK(esp_ok_func());
}
void app_main(void)
{
printf("Running esp_system host test app");

View File

@ -26,7 +26,7 @@ SOURCE_FILES = \
test_partition_manager.cpp \
main.cpp
SOURCE_FILES_C = ../../esp_rom/linux/esp_rom_crc.c ../../esp_common/src/esp_err_check_linux.c
SOURCE_FILES_C = ../../esp_rom/linux/esp_rom_crc.c esp_err_check_mock.c
ifeq ($(shell $(CC) -v 2>&1 | grep -c "clang version"), 1)
COMPILER := clang

View File

@ -1,6 +1,7 @@
idf_build_get_property(target IDF_TARGET)
if(${target} STREQUAL "linux")
idf_component_register(SRCS "linux/spi_flash_linux.c"
"linux/cache_utils.c"
INCLUDE_DIRS include
PRIV_INCLUDE_DIRS include/spi_flash)
return()

View File

@ -0,0 +1,12 @@
/*
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <stdbool.h>
bool spi_flash_cache_enabled(void)
{
return true;
}