feat(esp_common): Support ESP_ERROR_CHECK_ macros on Linux

Closes https://github.com/espressif/esp-idf/issues/13893
This commit is contained in:
Konstantin Kondrashov
2024-06-04 09:40:53 +03:00
parent 13e5b6f335
commit 023d112cbf
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

@@ -1,24 +0,0 @@
/*
* 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 <stdio.h>
#include <stdlib.h>
#include "esp_err.h"
#include "sdkconfig.h"
void _esp_error_check_failed(esp_err_t rc, const char *file, int line, const char *function, const char *expression)
{
printf("ESP_ERROR_CHECK failed: esp_err_t 0x%x", rc);
#ifdef CONFIG_ESP_ERR_TO_NAME_LOOKUP
printf(" (%s)", esp_err_to_name(rc));
#endif //CONFIG_ESP_ERR_TO_NAME_LOOKUP
printf(" at %p\n", __builtin_return_address(0));
printf("file: \"%s\" line %d\nfunc: %s\nexpression: %s\n", file, line, function, expression);
abort();
}