diff --git a/components/esp_system/port/arch/riscv/debug_helpers.c b/components/esp_system/port/arch/riscv/debug_helpers.c index 05ab68fdea..6b27451306 100644 --- a/components/esp_system/port/arch/riscv/debug_helpers.c +++ b/components/esp_system/port/arch/riscv/debug_helpers.c @@ -55,7 +55,7 @@ esp_err_t IRAM_ATTR esp_backtrace_print(int depth) #if CONFIG_ESP_SYSTEM_USE_EH_FRAME esp_rom_printf("esp_backtrace_print: Print CPU %d (current core) backtrace\n", current_core); - esp_eh_frame_print_backtrace(&frame); + esp_eh_frame_print_backtrace(frame); #else // CONFIG_ESP_SYSTEM_USE_EH_FRAME esp_rom_printf("esp_backtrace_print: Print CPU %d (current core) registers\n", current_core); panic_prepare_frame_from_ctx(&backtrace_frame); diff --git a/tools/test_apps/system/.build-test-rules.yml b/tools/test_apps/system/.build-test-rules.yml index b11db03fab..00bd70230e 100644 --- a/tools/test_apps/system/.build-test-rules.yml +++ b/tools/test_apps/system/.build-test-rules.yml @@ -25,9 +25,8 @@ tools/test_apps/system/cxx_no_except: tools/test_apps/system/eh_frame: enable: - - if: IDF_TARGET in ["esp32c2", "esp32c3"] - temporary: true - reason: the other targets are not tested yet + - if: IDF_TARGET not in ["esp32", "esp32s2", "esp32s3", "linux"] + reason: Only relevant for riscv targets tools/test_apps/system/esp_intr_dump: diff --git a/tools/test_apps/system/eh_frame/README.md b/tools/test_apps/system/eh_frame/README.md index 59a65262c1..c4ffe6bab7 100644 --- a/tools/test_apps/system/eh_frame/README.md +++ b/tools/test_apps/system/eh_frame/README.md @@ -1,5 +1,5 @@ -| Supported Targets | ESP32-C2 | ESP32-C3 | -| ----------------- | -------- | -------- | +| Supported Targets | ESP32-C2 | ESP32-C3 | ESP32-C5 | ESP32-C6 | ESP32-C61 | ESP32-H2 | ESP32-P4 | +| ----------------- | -------- | -------- | -------- | -------- | --------- | -------- | -------- | # Building and running diff --git a/tools/test_apps/system/eh_frame/main/CMakeLists.txt b/tools/test_apps/system/eh_frame/main/CMakeLists.txt index 09f0d02fdf..240268ee3e 100644 --- a/tools/test_apps/system/eh_frame/main/CMakeLists.txt +++ b/tools/test_apps/system/eh_frame/main/CMakeLists.txt @@ -1,3 +1,3 @@ idf_component_register(SRCS "eh_frame_main.c" INCLUDE_DIRS "." - REQUIRES esp_system) + REQUIRES esp_system unity esp_timer) diff --git a/tools/test_apps/system/eh_frame/main/eh_frame_main.c b/tools/test_apps/system/eh_frame/main/eh_frame_main.c index 8abf55144e..7c8263c09e 100644 --- a/tools/test_apps/system/eh_frame/main/eh_frame_main.c +++ b/tools/test_apps/system/eh_frame/main/eh_frame_main.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Unlicense OR CC0-1.0 */ @@ -7,7 +7,9 @@ #include #include #include - +#include "unity.h" +#include "esp_timer.h" +#include "esp_debug_helpers.h" /** * @brief Symbols defined by the linker. * Retrieve the addresses of both .eh_frame_hdr and .eh_frame sections. @@ -26,6 +28,24 @@ extern char __eh_frame_end; #define EH_FRAME_END_ADDR ((void*) (&__eh_frame_end)) +void __attribute((noinline)) trigger_wdt(void) +{ + const int wait_until_time = esp_timer_get_time() + (1000*1000 * (CONFIG_ESP_TASK_WDT_TIMEOUT_S + 1)); + while(esp_timer_get_time() < wait_until_time) { + } +} + +TEST_CASE("Test task wdt can print backtrace with eh-frame", "eh-frame") +{ + trigger_wdt(); +} + + +TEST_CASE("Test panic can print backtrace with eh-frame", "eh-frame") +{ + asm("unimp"); +} + void app_main(void) { /* As soon as this test compiles, it can be considered passed. The linker should @@ -37,4 +57,6 @@ void app_main(void) /* Use the symbols just to make sure they won't be optimized away */ printf(".eh_frame start: %p, end: %p\n", EH_FRAME_ADDR, EH_FRAME_END_ADDR); printf(".eh_frame_hdr start: %p, end: %p\n", EH_FRAME_HDR_ADDR, EH_FRAME_HDR_END_ADDR); + + unity_run_menu(); } diff --git a/tools/test_apps/system/eh_frame/pytest_eh_frame.py b/tools/test_apps/system/eh_frame/pytest_eh_frame.py new file mode 100644 index 0000000000..d94080d69f --- /dev/null +++ b/tools/test_apps/system/eh_frame/pytest_eh_frame.py @@ -0,0 +1,34 @@ +# SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD +# SPDX-License-Identifier: CC0-1.0 +import pytest +from pytest_embedded import Dut + + +@pytest.mark.esp32c2 +@pytest.mark.esp32c3 +@pytest.mark.esp32c5 +@pytest.mark.esp32c6 +@pytest.mark.esp32h2 +@pytest.mark.esp32p4 +@pytest.mark.generic +def test_eh_frame_wdt(dut: Dut) -> None: + dut.expect_exact('Press ENTER to see the list of tests') + dut.confirm_write('"Test task wdt can print backtrace with eh-frame"', expect_str=f'Running') + + # Expect a backtrace which is at least 3 PC-SP pairs deep + dut.expect(r'Backtrace: (0x[a-fA-F0-9]+:0x[a-fA-F0-9]+\s*){3,}') + + +@pytest.mark.esp32c2 +@pytest.mark.esp32c3 +@pytest.mark.esp32c5 +@pytest.mark.esp32c6 +@pytest.mark.esp32h2 +@pytest.mark.esp32p4 +@pytest.mark.generic +def test_eh_frame_panic(dut: Dut) -> None: + dut.expect_exact('Press ENTER to see the list of tests') + dut.confirm_write('"Test panic can print backtrace with eh-frame"', expect_str=f'Running') + + # Expect a backtrace which is at least 3 PC-SP pairs deep + dut.expect(r'Backtrace: (0x[a-fA-F0-9]+:0x[a-fA-F0-9]+\s*){3,}') diff --git a/tools/test_apps/system/eh_frame/sdkconfig.defaults b/tools/test_apps/system/eh_frame/sdkconfig.defaults index dae200b3ef..80d2e133b7 100644 --- a/tools/test_apps/system/eh_frame/sdkconfig.defaults +++ b/tools/test_apps/system/eh_frame/sdkconfig.defaults @@ -1,2 +1,4 @@ # Enable eh_frame sections generation CONFIG_ESP_SYSTEM_USE_EH_FRAME=y +# use non-rom systimer implementation, can't backtrace functions in ROM +CONFIG_HAL_SYSTIMER_USE_ROM_IMPL=n