mirror of
https://github.com/espressif/esp-idf.git
synced 2025-07-31 19:24:33 +02:00
test(sdmmc): Add test_apps test for sdmmc component
This commit is contained in:
@@ -9,7 +9,8 @@ if(CONFIG_SOC_SDMMC_HOST_SUPPORTED)
|
||||
"sdmmc_test_erase_sd.c"
|
||||
"sdmmc_test_trim_sd.c"
|
||||
"sdmmc_test_discard_sd.c"
|
||||
"sdmmc_test_sanitize_sd.c")
|
||||
"sdmmc_test_sanitize_sd.c"
|
||||
"sdmmc_test_various_cmds.c")
|
||||
endif()
|
||||
|
||||
set(priv_requires "sdmmc"
|
||||
|
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#include "sdkconfig.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "unity.h"
|
||||
#include "esp_log.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "driver/sdmmc_defs.h"
|
||||
#include "driver/sdmmc_host.h"
|
||||
#include "sdmmc_cmd.h"
|
||||
#include "esp_private/sdmmc_common.h"
|
||||
#include "sdmmc_test_begin_end_sd.h"
|
||||
|
||||
#if !SOC_SDMMC_HOST_SUPPORTED
|
||||
#error "Targets with SDMMC host supported only"
|
||||
#endif // !SOC_SDMMC_HOST_SUPPORTED
|
||||
|
||||
static const char* TAG = "sdmmc_test_various_cmds";
|
||||
|
||||
static void sdmmc_write_sectors_cmd25_error_test_acmd22(sdmmc_card_t* card, uint32_t write_size)
|
||||
{
|
||||
esp_err_t err = ESP_OK;
|
||||
size_t block_size = (size_t)card->csd.sector_size;
|
||||
size_t block_count = write_size / block_size;
|
||||
void* buf = heap_caps_calloc(1, write_size, MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT | MALLOC_CAP_DMA);
|
||||
TEST_ASSERT_NOT_NULL(buf);
|
||||
|
||||
if (!host_is_spi(card)) {
|
||||
err = sdmmc_wait_for_idle(card, 0); // wait for the card to be idle (in transfer state)
|
||||
if (err != ESP_OK) {
|
||||
free(buf);
|
||||
}
|
||||
TEST_ESP_OK(err);
|
||||
}
|
||||
|
||||
// Try to write to the card
|
||||
err = sdmmc_write_sectors(card, buf, 0, block_count);
|
||||
free(buf);
|
||||
TEST_ESP_OK(err);
|
||||
|
||||
// Check if the number of written blocks is equal to the number ACMD22 returns
|
||||
// ACMD22 is usually only called if CMD25 fails but here we call it anyway to test it
|
||||
size_t sucessfully_written_blocks;
|
||||
err = sdmmc_send_cmd_num_of_written_blocks(card, &sucessfully_written_blocks);
|
||||
TEST_ESP_OK(err);
|
||||
TEST_ASSERT_EQUAL_size_t(sucessfully_written_blocks, block_count);
|
||||
ESP_LOGI(TAG, "%s: ACMD22 successfully written %zu blocks out of %zu", __func__, sucessfully_written_blocks, block_count);
|
||||
}
|
||||
|
||||
static void do_one_mmc_acmd22_test(int slot, int width, int freq_khz, int ddr)
|
||||
{
|
||||
sdmmc_card_t card;
|
||||
sdmmc_test_sd_skip_if_board_incompatible(slot, width, freq_khz, ddr);
|
||||
sdmmc_test_sd_begin(slot, width, freq_khz, ddr, &card);
|
||||
sdmmc_card_print_info(stdout, &card);
|
||||
sdmmc_write_sectors_cmd25_error_test_acmd22(&card, 4096 * 4);
|
||||
sdmmc_test_sd_end(&card);
|
||||
}
|
||||
|
||||
TEST_CASE("send ACMD22 after writing multiple blocks to check real number of successfully written blocks, slot 0, 1-bit", "[sdmmc]")
|
||||
{
|
||||
do_one_mmc_acmd22_test(SLOT_0, 1, SDMMC_FREQ_HIGHSPEED, NO_DDR);
|
||||
}
|
||||
|
||||
TEST_CASE("send ACMD22 after writing multiple blocks to check real number of successfully written blocks, slot 1, 1-bit", "[sdmmc]")
|
||||
{
|
||||
do_one_mmc_acmd22_test(SLOT_1, 1, SDMMC_FREQ_HIGHSPEED, NO_DDR);
|
||||
}
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2006 Uwe Stuehler <uwe@openbsd.org>
|
||||
* Adaptations to ESP-IDF Copyright (c) 2016-2018 Espressif Systems (Shanghai) PTE LTD
|
||||
* Adaptations to ESP-IDF Copyright (c) 2016-2024 Espressif Systems (Shanghai) PTE LTD
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
#include <inttypes.h>
|
||||
#include "sdmmc_common.h"
|
||||
#include "esp_private/sdmmc_common.h"
|
||||
|
||||
static const char* TAG = "sdmmc_cmd";
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2006 Uwe Stuehler <uwe@openbsd.org>
|
||||
* Adaptations to ESP-IDF Copyright (c) 2016-2018 Espressif Systems (Shanghai) PTE LTD
|
||||
* Adaptations to ESP-IDF Copyright (c) 2016-2024 Espressif Systems (Shanghai) PTE LTD
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
@@ -18,7 +18,7 @@
|
||||
#include <inttypes.h>
|
||||
#include "esp_log.h"
|
||||
#include "esp_timer.h"
|
||||
#include "sdmmc_common.h"
|
||||
#include "esp_private/sdmmc_common.h"
|
||||
|
||||
static const char* TAG = "sdmmc_common";
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2006 Uwe Stuehler <uwe@openbsd.org>
|
||||
* Adaptations to ESP-IDF Copyright (c) 2016-2018 Espressif Systems (Shanghai) PTE LTD
|
||||
* Adaptations to ESP-IDF Copyright (c) 2016-2024 Espressif Systems (Shanghai) PTE LTD
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
@@ -15,7 +15,7 @@
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "sdmmc_common.h"
|
||||
#include "esp_private/sdmmc_common.h"
|
||||
#include "sd_pwr_ctrl_by_on_chip_ldo.h"
|
||||
#include "sd_pwr_ctrl.h"
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2006 Uwe Stuehler <uwe@openbsd.org>
|
||||
* Adaptations to ESP-IDF Copyright (c) 2016-2018 Espressif Systems (Shanghai) PTE LTD
|
||||
* Adaptations to ESP-IDF Copyright (c) 2016-2024 Espressif Systems (Shanghai) PTE LTD
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
@@ -16,7 +16,7 @@
|
||||
*/
|
||||
|
||||
#include <inttypes.h>
|
||||
#include "sdmmc_common.h"
|
||||
#include "esp_private/sdmmc_common.h"
|
||||
#include "esp_attr.h"
|
||||
#include "esp_compiler.h"
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2006 Uwe Stuehler <uwe@openbsd.org>
|
||||
* Adaptations to ESP-IDF Copyright (c) 2016-2018 Espressif Systems (Shanghai) PTE LTD
|
||||
* Adaptations to ESP-IDF Copyright (c) 2016-2024 Espressif Systems (Shanghai) PTE LTD
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <unistd.h>
|
||||
#include "sdmmc_common.h"
|
||||
#include "esp_private/sdmmc_common.h"
|
||||
|
||||
static const char* TAG = "sdmmc_mmc";
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2006 Uwe Stuehler <uwe@openbsd.org>
|
||||
* Adaptations to ESP-IDF Copyright (c) 2016-2018 Espressif Systems (Shanghai) PTE LTD
|
||||
* Adaptations to ESP-IDF Copyright (c) 2016-2024 Espressif Systems (Shanghai) PTE LTD
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
@@ -19,7 +19,7 @@
|
||||
#include "esp_check.h"
|
||||
#include "esp_timer.h"
|
||||
#include "esp_cache.h"
|
||||
#include "sdmmc_common.h"
|
||||
#include "esp_private/sdmmc_common.h"
|
||||
|
||||
static const char* TAG = "sdmmc_sd";
|
||||
|
||||
|
@@ -503,8 +503,8 @@ components/protocomm/include/transports/protocomm_console.h
|
||||
components/protocomm/include/transports/protocomm_httpd.h
|
||||
components/riscv/include/riscv/csr.h
|
||||
components/riscv/include/riscv/encoding.h
|
||||
components/sdmmc/include/esp_private/sdmmc_common.h
|
||||
components/sdmmc/sdmmc_common.c
|
||||
components/sdmmc/sdmmc_common.h
|
||||
components/sdmmc/sdmmc_init.c
|
||||
components/sdmmc/sdmmc_io.c
|
||||
components/sdmmc/sdmmc_mmc.c
|
||||
|
Reference in New Issue
Block a user