Skip to content

Commit

Permalink
Merge branch 'feature/linux_esp_err_support' into 'master'
Browse files Browse the repository at this point in the history
feat(esp_common): Support ESP_ERROR_CHECK_ macros on Linux

Closes IDFGH-12933

See merge request espressif/esp-idf!31320
  • Loading branch information
KonstantinKondrashov committed Jun 6, 2024
2 parents 745ca1a + 023d112 commit 391aabf
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 6 deletions.
4 changes: 1 addition & 3 deletions components/esp_common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
4 changes: 3 additions & 1 deletion components/esp_system/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
Original file line number Diff line number Diff line change
@@ -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
*/
Expand Down Expand Up @@ -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");
Expand Down
2 changes: 1 addition & 1 deletion components/nvs_flash/test_nvs_host/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions components/spi_flash/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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()
Expand Down
12 changes: 12 additions & 0 deletions components/spi_flash/linux/cache_utils.c
Original file line number Diff line number Diff line change
@@ -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;
}

0 comments on commit 391aabf

Please # to comment.