mirror of
https://github.com/espressif/esp-idf.git
synced 2024-09-19 14:26:01 -04:00
Merge branch 'test/improve_sdmmc_tests' into 'master'
sd: improve tests and added on CI See merge request espressif/esp-idf!27384
This commit is contained in:
commit
d36fe73960
@ -715,6 +715,24 @@ pytest_components_esp32_adc:
|
||||
artifacts: false
|
||||
tags: [ esp32, adc ]
|
||||
|
||||
pytest_components_esp32_sdmmc:
|
||||
extends:
|
||||
- .pytest_components_dir_template
|
||||
- .rules:test:component_ut-esp32
|
||||
needs:
|
||||
- job: build_pytest_components_esp32
|
||||
artifacts: false
|
||||
tags: [ esp32, sdcard ]
|
||||
|
||||
pytest_components_esp32s3_sdmmc:
|
||||
extends:
|
||||
- .pytest_components_dir_template
|
||||
- .rules:test:component_ut-esp32s3
|
||||
needs:
|
||||
- job: build_pytest_components_esp32s3
|
||||
artifacts: false
|
||||
tags: [ esp32s3, sdcard ]
|
||||
|
||||
pytest_components_esp32_sdio:
|
||||
extends:
|
||||
- .pytest_components_dir_template
|
||||
@ -1171,15 +1189,6 @@ pytest_components_esp32c3_flash_multi:
|
||||
artifacts: false
|
||||
tags: [ esp32c3, flash_multi ]
|
||||
|
||||
pytest_components_esp32_sdmmc:
|
||||
extends:
|
||||
- .pytest_components_dir_template
|
||||
- .rules:test:component_ut-esp32
|
||||
needs:
|
||||
- job: build_pytest_components_esp32
|
||||
artifacts: false
|
||||
tags: [ esp32, sdcard_sdmode ]
|
||||
|
||||
pytest_components_esp32_sdspi:
|
||||
extends:
|
||||
- .pytest_components_dir_template
|
||||
|
@ -0,0 +1,6 @@
|
||||
components/esp_driver_sdmmc/test_apps/sdmmc:
|
||||
disable:
|
||||
- if: SOC_SDMMC_HOST_SUPPORTED != 1
|
||||
depends_components:
|
||||
- sdmmc
|
||||
- esp_driver_sdmmc
|
@ -0,0 +1,9 @@
|
||||
set(srcs "sdmmc_test_cd_wp_common.c" "sdmmc_test_rw_common.c")
|
||||
|
||||
set(public_include "include")
|
||||
|
||||
idf_component_register(
|
||||
SRCS ${srcs}
|
||||
INCLUDE_DIRS ${public_include}
|
||||
PRIV_REQUIRES sdmmc unity test_utils
|
||||
)
|
@ -11,7 +11,6 @@
|
||||
#include "sdmmc_cmd.h"
|
||||
#include "sdmmc_test_cd_wp_common.h"
|
||||
|
||||
|
||||
void sdmmc_test_cd_input(int gpio_cd_num, const sdmmc_host_t* config)
|
||||
{
|
||||
sdmmc_card_t* card = malloc(sizeof(sdmmc_card_t));
|
@ -19,7 +19,8 @@
|
||||
static void do_single_rw_perf_test(sdmmc_card_t* card, size_t start_block,
|
||||
size_t block_count, size_t alignment, FILE* performance_log);
|
||||
|
||||
static void fill_buffer(uint32_t seed, uint8_t* dst, size_t count) {
|
||||
static void fill_buffer(uint32_t seed, uint8_t* dst, size_t count)
|
||||
{
|
||||
srand(seed);
|
||||
for (size_t i = 0; i < count; ++i) {
|
||||
uint32_t val = rand();
|
||||
@ -29,7 +30,8 @@ static void fill_buffer(uint32_t seed, uint8_t* dst, size_t count) {
|
||||
|
||||
// Check if the buffer pointed to by 'dst' contains 'count' 32-bit
|
||||
// ints generated from 'rand' with the starting value of 'seed'
|
||||
static void check_buffer(uint32_t seed, const uint8_t* src, size_t count) {
|
||||
static void check_buffer(uint32_t seed, const uint8_t* src, size_t count)
|
||||
{
|
||||
srand(seed);
|
||||
for (size_t i = 0; i < count; ++i) {
|
||||
uint32_t val;
|
||||
@ -77,7 +79,7 @@ static void do_single_rw_perf_test(sdmmc_card_t* card, size_t start_block,
|
||||
stdout = performance_log;
|
||||
static const char wr_speed_str[] = "SDMMC_WR_SPEED";
|
||||
static const char rd_speed_str[] = "SDMMC_RD_SPEED";
|
||||
int aligned = ((alignment % 4) == 0)? 1: 0;
|
||||
int aligned = ((alignment % 4) == 0) ? 1 : 0;
|
||||
IDF_LOG_PERFORMANCE(wr_speed_str, "%d, blk_n: %d, aligned: %d",
|
||||
(int)(total_size * 1000 / time_wr), block_count, aligned);
|
||||
IDF_LOG_PERFORMANCE(rd_speed_str, "%d, blk_n: %d, aligned: %d",
|
||||
@ -142,15 +144,15 @@ void sdmmc_test_rw_with_offset(sdmmc_card_t* card)
|
||||
do_single_rw_perf_test(card, card->csd.capacity - 64, 32, 4, NULL);
|
||||
do_single_rw_perf_test(card, card->csd.capacity - 64, 64, 4, NULL);
|
||||
do_single_rw_perf_test(card, card->csd.capacity - 8, 1, 4, NULL);
|
||||
do_single_rw_perf_test(card, card->csd.capacity/2, 1, 4, NULL);
|
||||
do_single_rw_perf_test(card, card->csd.capacity/2, 4, 4, NULL);
|
||||
do_single_rw_perf_test(card, card->csd.capacity/2, 8, 4, NULL);
|
||||
do_single_rw_perf_test(card, card->csd.capacity/2, 16, 4, NULL);
|
||||
do_single_rw_perf_test(card, card->csd.capacity/2, 32, 4, NULL);
|
||||
do_single_rw_perf_test(card, card->csd.capacity/2, 64, 4, NULL);
|
||||
do_single_rw_perf_test(card, card->csd.capacity/2, 128, 4, NULL);
|
||||
do_single_rw_perf_test(card, card->csd.capacity / 2, 1, 4, NULL);
|
||||
do_single_rw_perf_test(card, card->csd.capacity / 2, 4, 4, NULL);
|
||||
do_single_rw_perf_test(card, card->csd.capacity / 2, 8, 4, NULL);
|
||||
do_single_rw_perf_test(card, card->csd.capacity / 2, 16, 4, NULL);
|
||||
do_single_rw_perf_test(card, card->csd.capacity / 2, 32, 4, NULL);
|
||||
do_single_rw_perf_test(card, card->csd.capacity / 2, 64, 4, NULL);
|
||||
do_single_rw_perf_test(card, card->csd.capacity / 2, 128, 4, NULL);
|
||||
/* unaligned */
|
||||
do_single_rw_perf_test(card, card->csd.capacity/2, 1, 1, NULL);
|
||||
do_single_rw_perf_test(card, card->csd.capacity/2, 8, 1, NULL);
|
||||
do_single_rw_perf_test(card, card->csd.capacity/2, 128, 1, NULL);
|
||||
do_single_rw_perf_test(card, card->csd.capacity / 2, 1, 1, NULL);
|
||||
do_single_rw_perf_test(card, card->csd.capacity / 2, 8, 1, NULL);
|
||||
do_single_rw_perf_test(card, card->csd.capacity / 2, 128, 1, NULL);
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
idf_component_register(SRCS sdmmc_test_board.c sdmmc_test_board_defs.c
|
||||
INCLUDE_DIRS include
|
||||
PRIV_REQUIRES sdmmc esp_driver_sdmmc esp_driver_sdspi)
|
||||
REQUIRES esp_driver_sdmmc esp_driver_sdspi esp_driver_gpio)
|
@ -0,0 +1,8 @@
|
||||
# SDMMC Test Boards
|
||||
|
||||
This component is a test utility component for test board info:
|
||||
- SDMMC test boards (e.g. ESP32_WROVER_KIT, ESP32S3_USB_OTG, etc.)
|
||||
- eMMC test boards
|
||||
- SDMMC with SD breakout adapter board
|
||||
- SDSPI with SD breakout adapter board
|
||||
- ...
|
@ -56,7 +56,6 @@ typedef struct {
|
||||
void (*card_power_set)(bool); /*< function to turn card power on or off */
|
||||
} sdmmc_test_board_info_t;
|
||||
|
||||
|
||||
/**
|
||||
* @brief Get information about the test board
|
||||
* @return Pointer to the board information structure
|
||||
@ -92,7 +91,6 @@ void sdmmc_test_board_get_config_sdmmc(int slot_index, sdmmc_host_t *out_host_co
|
||||
void sdmmc_test_board_get_config_sdspi(int slot_index, sdmmc_host_t *out_host_config,
|
||||
spi_bus_config_t *out_spi_bus_config, sdspi_device_config_t *out_dev_config);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Set card power on or off
|
||||
* For boards with card power control circuit, this function allows powering the card up or down.
|
@ -8,7 +8,6 @@
|
||||
#include "sdkconfig.h"
|
||||
#include "soc/soc_caps.h"
|
||||
|
||||
|
||||
const sdmmc_test_board_slot_info_t* sdmmc_test_board_get_slot_info(int slot_index)
|
||||
{
|
||||
assert(slot_index >= 0 && slot_index < SDMMC_TEST_BOARD_MAX_SLOTS);
|
@ -385,7 +385,6 @@ static const sdmmc_test_board_info_t s_board_info = {
|
||||
|
||||
#endif // CONFIG_SDMMC_BOARD_*
|
||||
|
||||
|
||||
const sdmmc_test_board_info_t* sdmmc_test_board_get_info(void)
|
||||
{
|
||||
return &s_board_info;
|
@ -0,0 +1,8 @@
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
list(APPEND EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/tools/unit-test-app/components")
|
||||
list(APPEND EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/components/esp_driver_sdmmc/test_apps/sd_test_utils/components")
|
||||
set(COMPONENTS main)
|
||||
|
||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||
project(sdmmc_test_console)
|
2
components/esp_driver_sdmmc/test_apps/sdmmc/README.md
Normal file
2
components/esp_driver_sdmmc/test_apps/sdmmc/README.md
Normal file
@ -0,0 +1,2 @@
|
||||
| Supported Targets | ESP32 | ESP32-P4 | ESP32-S3 |
|
||||
| ----------------- | ----- | -------- | -------- |
|
@ -0,0 +1,20 @@
|
||||
set(srcs)
|
||||
|
||||
|
||||
if(CONFIG_SOC_SDMMC_HOST_SUPPORTED)
|
||||
list(APPEND srcs "sdmmc_test_begin_end_sd.c"
|
||||
"sdmmc_test_cd_wp_sd.c"
|
||||
"sdmmc_test_probe_sd.c"
|
||||
"sdmmc_test_rw_sd.c")
|
||||
endif()
|
||||
|
||||
set(priv_requires "sdmmc"
|
||||
"esp_driver_sdmmc"
|
||||
"sdmmc_test_boards"
|
||||
"common_test_flows"
|
||||
"unity"
|
||||
)
|
||||
|
||||
idf_component_register(SRCS ${srcs}
|
||||
PRIV_REQUIRES ${priv_requires}
|
||||
WHOLE_ARCHIVE TRUE)
|
@ -13,7 +13,7 @@
|
||||
#include "driver/sdmmc_host.h"
|
||||
#include "sd_protocol_defs.h"
|
||||
#include "sdmmc_cmd.h"
|
||||
#include "sdmmc_test_begin_end.h"
|
||||
#include "sdmmc_test_begin_end_sd.h"
|
||||
#include "hal/gpio_hal.h"
|
||||
|
||||
void sdmmc_test_sd_skip_if_board_incompatible(int slot, int width, int freq_khz, int ddr)
|
||||
@ -33,7 +33,8 @@ void sdmmc_test_sd_skip_if_board_incompatible(int slot, int width, int freq_khz,
|
||||
TEST_IGNORE_MESSAGE("Board doesn't support required bus width");
|
||||
}
|
||||
}
|
||||
void sdmmc_test_sd_begin(int slot, int width, int freq_khz, int ddr, sdmmc_card_t *out_card) {
|
||||
void sdmmc_test_sd_begin(int slot, int width, int freq_khz, int ddr, sdmmc_card_t *out_card)
|
||||
{
|
||||
sdmmc_host_t config = SDMMC_HOST_DEFAULT();
|
||||
sdmmc_slot_config_t slot_config = SDMMC_SLOT_CONFIG_DEFAULT();
|
||||
|
||||
@ -87,18 +88,18 @@ void sdmmc_test_sd_end(sdmmc_card_t *card)
|
||||
int slot = card->host.slot;
|
||||
const sdmmc_test_board_slot_info_t *slot_info = sdmmc_test_board_get_slot_info(slot);
|
||||
const int pins[] = {
|
||||
slot_info->clk,
|
||||
slot_info->cmd_mosi,
|
||||
slot_info->d0_miso,
|
||||
slot_info->d1,
|
||||
slot_info->d2,
|
||||
slot_info->d3_cs,
|
||||
slot_info->d4,
|
||||
slot_info->d5,
|
||||
slot_info->d6,
|
||||
slot_info->d7,
|
||||
slot_info->cd,
|
||||
slot_info->wp,
|
||||
slot_info->clk,
|
||||
slot_info->cmd_mosi,
|
||||
slot_info->d0_miso,
|
||||
slot_info->d1,
|
||||
slot_info->d2,
|
||||
slot_info->d3_cs,
|
||||
slot_info->d4,
|
||||
slot_info->d5,
|
||||
slot_info->d6,
|
||||
slot_info->d7,
|
||||
slot_info->cd,
|
||||
slot_info->wp,
|
||||
};
|
||||
const int num_pins = sizeof(pins) / sizeof(pins[0]);
|
||||
// Silence logging in gpio_reset_pin, which logs at INFO level
|
@ -19,7 +19,6 @@ extern "C" {
|
||||
|
||||
/* Helper functions to initialize/deinintalize the host (SDMMC/SDSPI) inside the test */
|
||||
|
||||
|
||||
#if SOC_SDMMC_HOST_SUPPORTED
|
||||
/**
|
||||
* @brief Skip the test if the board is incompatible with the given slot, width, frequency and DDR mode
|
||||
@ -49,25 +48,6 @@ void sdmmc_test_sd_begin(int slot, int width, int freq_khz, int ddr, sdmmc_card_
|
||||
void sdmmc_test_sd_end(sdmmc_card_t *card);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Skip the test if the board is incompatible with the given slot and frequency, for SPI mode.
|
||||
* @see sdmmc_test_sd_skip_if_board_incompatible
|
||||
*/
|
||||
void sdmmc_test_spi_skip_if_board_incompatible(int slot, int freq_khz);
|
||||
|
||||
/**
|
||||
* @brief Helper function to initialize the SDMMC host and slot for the test using the given settings, for SPI mode
|
||||
* @see sdmmc_test_sd_begin
|
||||
*/
|
||||
void sdmmc_test_spi_begin(int slot, int freq_khz, sdmmc_card_t *out_card);
|
||||
|
||||
/**
|
||||
* @brief Helper function to deinitialize the SDMMC host and slot after the test, for SPI mode
|
||||
* @see sdmmc_test_sd_end
|
||||
*/
|
||||
void sdmmc_test_spi_end(int slot, sdmmc_card_t *card);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
@ -10,6 +10,8 @@
|
||||
#include "sdmmc_test_cd_wp_common.h"
|
||||
#include "sdmmc_test_board.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();
|
||||
@ -43,3 +45,4 @@ TEST_CASE("WP input works in SD mode", "[sdmmc]")
|
||||
TEST_ESP_OK(sdmmc_host_deinit());
|
||||
sdmmc_test_board_card_power_set(false);
|
||||
}
|
||||
#endif
|
@ -6,7 +6,7 @@
|
||||
#include <stddef.h>
|
||||
#include "unity.h"
|
||||
#include "sdmmc_cmd.h"
|
||||
#include "sdmmc_test_begin_end.h"
|
||||
#include "sdmmc_test_begin_end_sd.h"
|
||||
|
||||
static void do_one_sdmmc_probe_test(int slot, int width, int freq_khz, int ddr)
|
||||
{
|
@ -7,7 +7,7 @@
|
||||
#include <stddef.h>
|
||||
#include "unity.h"
|
||||
#include "sdmmc_cmd.h"
|
||||
#include "sdmmc_test_begin_end.h"
|
||||
#include "sdmmc_test_begin_end_sd.h"
|
||||
#include "sdmmc_test_rw_common.h"
|
||||
|
||||
/* ========== Read/write performance tests, SD ========== */
|
@ -0,0 +1,13 @@
|
||||
set(srcs "test_app_main.c")
|
||||
|
||||
set(priv_requires
|
||||
# tests reside in this component, also available for `sdmmc_console`
|
||||
sdmmc_tests
|
||||
# general
|
||||
unity
|
||||
)
|
||||
|
||||
idf_component_register(SRCS ${srcs}
|
||||
INCLUDE_DIRS "."
|
||||
PRIV_REQUIRES ${priv_requires}
|
||||
WHOLE_ARCHIVE TRUE)
|
@ -0,0 +1,43 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: CC0-1.0
|
||||
*/
|
||||
|
||||
#include "unity.h"
|
||||
#include "unity_test_utils.h"
|
||||
#include "esp_heap_caps.h"
|
||||
#include "sdkconfig.h"
|
||||
|
||||
#define TEST_MEMORY_LEAK_THRESHOLD (300)
|
||||
|
||||
void setUp(void)
|
||||
{
|
||||
unity_utils_record_free_mem();
|
||||
}
|
||||
|
||||
void tearDown(void)
|
||||
{
|
||||
unity_utils_evaluate_leaks_direct(TEST_MEMORY_LEAK_THRESHOLD);
|
||||
}
|
||||
|
||||
void app_main(void)
|
||||
{
|
||||
/*
|
||||
_____ _ ______________ ______ ________
|
||||
|_ _| | | / ___| _ \ \/ || \/ / __ \
|
||||
| | ___ ___| |_ \ `--.| | | | . . || . . | / \/
|
||||
| |/ _ \/ __| __| `--. \ | | | |\/| || |\/| | |
|
||||
| | __/\__ \ |_ /\__/ / |/ /| | | || | | | \__/\
|
||||
\_/\___||___/\__| \____/|___/ \_| |_/\_| |_/\____/
|
||||
*/
|
||||
|
||||
printf(" _____ _ ______________ ______ ________\n");
|
||||
printf("|_ _| | | / ___| _ \\ \\/ || \\/ / __ \\ \n");
|
||||
printf(" | | ___ ___| |_ \\ `--.| | | | . . || . . | / \\/\n");
|
||||
printf(" | |/ _ \\/ __| __| `--. \\ | | | |\\/| || |\\/| | |\n");
|
||||
printf(" | | __/\\__ \\ |_ /\\__/ / |/ /| | | || | | | \\__/\\\n");
|
||||
printf(" \\_/\\___||___/\\__| \\____/|___/ \\_| |_/\\_| |_/\\____/\n");
|
||||
|
||||
unity_run_menu();
|
||||
}
|
12
components/esp_driver_sdmmc/test_apps/sdmmc/pytest_sdmmc.py
Normal file
12
components/esp_driver_sdmmc/test_apps/sdmmc/pytest_sdmmc.py
Normal file
@ -0,0 +1,12 @@
|
||||
# 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.sdcard
|
||||
def test_sdmmc(dut: IdfDut) -> None:
|
||||
dut.run_all_single_board_cases()
|
@ -0,0 +1,2 @@
|
||||
CONFIG_FREERTOS_HZ=1000
|
||||
CONFIG_ESP_TASK_WDT_EN=n
|
10
components/esp_driver_sdspi/test_apps/.build-test-rules.yml
Normal file
10
components/esp_driver_sdspi/test_apps/.build-test-rules.yml
Normal file
@ -0,0 +1,10 @@
|
||||
components/esp_driver_sdspi/test_apps/sdspi:
|
||||
disable:
|
||||
- if: SOC_GPSPI_SUPPORTED != 1
|
||||
disable_test:
|
||||
- if: SOC_GPSPI_SUPPORTED == 1
|
||||
temporary: true
|
||||
reason: will add runners later # TODO: IDF-8747
|
||||
depends_components:
|
||||
- sdmmc
|
||||
- esp_driver_sdspi
|
10
components/esp_driver_sdspi/test_apps/sdspi/CMakeLists.txt
Normal file
10
components/esp_driver_sdspi/test_apps/sdspi/CMakeLists.txt
Normal file
@ -0,0 +1,10 @@
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
list(APPEND EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/tools/unit-test-app/components")
|
||||
list(APPEND EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/components/esp_driver_sdmmc/test_apps/sd_test_utils/components")
|
||||
list(APPEND EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/components/esp_driver_sdmmc/test_apps/sdmmc/components/sdmmc_tests")
|
||||
|
||||
set(COMPONENTS main)
|
||||
|
||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||
project(sdmmc_test_console)
|
2
components/esp_driver_sdspi/test_apps/sdspi/README.md
Normal file
2
components/esp_driver_sdspi/test_apps/sdspi/README.md
Normal file
@ -0,0 +1,2 @@
|
||||
| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C6 | ESP32-H2 | ESP32-P4 | ESP32-S2 | ESP32-S3 |
|
||||
| ----------------- | ----- | -------- | -------- | -------- | -------- | -------- | -------- | -------- |
|
@ -0,0 +1,19 @@
|
||||
set(srcs)
|
||||
|
||||
if(CONFIG_SOC_GPSPI_SUPPORTED)
|
||||
list(APPEND srcs "sdmmc_test_begin_end_spi.c"
|
||||
"sdmmc_test_cd_wp_spi.c"
|
||||
"sdmmc_test_probe_spi.c"
|
||||
"sdmmc_test_rw_spi.c")
|
||||
endif()
|
||||
|
||||
set(priv_requires "sdmmc"
|
||||
"esp_driver_sdspi"
|
||||
"sdmmc_test_boards"
|
||||
"common_test_flows"
|
||||
"unity"
|
||||
)
|
||||
|
||||
idf_component_register(SRCS ${srcs}
|
||||
PRIV_REQUIRES ${priv_requires}
|
||||
WHOLE_ARCHIVE TRUE)
|
@ -13,7 +13,7 @@
|
||||
#include "driver/sdspi_host.h"
|
||||
#include "sd_protocol_defs.h"
|
||||
#include "sdmmc_cmd.h"
|
||||
#include "sdmmc_test_begin_end.h"
|
||||
#include "sdmmc_test_begin_end_spi.h"
|
||||
|
||||
void sdmmc_test_spi_skip_if_board_incompatible(int slot, int freq_khz)
|
||||
{
|
@ -0,0 +1,42 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "sd_protocol_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Defines for readability */
|
||||
#define SLOT_0 0
|
||||
#define SLOT_1 1
|
||||
#define NO_DDR 0
|
||||
#define WITH_DDR 1
|
||||
|
||||
/* Helper functions to initialize/deinintalize the host (SDMMC/SDSPI) inside the test */
|
||||
|
||||
/**
|
||||
* @brief Skip the test if the board is incompatible with the given slot and frequency, for SPI mode.
|
||||
* @see sdmmc_test_sd_skip_if_board_incompatible
|
||||
*/
|
||||
void sdmmc_test_spi_skip_if_board_incompatible(int slot, int freq_khz);
|
||||
|
||||
/**
|
||||
* @brief Helper function to initialize the SDMMC host and slot for the test using the given settings, for SPI mode
|
||||
* @see sdmmc_test_sd_begin
|
||||
*/
|
||||
void sdmmc_test_spi_begin(int slot, int freq_khz, sdmmc_card_t *out_card);
|
||||
|
||||
/**
|
||||
* @brief Helper function to deinitialize the SDMMC host and slot after the test, for SPI mode
|
||||
* @see sdmmc_test_sd_end
|
||||
*/
|
||||
void sdmmc_test_spi_end(int slot, sdmmc_card_t *card);
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
@ -9,7 +9,7 @@
|
||||
#include "driver/sdspi_host.h"
|
||||
#include "sdmmc_cmd.h"
|
||||
#include "sdmmc_test_board.h"
|
||||
#include "sdmmc_test_begin_end.h"
|
||||
#include "sdmmc_test_begin_end_spi.h"
|
||||
#include "sdmmc_test_cd_wp_common.h"
|
||||
|
||||
TEST_CASE("CD input works in SPI mode", "[sdspi]")
|
@ -6,7 +6,7 @@
|
||||
#include <stddef.h>
|
||||
#include "unity.h"
|
||||
#include "sdmmc_cmd.h"
|
||||
#include "sdmmc_test_begin_end.h"
|
||||
#include "sdmmc_test_begin_end_spi.h"
|
||||
|
||||
static void do_one_sdspi_probe(int slot, int freq_khz)
|
||||
{
|
||||
@ -30,13 +30,19 @@ TEST_CASE("sdspi probe, slot 0, HS", "[sdspi]")
|
||||
do_one_sdspi_probe(SLOT_0, SDMMC_FREQ_HIGHSPEED);
|
||||
}
|
||||
|
||||
#if !CONFIG_IDF_TARGET_ESP32 && !CONFIG_IDF_TARGET_ESP32S3
|
||||
//TODO: IDF-8750. Leaks too much memory, needs check
|
||||
TEST_CASE("sdspi probe, slot 1", "[sdspi]")
|
||||
{
|
||||
do_one_sdspi_probe(SLOT_1, SDMMC_FREQ_PROBING);
|
||||
do_one_sdspi_probe(SLOT_1, SDMMC_FREQ_DEFAULT);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !CONFIG_IDF_TARGET_ESP32 && !CONFIG_IDF_TARGET_ESP32S3
|
||||
//TODO: IDF-8749
|
||||
TEST_CASE("sdspi probe, slot 1, HS", "[sdspi]")
|
||||
{
|
||||
do_one_sdspi_probe(SLOT_1, SDMMC_FREQ_HIGHSPEED);
|
||||
}
|
||||
#endif
|
@ -6,7 +6,7 @@
|
||||
#include <stddef.h>
|
||||
#include "unity.h"
|
||||
#include "sdmmc_cmd.h"
|
||||
#include "sdmmc_test_begin_end.h"
|
||||
#include "sdmmc_test_begin_end_spi.h"
|
||||
#include "sdmmc_test_rw_common.h"
|
||||
|
||||
/* ========== Read/write performance tests, SPI ========== */
|
||||
@ -26,10 +26,13 @@ TEST_CASE("sdspi read/write performance, slot 0", "[sdspi]")
|
||||
do_one_sdspi_perf_test(SLOT_0, SDMMC_FREQ_HIGHSPEED);
|
||||
}
|
||||
|
||||
#if !CONFIG_IDF_TARGET_ESP32 && !CONFIG_IDF_TARGET_ESP32S3
|
||||
//TODO: IDF-8749
|
||||
TEST_CASE("sdspi read/write performance, slot 1", "[sdspi]")
|
||||
{
|
||||
do_one_sdspi_perf_test(SLOT_1, SDMMC_FREQ_HIGHSPEED);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* ========== Read/write tests with offset, SPI ========== */
|
||||
|
||||
@ -48,10 +51,13 @@ TEST_CASE("sdspi read/write performance with offset, slot 0", "[sdspi]")
|
||||
do_one_sdspi_rw_test_with_offset(SLOT_0, SDMMC_FREQ_HIGHSPEED);
|
||||
}
|
||||
|
||||
#if !CONFIG_IDF_TARGET_ESP32 && !CONFIG_IDF_TARGET_ESP32S3
|
||||
//TODO: IDF-8749
|
||||
TEST_CASE("sdspi read/write performance with offset, slot 1", "[sdspi]")
|
||||
{
|
||||
do_one_sdspi_rw_test_with_offset(SLOT_1, SDMMC_FREQ_HIGHSPEED);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* ========== Read/write tests with unaligned source/destination buffer, SPI ========== */
|
||||
|
@ -0,0 +1,13 @@
|
||||
set(srcs "test_app_main.c")
|
||||
|
||||
set(priv_requires
|
||||
# tests reside in this component, also available for `sdmmc_console`
|
||||
sdspi_tests
|
||||
# general
|
||||
unity
|
||||
)
|
||||
|
||||
idf_component_register(SRCS ${srcs}
|
||||
INCLUDE_DIRS "."
|
||||
PRIV_REQUIRES ${priv_requires}
|
||||
WHOLE_ARCHIVE TRUE)
|
@ -0,0 +1,43 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: CC0-1.0
|
||||
*/
|
||||
|
||||
#include "unity.h"
|
||||
#include "unity_test_utils.h"
|
||||
#include "esp_heap_caps.h"
|
||||
#include "sdkconfig.h"
|
||||
|
||||
#define TEST_MEMORY_LEAK_THRESHOLD (400)
|
||||
|
||||
void setUp(void)
|
||||
{
|
||||
unity_utils_record_free_mem();
|
||||
}
|
||||
|
||||
void tearDown(void)
|
||||
{
|
||||
unity_utils_evaluate_leaks_direct(TEST_MEMORY_LEAK_THRESHOLD);
|
||||
}
|
||||
|
||||
void app_main(void)
|
||||
{
|
||||
/*
|
||||
_____ _ ___________ ___________ _____
|
||||
|_ _| | | / ___| _ \/ ___| ___ \_ _|
|
||||
| | ___ ___| |_ \ `--.| | | |\ `--.| |_/ / | |
|
||||
| |/ _ \/ __| __| `--. \ | | | `--. \ __/ | |
|
||||
| | __/\__ \ |_ /\__/ / |/ / /\__/ / | _| |_
|
||||
\_/\___||___/\__| \____/|___/ \____/\_| \___/
|
||||
*/
|
||||
|
||||
printf(" _____ _ ___________ ___________ _____\n");
|
||||
printf("|_ _| | | / ___| _ \\/ ___| ___ \\_ _|\n");
|
||||
printf(" | | ___ ___| |_ \\ `--.| | | |\\ `--.| |_/ / | |\n");
|
||||
printf(" | |/ _ \\/ __| __| `--. \\ | | | `--. \\ __/ | |\n");
|
||||
printf(" | | __/\\__ \\ |_ /\\__/ / |/ / /\\__/ / | _| |_\n");
|
||||
printf(" \\_/\\___||___/\\__| \\____/|___/ \\____/\\_| \\___/\n");
|
||||
|
||||
unity_run_menu();
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
# SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
|
||||
# SPDX-License-Identifier: CC0-1.0
|
||||
|
||||
from pytest_embedded_idf import IdfDut
|
||||
|
||||
|
||||
def test_sdspi(dut: IdfDut) -> None:
|
||||
dut.run_all_single_board_cases()
|
@ -0,0 +1,2 @@
|
||||
CONFIG_FREERTOS_HZ=1000
|
||||
CONFIG_ESP_TASK_WDT_EN=n
|
@ -77,9 +77,10 @@ ENV_MARKERS = {
|
||||
'xtal_26mhz': 'runner with 26MHz xtal on board',
|
||||
'xtal_40mhz': 'runner with 40MHz xtal on board',
|
||||
'external_flash': 'external flash memory connected via VSPI (FSPI)',
|
||||
'sdcard_sdmode': 'sdcard running in SD mode',
|
||||
'sdcard_sdmode': 'sdcard running in SD mode, to be removed after test migration',
|
||||
'sdcard_spimode': 'sdcard running in SPI mode',
|
||||
'emmc': 'eMMC card',
|
||||
'sdcard': 'sdcard runner',
|
||||
'MSPI_F8R8': 'runner with Octal Flash and Octal PSRAM',
|
||||
'MSPI_F4R8': 'runner with Quad Flash and Octal PSRAM',
|
||||
'MSPI_F4R4': 'runner with Quad Flash and Quad PSRAM',
|
||||
|
@ -2,6 +2,9 @@ cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
list(APPEND EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/examples/system/console/advanced/components")
|
||||
list(APPEND EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/tools/unit-test-app/components")
|
||||
list(APPEND EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/components/esp_driver_sdmmc/test_apps/sd_test_utils/components")
|
||||
list(APPEND EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/components/esp_driver_sdmmc/test_apps/sdmmc/components/sdmmc_tests")
|
||||
list(APPEND EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/components/esp_driver_sdspi/test_apps/sdspi/components/sdspi_tests")
|
||||
set(COMPONENTS main)
|
||||
|
||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||
|
@ -1,6 +1,6 @@
|
||||
idf_component_register(SRCS cmd_sdmmc.c
|
||||
INCLUDE_DIRS .
|
||||
PRIV_REQUIRES console sdmmc esp_driver_sdmmc esp_driver_gpio esp_driver_sdspi
|
||||
sdmmc_test_board
|
||||
sdmmc_test_boards
|
||||
|
||||
)
|
||||
|
@ -1,28 +0,0 @@
|
||||
idf_component_register(
|
||||
SRCS
|
||||
sdmmc_test_cd_wp_common.c
|
||||
sdmmc_test_rw_common.c
|
||||
PRIV_REQUIRES
|
||||
sdmmc esp_driver_sdmmc esp_driver_sdspi sdmmc_test_board esp_timer unity test_utils
|
||||
WHOLE_ARCHIVE TRUE
|
||||
)
|
||||
|
||||
if(CONFIG_SOC_GPSPI_SUPPORTED)
|
||||
target_sources(
|
||||
${COMPONENT_LIB} PRIVATE
|
||||
sdmmc_test_rw_spi.c
|
||||
sdmmc_test_begin_end_spi.c
|
||||
sdmmc_test_probe_spi.c
|
||||
sdmmc_test_cd_wp_spi.c
|
||||
)
|
||||
endif()
|
||||
|
||||
if(CONFIG_SOC_SDMMC_HOST_SUPPORTED)
|
||||
target_sources(
|
||||
${COMPONENT_LIB} PRIVATE
|
||||
sdmmc_test_begin_end_sd.c
|
||||
sdmmc_test_rw_sd.c
|
||||
sdmmc_test_probe_sd.c
|
||||
sdmmc_test_cd_wp_sd.c
|
||||
)
|
||||
endif()
|
@ -4,7 +4,7 @@ set(requires
|
||||
# for console history
|
||||
vfs fatfs
|
||||
# sdmmc tests, themselves
|
||||
sdmmc_test_board sdmmc_tests
|
||||
sdmmc_test_boards sdmmc_tests sdspi_tests
|
||||
# various console comamnds
|
||||
cmd_unity cmd_system cmd_sdmmc
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user