From ad51d0d1cae06ba94ef42d59c7562756b72a281c Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Fri, 5 Apr 2024 17:48:37 +0200 Subject: [PATCH 1/6] ci(sdmmc): clean up stdout to avoid false positive memory leaks --- .../esp_driver_sdmmc/test_apps/sdmmc/main/test_app_main.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/components/esp_driver_sdmmc/test_apps/sdmmc/main/test_app_main.c b/components/esp_driver_sdmmc/test_apps/sdmmc/main/test_app_main.c index e6e17ee73e..e36a7a945e 100644 --- a/components/esp_driver_sdmmc/test_apps/sdmmc/main/test_app_main.c +++ b/components/esp_driver_sdmmc/test_apps/sdmmc/main/test_app_main.c @@ -13,11 +13,13 @@ void setUp(void) { + printf("%s", ""); /* sneakily lazy-allocate the reent structure for this test task */ unity_utils_record_free_mem(); } void tearDown(void) { + esp_reent_cleanup(); unity_utils_evaluate_leaks_direct(TEST_MEMORY_LEAK_THRESHOLD); } From 96074470ec885610b8d166c8305dd0e2d4ab7b3b Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Fri, 5 Apr 2024 17:47:27 +0200 Subject: [PATCH 2/6] fix(sdmmc): correct power init in CD/WP tests for P4 --- .../sdmmc_tests/sdmmc_test_cd_wp_sd.c | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/components/esp_driver_sdmmc/test_apps/sdmmc/components/sdmmc_tests/sdmmc_test_cd_wp_sd.c b/components/esp_driver_sdmmc/test_apps/sdmmc/components/sdmmc_tests/sdmmc_test_cd_wp_sd.c index 93e04dd8aa..fa45335a28 100644 --- a/components/esp_driver_sdmmc/test_apps/sdmmc/components/sdmmc_tests/sdmmc_test_cd_wp_sd.c +++ b/components/esp_driver_sdmmc/test_apps/sdmmc/components/sdmmc_tests/sdmmc_test_cd_wp_sd.c @@ -21,6 +21,17 @@ TEST_CASE("CD input works in SD mode", "[sdmmc]") sdmmc_test_board_get_config_sdmmc(SDMMC_HOST_SLOT_1, &config, &slot_config); const int test_gpio = sdmmc_test_board_get_slot_info(SDMMC_HOST_SLOT_1)->unused_pin; slot_config.gpio_cd = test_gpio; +#if SOC_SDMMC_IO_POWER_EXTERNAL +#define SDMMC_PWR_LDO_CHANNEL 4 + sd_pwr_ctrl_ldo_config_t ldo_config = { + .ldo_chan_id = SDMMC_PWR_LDO_CHANNEL, + }; + sd_pwr_ctrl_handle_t pwr_ctrl_handle = NULL; + + TEST_ESP_OK(sd_pwr_ctrl_new_on_chip_ldo(&ldo_config, &pwr_ctrl_handle)); + config.pwr_ctrl_handle = pwr_ctrl_handle; +#endif + sdmmc_test_board_card_power_set(true); TEST_ESP_OK(sdmmc_host_init()); TEST_ESP_OK(sdmmc_host_init_slot(SDMMC_HOST_SLOT_1, &slot_config)); @@ -42,6 +53,17 @@ TEST_CASE("WP input works in SD mode", "[sdmmc]") sdmmc_test_board_get_config_sdmmc(SDMMC_HOST_SLOT_1, &config, &slot_config); const int test_gpio = sdmmc_test_board_get_slot_info(SDMMC_HOST_SLOT_1)->unused_pin; slot_config.gpio_wp = test_gpio; +#if SOC_SDMMC_IO_POWER_EXTERNAL +#define SDMMC_PWR_LDO_CHANNEL 4 + sd_pwr_ctrl_ldo_config_t ldo_config = { + .ldo_chan_id = SDMMC_PWR_LDO_CHANNEL, + }; + sd_pwr_ctrl_handle_t pwr_ctrl_handle = NULL; + + TEST_ESP_OK(sd_pwr_ctrl_new_on_chip_ldo(&ldo_config, &pwr_ctrl_handle)); + config.pwr_ctrl_handle = pwr_ctrl_handle; +#endif + TEST_ESP_OK(sdmmc_host_init()); TEST_ESP_OK(sdmmc_host_init_slot(SDMMC_HOST_SLOT_1, &slot_config)); From b08ddfb25bcebb63de67c5763e92c68bf5927b58 Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Fri, 5 Apr 2024 17:46:27 +0200 Subject: [PATCH 3/6] fix(sdmmc): don't fail in clock update commands when no card detected Clock update commands don't actually require the card to be present, so it's not necessary to fail at this stage. --- components/esp_driver_sdmmc/src/sdmmc_host.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/esp_driver_sdmmc/src/sdmmc_host.c b/components/esp_driver_sdmmc/src/sdmmc_host.c index 2a2e4c9cc0..2362e03028 100644 --- a/components/esp_driver_sdmmc/src/sdmmc_host.c +++ b/components/esp_driver_sdmmc/src/sdmmc_host.c @@ -348,7 +348,8 @@ esp_err_t sdmmc_host_start_command(int slot, sdmmc_hw_cmd_t cmd, uint32_t arg) if (!(slot == 0 || slot == 1)) { return ESP_ERR_INVALID_ARG; } - if (!sdmmc_ll_is_card_detected(s_host_ctx.hal.dev, slot)) { + // if this isn't a clock update command, check the card detect status + if (!sdmmc_ll_is_card_detected(s_host_ctx.hal.dev, slot) && !cmd.update_clk_reg) { return ESP_ERR_NOT_FOUND; } if (cmd.data_expected && cmd.rw && sdmmc_ll_is_card_write_protected(s_host_ctx.hal.dev, slot)) { From 3546c81e32347e1224feeb608d79151198ee72c8 Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Fri, 12 Apr 2024 13:14:09 +0200 Subject: [PATCH 4/6] ci(sdmmc): re-enable CD/WP tests --- .../sdmmc/components/sdmmc_tests/sdmmc_test_cd_wp_sd.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/components/esp_driver_sdmmc/test_apps/sdmmc/components/sdmmc_tests/sdmmc_test_cd_wp_sd.c b/components/esp_driver_sdmmc/test_apps/sdmmc/components/sdmmc_tests/sdmmc_test_cd_wp_sd.c index fa45335a28..80e9e01730 100644 --- a/components/esp_driver_sdmmc/test_apps/sdmmc/components/sdmmc_tests/sdmmc_test_cd_wp_sd.c +++ b/components/esp_driver_sdmmc/test_apps/sdmmc/components/sdmmc_tests/sdmmc_test_cd_wp_sd.c @@ -12,8 +12,6 @@ #include "sd_pwr_ctrl.h" #include "sd_pwr_ctrl_by_on_chip_ldo.h" -//TODO: IDF-8734 -#if !CONFIG_IDF_TARGET_ESP32 && !CONFIG_IDF_TARGET_ESP32S3 TEST_CASE("CD input works in SD mode", "[sdmmc]") { sdmmc_host_t config = SDMMC_HOST_DEFAULT(); @@ -75,4 +73,3 @@ TEST_CASE("WP input works in SD mode", "[sdmmc]") TEST_ESP_OK(sd_pwr_ctrl_del_on_chip_ldo(config.pwr_ctrl_handle)); #endif } -#endif From ad6cce5e3a65454b05516db105b42bc6907df4a6 Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Fri, 5 Apr 2024 17:46:57 +0200 Subject: [PATCH 5/6] fix(sdmmc): correct unused pin number for P4 EV board --- .../components/sdmmc_test_boards/sdmmc_test_board_defs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/esp_driver_sdmmc/test_apps/sd_test_utils/components/sdmmc_test_boards/sdmmc_test_board_defs.c b/components/esp_driver_sdmmc/test_apps/sd_test_utils/components/sdmmc_test_boards/sdmmc_test_board_defs.c index d564dc3625..57079e3082 100644 --- a/components/esp_driver_sdmmc/test_apps/sd_test_utils/components/sdmmc_test_boards/sdmmc_test_board_defs.c +++ b/components/esp_driver_sdmmc/test_apps/sd_test_utils/components/sdmmc_test_boards/sdmmc_test_board_defs.c @@ -341,7 +341,7 @@ static const sdmmc_test_board_info_t s_board_info = { .d7 = GPIO_NUM_NC, .cd = GPIO_NUM_NC, .wp = GPIO_NUM_NC, - .unused_pin = 2, + .unused_pin = 54, } }, }; From 3f663ec7890fc6d4bedc7c94cdd57a5231dbd5f1 Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Fri, 5 Apr 2024 17:48:02 +0200 Subject: [PATCH 6/6] ci(sdmmc): add test config for p4 --- .../esp_driver_sdmmc/test_apps/sdmmc/pytest_sdmmc.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/components/esp_driver_sdmmc/test_apps/sdmmc/pytest_sdmmc.py b/components/esp_driver_sdmmc/test_apps/sdmmc/pytest_sdmmc.py index 6d4e712930..747b8f36ff 100644 --- a/components/esp_driver_sdmmc/test_apps/sdmmc/pytest_sdmmc.py +++ b/components/esp_driver_sdmmc/test_apps/sdmmc/pytest_sdmmc.py @@ -1,12 +1,16 @@ # SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD # SPDX-License-Identifier: CC0-1.0 - import pytest from pytest_embedded_idf import IdfDut @pytest.mark.esp32 @pytest.mark.esp32s3 +@pytest.mark.esp32p4 +@pytest.mark.temp_skip_ci(targets=['esp32p4'], reason='lack of runners, IDF-8970') @pytest.mark.sdcard def test_sdmmc(dut: IdfDut) -> None: - dut.run_all_single_board_cases() + # SDMMC driver can't be reinitialized if the test fails, + # so we need to reset the board between tests to avoid failing + # all the tests after the first one fails. + dut.run_all_single_board_cases(reset=True)