Skip to content

Commit 57a8012

Browse files
committed
Merge branch 'ci/sdmmc_tests' into 'master'
sdmmc: test-related fixes Closes IDF-8734 See merge request espressif/esp-idf!30221
2 parents 288f769 + 3f663ec commit 57a8012

File tree

5 files changed

+33
-7
lines changed

5 files changed

+33
-7
lines changed

components/esp_driver_sdmmc/src/sdmmc_host.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,8 @@ esp_err_t sdmmc_host_start_command(int slot, sdmmc_hw_cmd_t cmd, uint32_t arg)
348348
if (!(slot == 0 || slot == 1)) {
349349
return ESP_ERR_INVALID_ARG;
350350
}
351-
if (!sdmmc_ll_is_card_detected(s_host_ctx.hal.dev, slot)) {
351+
// if this isn't a clock update command, check the card detect status
352+
if (!sdmmc_ll_is_card_detected(s_host_ctx.hal.dev, slot) && !cmd.update_clk_reg) {
352353
return ESP_ERR_NOT_FOUND;
353354
}
354355
if (cmd.data_expected && cmd.rw && sdmmc_ll_is_card_write_protected(s_host_ctx.hal.dev, slot)) {

components/esp_driver_sdmmc/test_apps/sd_test_utils/components/sdmmc_test_boards/sdmmc_test_board_defs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ static const sdmmc_test_board_info_t s_board_info = {
341341
.d7 = GPIO_NUM_NC,
342342
.cd = GPIO_NUM_NC,
343343
.wp = GPIO_NUM_NC,
344-
.unused_pin = 2,
344+
.unused_pin = 54,
345345
}
346346
},
347347
};

components/esp_driver_sdmmc/test_apps/sdmmc/components/sdmmc_tests/sdmmc_test_cd_wp_sd.c

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,24 @@
1212
#include "sd_pwr_ctrl.h"
1313
#include "sd_pwr_ctrl_by_on_chip_ldo.h"
1414

15-
//TODO: IDF-8734
16-
#if !CONFIG_IDF_TARGET_ESP32 && !CONFIG_IDF_TARGET_ESP32S3
1715
TEST_CASE("CD input works in SD mode", "[sdmmc]")
1816
{
1917
sdmmc_host_t config = SDMMC_HOST_DEFAULT();
2018
sdmmc_slot_config_t slot_config = SDMMC_SLOT_CONFIG_DEFAULT();
2119
sdmmc_test_board_get_config_sdmmc(SDMMC_HOST_SLOT_1, &config, &slot_config);
2220
const int test_gpio = sdmmc_test_board_get_slot_info(SDMMC_HOST_SLOT_1)->unused_pin;
2321
slot_config.gpio_cd = test_gpio;
22+
#if SOC_SDMMC_IO_POWER_EXTERNAL
23+
#define SDMMC_PWR_LDO_CHANNEL 4
24+
sd_pwr_ctrl_ldo_config_t ldo_config = {
25+
.ldo_chan_id = SDMMC_PWR_LDO_CHANNEL,
26+
};
27+
sd_pwr_ctrl_handle_t pwr_ctrl_handle = NULL;
28+
29+
TEST_ESP_OK(sd_pwr_ctrl_new_on_chip_ldo(&ldo_config, &pwr_ctrl_handle));
30+
config.pwr_ctrl_handle = pwr_ctrl_handle;
31+
#endif
32+
2433
sdmmc_test_board_card_power_set(true);
2534
TEST_ESP_OK(sdmmc_host_init());
2635
TEST_ESP_OK(sdmmc_host_init_slot(SDMMC_HOST_SLOT_1, &slot_config));
@@ -42,6 +51,17 @@ TEST_CASE("WP input works in SD mode", "[sdmmc]")
4251
sdmmc_test_board_get_config_sdmmc(SDMMC_HOST_SLOT_1, &config, &slot_config);
4352
const int test_gpio = sdmmc_test_board_get_slot_info(SDMMC_HOST_SLOT_1)->unused_pin;
4453
slot_config.gpio_wp = test_gpio;
54+
#if SOC_SDMMC_IO_POWER_EXTERNAL
55+
#define SDMMC_PWR_LDO_CHANNEL 4
56+
sd_pwr_ctrl_ldo_config_t ldo_config = {
57+
.ldo_chan_id = SDMMC_PWR_LDO_CHANNEL,
58+
};
59+
sd_pwr_ctrl_handle_t pwr_ctrl_handle = NULL;
60+
61+
TEST_ESP_OK(sd_pwr_ctrl_new_on_chip_ldo(&ldo_config, &pwr_ctrl_handle));
62+
config.pwr_ctrl_handle = pwr_ctrl_handle;
63+
#endif
64+
4565
TEST_ESP_OK(sdmmc_host_init());
4666
TEST_ESP_OK(sdmmc_host_init_slot(SDMMC_HOST_SLOT_1, &slot_config));
4767

@@ -53,4 +73,3 @@ TEST_CASE("WP input works in SD mode", "[sdmmc]")
5373
TEST_ESP_OK(sd_pwr_ctrl_del_on_chip_ldo(config.pwr_ctrl_handle));
5474
#endif
5575
}
56-
#endif

components/esp_driver_sdmmc/test_apps/sdmmc/main/test_app_main.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,13 @@
1313

1414
void setUp(void)
1515
{
16+
printf("%s", ""); /* sneakily lazy-allocate the reent structure for this test task */
1617
unity_utils_record_free_mem();
1718
}
1819

1920
void tearDown(void)
2021
{
22+
esp_reent_cleanup();
2123
unity_utils_evaluate_leaks_direct(TEST_MEMORY_LEAK_THRESHOLD);
2224
}
2325

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
# SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
22
# SPDX-License-Identifier: CC0-1.0
3-
43
import pytest
54
from pytest_embedded_idf import IdfDut
65

76

87
@pytest.mark.esp32
98
@pytest.mark.esp32s3
9+
@pytest.mark.esp32p4
10+
@pytest.mark.temp_skip_ci(targets=['esp32p4'], reason='lack of runners, IDF-8970')
1011
@pytest.mark.sdcard
1112
def test_sdmmc(dut: IdfDut) -> None:
12-
dut.run_all_single_board_cases()
13+
# SDMMC driver can't be reinitialized if the test fails,
14+
# so we need to reset the board between tests to avoid failing
15+
# all the tests after the first one fails.
16+
dut.run_all_single_board_cases(reset=True)

0 commit comments

Comments
 (0)