esp_err.c 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. /*
  2. * SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #include <stdbool.h>
  7. #include <stdlib.h>
  8. #include <string.h>
  9. #include "esp_err.h"
  10. #include "spi_flash_mmap.h"
  11. #include "esp_private/cache_utils.h"
  12. #include "esp_rom_sys.h"
  13. static void esp_error_check_failed_print(const char *msg, esp_err_t rc, const char *file, int line, const char *function, const char *expression)
  14. {
  15. esp_rom_printf("%s failed: esp_err_t 0x%x", msg, rc);
  16. #ifdef CONFIG_ESP_ERR_TO_NAME_LOOKUP
  17. esp_rom_printf(" (%s)", esp_err_to_name(rc));
  18. #endif //CONFIG_ESP_ERR_TO_NAME_LOOKUP
  19. esp_rom_printf(" at 0x%08x\n", (intptr_t)__builtin_return_address(0) - 3);
  20. if (spi_flash_cache_enabled()) { // strings may be in flash cache
  21. esp_rom_printf("file: \"%s\" line %d\nfunc: %s\nexpression: %s\n", file, line, function, expression);
  22. }
  23. }
  24. void _esp_error_check_failed_without_abort(esp_err_t rc, const char *file, int line, const char *function, const char *expression)
  25. {
  26. esp_error_check_failed_print("ESP_ERROR_CHECK_WITHOUT_ABORT", rc, file, line, function, expression);
  27. }
  28. void _esp_error_check_failed(esp_err_t rc, const char *file, int line, const char *function, const char *expression)
  29. {
  30. esp_error_check_failed_print("ESP_ERROR_CHECK", rc, file, line, function, expression);
  31. abort();
  32. }