From 16cc8f974df3fca1eafaac8c8d21e2e4f7bed11d Mon Sep 17 00:00:00 2001 From: laokaiyao Date: Mon, 12 May 2025 11:33:56 +0800 Subject: [PATCH 1/3] ci: test i2s, touch, ana_cmpr with CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL=0 --- .../analog_comparator/CMakeLists.txt | 2 +- .../analog_comparator/main/CMakeLists.txt | 2 +- .../analog_comparator/sdkconfig.defaults | 2 +- .../sdkconfig.defaults.esp32p4 | 3 +++ .../test_apps/dac/sdkconfig.defaults | 2 +- .../test_apps/i2s/main/CMakeLists.txt | 3 ++- .../test_apps/i2s/pytest_i2s.py | 20 ++++++++++++++++++- .../test_apps/i2s/sdkconfig.defaults.esp32p4 | 3 +++ .../test_apps/i2s/sdkconfig.defaults.esp32s3 | 4 ++++ .../test_apps/touch_sens/main/CMakeLists.txt | 2 +- .../touch_sens/sdkconfig.defaults.esp32p4 | 3 +++ 11 files changed, 39 insertions(+), 7 deletions(-) create mode 100644 components/esp_driver_ana_cmpr/test_apps/analog_comparator/sdkconfig.defaults.esp32p4 create mode 100644 components/esp_driver_i2s/test_apps/i2s/sdkconfig.defaults.esp32p4 create mode 100644 components/esp_driver_i2s/test_apps/i2s/sdkconfig.defaults.esp32s3 create mode 100644 components/esp_driver_touch_sens/test_apps/touch_sens/sdkconfig.defaults.esp32p4 diff --git a/components/esp_driver_ana_cmpr/test_apps/analog_comparator/CMakeLists.txt b/components/esp_driver_ana_cmpr/test_apps/analog_comparator/CMakeLists.txt index 6bc3f82173..72ee984b6a 100644 --- a/components/esp_driver_ana_cmpr/test_apps/analog_comparator/CMakeLists.txt +++ b/components/esp_driver_ana_cmpr/test_apps/analog_comparator/CMakeLists.txt @@ -14,7 +14,7 @@ if(CONFIG_COMPILER_DUMP_RTL_FILES) --elf-file ${CMAKE_BINARY_DIR}/test_ana_cmpr.elf find-refs --from-sections=.iram0.text - --to-sections=.flash.text + --to-sections=.flash.text,.flash.rodata --exit-code DEPENDS ${elf} ) diff --git a/components/esp_driver_ana_cmpr/test_apps/analog_comparator/main/CMakeLists.txt b/components/esp_driver_ana_cmpr/test_apps/analog_comparator/main/CMakeLists.txt index 0863879495..264d7eb0df 100644 --- a/components/esp_driver_ana_cmpr/test_apps/analog_comparator/main/CMakeLists.txt +++ b/components/esp_driver_ana_cmpr/test_apps/analog_comparator/main/CMakeLists.txt @@ -13,5 +13,5 @@ endif() idf_component_register(SRCS ${srcs} INCLUDE_DIRS "." - PRIV_REQUIRES unity esp_driver_gpio esp_driver_ana_cmpr esp_driver_gptimer esp_pm + PRIV_REQUIRES unity esp_driver_gpio esp_driver_ana_cmpr esp_driver_gptimer esp_pm esp_psram WHOLE_ARCHIVE) diff --git a/components/esp_driver_ana_cmpr/test_apps/analog_comparator/sdkconfig.defaults b/components/esp_driver_ana_cmpr/test_apps/analog_comparator/sdkconfig.defaults index b308cb2ddd..fa8ac618b9 100644 --- a/components/esp_driver_ana_cmpr/test_apps/analog_comparator/sdkconfig.defaults +++ b/components/esp_driver_ana_cmpr/test_apps/analog_comparator/sdkconfig.defaults @@ -1,2 +1,2 @@ CONFIG_FREERTOS_HZ=1000 -CONFIG_ESP_TASK_WDT=n +CONFIG_ESP_TASK_WDT_EN=n diff --git a/components/esp_driver_ana_cmpr/test_apps/analog_comparator/sdkconfig.defaults.esp32p4 b/components/esp_driver_ana_cmpr/test_apps/analog_comparator/sdkconfig.defaults.esp32p4 new file mode 100644 index 0000000000..d2699b2221 --- /dev/null +++ b/components/esp_driver_ana_cmpr/test_apps/analog_comparator/sdkconfig.defaults.esp32p4 @@ -0,0 +1,3 @@ +CONFIG_SPIRAM=y +CONFIG_SPIRAM_MODE_HEX=y +CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL=0 diff --git a/components/esp_driver_dac/test_apps/dac/sdkconfig.defaults b/components/esp_driver_dac/test_apps/dac/sdkconfig.defaults index 0a847f27d5..51ec00b756 100644 --- a/components/esp_driver_dac/test_apps/dac/sdkconfig.defaults +++ b/components/esp_driver_dac/test_apps/dac/sdkconfig.defaults @@ -1,4 +1,4 @@ CONFIG_FREERTOS_HZ=1000 -CONFIG_ESP_TASK_WDT=n +CONFIG_ESP_TASK_WDT_EN=n # Disable this config, otherwise DAC will be disabled when ADC initialized CONFIG_ADC_DISABLE_DAC_OUTPUT=n diff --git a/components/esp_driver_i2s/test_apps/i2s/main/CMakeLists.txt b/components/esp_driver_i2s/test_apps/i2s/main/CMakeLists.txt index d90f51c9f4..827d77dba5 100644 --- a/components/esp_driver_i2s/test_apps/i2s/main/CMakeLists.txt +++ b/components/esp_driver_i2s/test_apps/i2s/main/CMakeLists.txt @@ -8,5 +8,6 @@ if(CONFIG_SOC_I2S_SUPPORTS_ETM AND CONFIG_SOC_GPIO_SUPPORT_ETM) endif() idf_component_register(SRCS ${srcs} - PRIV_REQUIRES unity esp_driver_pcnt spi_flash esp_driver_gpio esp_driver_i2s esp_driver_uart + PRIV_REQUIRES unity esp_driver_pcnt spi_flash + esp_driver_gpio esp_driver_i2s esp_driver_uart esp_psram WHOLE_ARCHIVE) diff --git a/components/esp_driver_i2s/test_apps/i2s/pytest_i2s.py b/components/esp_driver_i2s/test_apps/i2s/pytest_i2s.py index 2f7ac561f3..9c34a48bbb 100644 --- a/components/esp_driver_i2s/test_apps/i2s/pytest_i2s.py +++ b/components/esp_driver_i2s/test_apps/i2s/pytest_i2s.py @@ -16,8 +16,26 @@ from pytest_embedded_idf.utils import idf_parametrize ) @idf_parametrize( 'target', - ['esp32', 'esp32s2', 'esp32c3', 'esp32c5', 'esp32c6', 'esp32s3', 'esp32h2', 'esp32p4', 'esp32c61'], + ['esp32', 'esp32s2', 'esp32c3', 'esp32c5', 'esp32c6', 'esp32h2', 'esp32p4', 'esp32c61'], indirect=['target'], ) def test_i2s(dut: Dut) -> None: dut.run_all_single_board_cases() + + +@pytest.mark.octal_psram +@pytest.mark.parametrize( + 'config', + [ + 'iram_safe', + 'release', + ], + indirect=True, +) +@idf_parametrize( + 'target', + ['esp32s3'], + indirect=['target'], +) +def test_i2s_psram(dut: Dut) -> None: + dut.run_all_single_board_cases() diff --git a/components/esp_driver_i2s/test_apps/i2s/sdkconfig.defaults.esp32p4 b/components/esp_driver_i2s/test_apps/i2s/sdkconfig.defaults.esp32p4 new file mode 100644 index 0000000000..d2699b2221 --- /dev/null +++ b/components/esp_driver_i2s/test_apps/i2s/sdkconfig.defaults.esp32p4 @@ -0,0 +1,3 @@ +CONFIG_SPIRAM=y +CONFIG_SPIRAM_MODE_HEX=y +CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL=0 diff --git a/components/esp_driver_i2s/test_apps/i2s/sdkconfig.defaults.esp32s3 b/components/esp_driver_i2s/test_apps/i2s/sdkconfig.defaults.esp32s3 new file mode 100644 index 0000000000..24336a0742 --- /dev/null +++ b/components/esp_driver_i2s/test_apps/i2s/sdkconfig.defaults.esp32s3 @@ -0,0 +1,4 @@ +CONFIG_SPIRAM=y +CONFIG_SPIRAM_MODE_OCT=y +CONFIG_SPIRAM_SPEED_80M=y +CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL=0 diff --git a/components/esp_driver_touch_sens/test_apps/touch_sens/main/CMakeLists.txt b/components/esp_driver_touch_sens/test_apps/touch_sens/main/CMakeLists.txt index 97285a1122..62b7b431c1 100644 --- a/components/esp_driver_touch_sens/test_apps/touch_sens/main/CMakeLists.txt +++ b/components/esp_driver_touch_sens/test_apps/touch_sens/main/CMakeLists.txt @@ -2,5 +2,5 @@ set(srcs "test_app_main.c" "test_touch_sens_common.c") idf_component_register(SRCS ${srcs} INCLUDE_DIRS "." - PRIV_REQUIRES unity esp_driver_touch_sens + PRIV_REQUIRES unity esp_driver_touch_sens esp_psram WHOLE_ARCHIVE) diff --git a/components/esp_driver_touch_sens/test_apps/touch_sens/sdkconfig.defaults.esp32p4 b/components/esp_driver_touch_sens/test_apps/touch_sens/sdkconfig.defaults.esp32p4 new file mode 100644 index 0000000000..d2699b2221 --- /dev/null +++ b/components/esp_driver_touch_sens/test_apps/touch_sens/sdkconfig.defaults.esp32p4 @@ -0,0 +1,3 @@ +CONFIG_SPIRAM=y +CONFIG_SPIRAM_MODE_HEX=y +CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL=0 From 7d086d6a8d6bc5eb9ef8b0128e876e9f3a43ce6e Mon Sep 17 00:00:00 2001 From: laokaiyao Date: Wed, 21 May 2025 16:30:56 +0800 Subject: [PATCH 2/3] fix(ana_cmpr): fixed FUNC_IN_IRAM option involves flash data --- components/esp_driver_ana_cmpr/ana_cmpr.c | 25 +++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/components/esp_driver_ana_cmpr/ana_cmpr.c b/components/esp_driver_ana_cmpr/ana_cmpr.c index c70b457948..381cf6c07b 100644 --- a/components/esp_driver_ana_cmpr/ana_cmpr.c +++ b/components/esp_driver_ana_cmpr/ana_cmpr.c @@ -34,7 +34,14 @@ struct ana_cmpr_t { /* Helper macros */ #define ANA_CMPR_NULL_POINTER_CHECK(p) ESP_RETURN_ON_FALSE((p), ESP_ERR_INVALID_ARG, TAG, "input parameter '" #p "' is NULL") -#define ANA_CMPR_NULL_POINTER_CHECK_ISR(p) ESP_RETURN_ON_FALSE_ISR((p), ESP_ERR_INVALID_ARG, TAG, "input parameter '" #p "' is NULL") +#define ANA_CMPR_NULL_POINTER_CHECK_SAFE(p) \ +do { \ + if (unlikely(!(p))) { \ + ESP_EARLY_LOGE(TAG, "input parameter '" #p "' is NULL"); \ + return ESP_ERR_INVALID_ARG; \ + } \ +} while(0) + #define ANA_CMPR_UNIT_CHECK(unit) ESP_RETURN_ON_FALSE((unit) >= 0 && (unit) < SOC_ANA_CMPR_NUM, ESP_ERR_INVALID_ARG, TAG, "invalid unit number") /* Global static object of the Analog Comparator unit */ @@ -194,10 +201,12 @@ esp_err_t ana_cmpr_del_unit(ana_cmpr_handle_t cmpr) esp_err_t ana_cmpr_set_internal_reference(ana_cmpr_handle_t cmpr, const ana_cmpr_internal_ref_config_t *ref_cfg) { - ANA_CMPR_NULL_POINTER_CHECK_ISR(cmpr); - ANA_CMPR_NULL_POINTER_CHECK_ISR(ref_cfg); - ESP_RETURN_ON_FALSE_ISR(cmpr->ref_src == ANA_CMPR_REF_SRC_INTERNAL, ESP_ERR_INVALID_STATE, - TAG, "the reference voltage does not come from internal"); + ANA_CMPR_NULL_POINTER_CHECK_SAFE(cmpr); + ANA_CMPR_NULL_POINTER_CHECK_SAFE(ref_cfg); + if (unlikely(cmpr->ref_src != ANA_CMPR_REF_SRC_INTERNAL)) { + ESP_EARLY_LOGE(TAG, "the reference voltage does not come from internal"); + return ESP_ERR_INVALID_STATE; + } // the underlying register may be accessed by different threads at the same time, so use spin lock to protect it portENTER_CRITICAL_SAFE(&s_spinlock); @@ -209,8 +218,8 @@ esp_err_t ana_cmpr_set_internal_reference(ana_cmpr_handle_t cmpr, const ana_cmpr esp_err_t ana_cmpr_set_debounce(ana_cmpr_handle_t cmpr, const ana_cmpr_debounce_config_t *dbc_cfg) { - ANA_CMPR_NULL_POINTER_CHECK_ISR(cmpr); - ANA_CMPR_NULL_POINTER_CHECK_ISR(dbc_cfg); + ANA_CMPR_NULL_POINTER_CHECK_SAFE(cmpr); + ANA_CMPR_NULL_POINTER_CHECK_SAFE(dbc_cfg); /* Transfer the time to clock cycles */ uint32_t wait_cycle = dbc_cfg->wait_us * (cmpr->src_clk_freq_hz / 1000000); @@ -231,7 +240,7 @@ esp_err_t ana_cmpr_set_cross_type(ana_cmpr_handle_t cmpr, ana_cmpr_cross_type_t (void)cross_type; return ESP_ERR_NOT_SUPPORTED; #else - ANA_CMPR_NULL_POINTER_CHECK_ISR(cmpr); + ANA_CMPR_NULL_POINTER_CHECK_SAFE(cmpr); ESP_RETURN_ON_FALSE_ISR(cross_type >= ANA_CMPR_CROSS_DISABLE && cross_type <= ANA_CMPR_CROSS_ANY, ESP_ERR_INVALID_ARG, TAG, "invalid cross type"); From a2cf361c5a83c7106dfb18cd8e1912b2938052c0 Mon Sep 17 00:00:00 2001 From: laokaiyao Date: Mon, 12 May 2025 11:33:56 +0800 Subject: [PATCH 3/3] ci: test i2s, touch, ana_cmpr with CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL=0 --- components/esp_driver_ana_cmpr/ana_cmpr.c | 6 ++++-- .../test_apps/analog_comparator/sdkconfig.ci.cache_safe | 1 - .../test_apps/touch_sens/sdkconfig.defaults | 1 + .../test_apps/touch_sens/sdkconfig.defaults.esp32s3 | 2 ++ 4 files changed, 7 insertions(+), 3 deletions(-) create mode 100644 components/esp_driver_touch_sens/test_apps/touch_sens/sdkconfig.defaults.esp32s3 diff --git a/components/esp_driver_ana_cmpr/ana_cmpr.c b/components/esp_driver_ana_cmpr/ana_cmpr.c index 381cf6c07b..92ebf93984 100644 --- a/components/esp_driver_ana_cmpr/ana_cmpr.c +++ b/components/esp_driver_ana_cmpr/ana_cmpr.c @@ -241,8 +241,10 @@ esp_err_t ana_cmpr_set_cross_type(ana_cmpr_handle_t cmpr, ana_cmpr_cross_type_t return ESP_ERR_NOT_SUPPORTED; #else ANA_CMPR_NULL_POINTER_CHECK_SAFE(cmpr); - ESP_RETURN_ON_FALSE_ISR(cross_type >= ANA_CMPR_CROSS_DISABLE && cross_type <= ANA_CMPR_CROSS_ANY, - ESP_ERR_INVALID_ARG, TAG, "invalid cross type"); + if (unlikely(cross_type < ANA_CMPR_CROSS_DISABLE || cross_type > ANA_CMPR_CROSS_ANY)) { + ESP_EARLY_LOGE(TAG, "invalid cross type"); + return ESP_ERR_INVALID_ARG; + } portENTER_CRITICAL_SAFE(&s_spinlock); analog_cmpr_ll_set_intr_cross_type(cmpr->dev, cross_type); diff --git a/components/esp_driver_ana_cmpr/test_apps/analog_comparator/sdkconfig.ci.cache_safe b/components/esp_driver_ana_cmpr/test_apps/analog_comparator/sdkconfig.ci.cache_safe index 35539be28f..5f1f5c1300 100644 --- a/components/esp_driver_ana_cmpr/test_apps/analog_comparator/sdkconfig.ci.cache_safe +++ b/components/esp_driver_ana_cmpr/test_apps/analog_comparator/sdkconfig.ci.cache_safe @@ -1,6 +1,5 @@ CONFIG_COMPILER_DUMP_RTL_FILES=y CONFIG_ANA_CMPR_ISR_CACHE_SAFE=y -CONFIG_ANA_CMPR_CTRL_FUNC_IN_IRAM=y CONFIG_GPIO_CTRL_FUNC_IN_IRAM=y CONFIG_COMPILER_OPTIMIZATION_NONE=y # place non-ISR FreeRTOS functions in Flash diff --git a/components/esp_driver_touch_sens/test_apps/touch_sens/sdkconfig.defaults b/components/esp_driver_touch_sens/test_apps/touch_sens/sdkconfig.defaults index 8e326e32e1..a58b4feee7 100644 --- a/components/esp_driver_touch_sens/test_apps/touch_sens/sdkconfig.defaults +++ b/components/esp_driver_touch_sens/test_apps/touch_sens/sdkconfig.defaults @@ -1,2 +1,3 @@ CONFIG_FREERTOS_HZ=1000 CONFIG_ESP_TASK_WDT_INIT=n +CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL=0 diff --git a/components/esp_driver_touch_sens/test_apps/touch_sens/sdkconfig.defaults.esp32s3 b/components/esp_driver_touch_sens/test_apps/touch_sens/sdkconfig.defaults.esp32s3 new file mode 100644 index 0000000000..db575808cf --- /dev/null +++ b/components/esp_driver_touch_sens/test_apps/touch_sens/sdkconfig.defaults.esp32s3 @@ -0,0 +1,2 @@ +CONFIG_SPIRAM=y +CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL=0