From 9ab0d95f65f982c902e4fbff0851c25904f58fc4 Mon Sep 17 00:00:00 2001 From: Marius Vikhammer Date: Wed, 17 Jan 2024 16:46:32 +0800 Subject: [PATCH] test(newlib): enable and fix newlib tests on P4 --- .../esp_rom/esp32p4/Kconfig.soc_caps.in | 4 ++++ components/esp_rom/esp32p4/esp_rom_caps.h | 1 + .../newlib/test_apps/.build-test-rules.yml | 7 ------- components/newlib/test_apps/newlib/README.md | 4 ++-- .../test_apps/newlib/main/test_newlib.c | 2 +- .../newlib/test_apps/newlib/main/test_time.c | 21 +++++++++++++++---- .../newlib/test_apps/newlib/pytest_newlib.py | 1 - 7 files changed, 25 insertions(+), 15 deletions(-) delete mode 100644 components/newlib/test_apps/.build-test-rules.yml diff --git a/components/esp_rom/esp32p4/Kconfig.soc_caps.in b/components/esp_rom/esp32p4/Kconfig.soc_caps.in index ec068d6ac8..75978111d7 100644 --- a/components/esp_rom/esp32p4/Kconfig.soc_caps.in +++ b/components/esp_rom/esp32p4/Kconfig.soc_caps.in @@ -54,3 +54,7 @@ config ESP_ROM_HAS_LP_ROM config ESP_ROM_WITHOUT_REGI2C bool default y + +config ESP_ROM_HAS_NEWLIB_NANO_FORMAT + bool + default y diff --git a/components/esp_rom/esp32p4/esp_rom_caps.h b/components/esp_rom/esp32p4/esp_rom_caps.h index 3f9478162f..60ffece0d5 100644 --- a/components/esp_rom/esp32p4/esp_rom_caps.h +++ b/components/esp_rom/esp32p4/esp_rom_caps.h @@ -19,3 +19,4 @@ #define ESP_ROM_WDT_INIT_PATCH (1) // ROM version does not configure the clock #define ESP_ROM_HAS_LP_ROM (1) // ROM also has a LP ROM placed in LP memory #define ESP_ROM_WITHOUT_REGI2C (1) // ROM has no regi2c APIs +#define ESP_ROM_HAS_NEWLIB_NANO_FORMAT (1) // ROM has the newlib nano version of formatting functions diff --git a/components/newlib/test_apps/.build-test-rules.yml b/components/newlib/test_apps/.build-test-rules.yml deleted file mode 100644 index e73b75fb65..0000000000 --- a/components/newlib/test_apps/.build-test-rules.yml +++ /dev/null @@ -1,7 +0,0 @@ -# Documentation: .gitlab/ci/README.md#manifest-file-to-control-the-buildtest-apps - -components/newlib/test_apps/newlib: - disable: - - if: IDF_TARGET == "esp32p4" - temporary: true - reason: not supported yet #TODO: IDF-7862 diff --git a/components/newlib/test_apps/newlib/README.md b/components/newlib/test_apps/newlib/README.md index a8b7833fa3..bf47d80ec6 100644 --- a/components/newlib/test_apps/newlib/README.md +++ b/components/newlib/test_apps/newlib/README.md @@ -1,2 +1,2 @@ -| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C6 | ESP32-H2 | ESP32-S2 | ESP32-S3 | -| ----------------- | ----- | -------- | -------- | -------- | -------- | -------- | -------- | +| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C6 | ESP32-H2 | ESP32-P4 | ESP32-S2 | ESP32-S3 | +| ----------------- | ----- | -------- | -------- | -------- | -------- | -------- | -------- | -------- | diff --git a/components/newlib/test_apps/newlib/main/test_newlib.c b/components/newlib/test_apps/newlib/main/test_newlib.c index 8cb32840c0..2651d3d61c 100644 --- a/components/newlib/test_apps/newlib/main/test_newlib.c +++ b/components/newlib/test_apps/newlib/main/test_newlib.c @@ -132,7 +132,7 @@ static bool fn_in_rom(void *fn) /* Older chips have newlib nano in rom as well, but this is not linked in due to us now using 64 bit time_t and the ROM code was compiled for 32 bit. */ -#define PRINTF_NANO_IN_ROM (CONFIG_NEWLIB_NANO_FORMAT && (CONFIG_IDF_TARGET_ESP32C2 || CONFIG_IDF_TARGET_ESP32H2)) +#define PRINTF_NANO_IN_ROM (CONFIG_NEWLIB_NANO_FORMAT && (CONFIG_IDF_TARGET_ESP32C2 || CONFIG_IDF_TARGET_ESP32H2 || CONFIG_IDF_TARGET_ESP32P4)) #define SSCANF_NANO_IN_ROM (CONFIG_NEWLIB_NANO_FORMAT && CONFIG_IDF_TARGET_ESP32C2) TEST_CASE("check if ROM or Flash is used for functions", "[newlib]") diff --git a/components/newlib/test_apps/newlib/main/test_time.c b/components/newlib/test_apps/newlib/main/test_time.c index 0ce0f18286..a394791ca8 100644 --- a/components/newlib/test_apps/newlib/main/test_time.c +++ b/components/newlib/test_apps/newlib/main/test_time.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -45,7 +45,14 @@ #include "esp32p4/rtc.h" #endif -#if portNUM_PROCESSORS == 2 +#if SOC_CACHE_INTERNAL_MEM_VIA_L1CACHE +#include "hal/cache_ll.h" +#endif + +#if (portNUM_PROCESSORS == 2) && CONFIG_IDF_TARGET_ARCH_XTENSA +// https://github.com/espressif/arduino-esp32/issues/120 +/* Test for hardware bug, not needed for newer chips */ + #include "soc/rtc_cntl_reg.h" // This runs on APP CPU: @@ -65,7 +72,7 @@ static void time_adc_test_task(void* arg) vTaskDelete(NULL); } -// https://github.com/espressif/arduino-esp32/issues/120 + TEST_CASE("Reading RTC registers on APP CPU doesn't affect clock", "[newlib]") { SemaphoreHandle_t done = xSemaphoreCreateBinary(); @@ -85,7 +92,7 @@ TEST_CASE("Reading RTC registers on APP CPU doesn't affect clock", "[newlib]") TEST_ASSERT_TRUE(xSemaphoreTake(done, 5000 / portTICK_PERIOD_MS)); } -#endif // portNUM_PROCESSORS == 2 +#endif // (portNUM_PROCESSORS == 2) && CONFIG_IDF_TARGET_ARCH_XTENSA TEST_CASE("test adjtime function", "[newlib]") { @@ -609,6 +616,12 @@ static void set_initial_condition(type_reboot_t type_reboot, int error_time) TEST_ASSERT_GREATER_OR_EQUAL(error_time, dt); s_time_in_reboot = esp_rtc_get_time_us(); +#if SOC_CACHE_INTERNAL_MEM_VIA_L1CACHE + /* If internal data is behind a cache it might not be written to the physical memory when we crash/reboot + force a full writeback here to ensure this */ + cache_ll_writeback_all(CACHE_LL_LEVEL_INT_MEM, CACHE_TYPE_DATA, CACHE_LL_ID_ALL); +#endif + if (type_reboot == TYPE_REBOOT_ABORT) { printf("Update boot time based on diff\n"); esp_sync_timekeeping_timers(); diff --git a/components/newlib/test_apps/newlib/pytest_newlib.py b/components/newlib/test_apps/newlib/pytest_newlib.py index ce50c0656d..4569c93f08 100644 --- a/components/newlib/test_apps/newlib/pytest_newlib.py +++ b/components/newlib/test_apps/newlib/pytest_newlib.py @@ -31,7 +31,6 @@ def validate_sbom(dut: Dut) -> None: assert toolchain_newlib_version == sbom_newlib_version, 'toolchain_newlib_version != sbom_newlib_version' -@pytest.mark.temp_skip_ci(targets=['esp32p4'], reason='esp32p4 support TBD') # TODO: IDF-8983 @pytest.mark.generic @pytest.mark.parametrize( 'config',