mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
refactor(sdspi): added component pytest cases and enabled them on CI
This commit is contained in:
parent
9b0d75f2df
commit
4aadacbcdc
@ -2,7 +2,6 @@ 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_tests")
|
||||
set(COMPONENTS main)
|
||||
|
||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||
|
@ -1,108 +1,2 @@
|
||||
| Supported Targets | ESP32 | ESP32-P4 | ESP32-S3 |
|
||||
| ----------------- | ----- | -------- | -------- |
|
||||
|
||||
# SDMMC Test Application
|
||||
|
||||
This app is used to test the SDMMC protocol layer (in `sdmmc` component), as well as SDMMC and SDSPI drivers (in `driver` component).
|
||||
|
||||
The app serves two purposes:
|
||||
|
||||
1. It allows various Unity test cases for SDMMC protocol layer features: probing, data transfer, etc.
|
||||
2. It also allows running lower level operations from the console, which makes it useful as a debugging/hacking/experimentation tool when investigating SDMMC issues.
|
||||
- Initializing the SDMMC host in various modes
|
||||
- Probing the card
|
||||
- (more to come: sending commands, reading/writing data, etc.)
|
||||
|
||||
## SDMMC test app code overview
|
||||
|
||||
The app consists of several components:
|
||||
- `main` — small amount of code to initialize the console and register all the commands.
|
||||
- `components/cmd_unity` — console command to run Unity tests.
|
||||
- `components/cmd_sdmmc` — console commands for SDMMC low-level operations.
|
||||
- `components/sdmmc_test_board` — contains pin mappings for various development boards, and APIs for tests to access them.
|
||||
- `components/sdmmc_test` — contains the actual test cases.
|
||||
|
||||
## Supported boards
|
||||
|
||||
* ESP32-WROVER-KIT
|
||||
* ESP32 eMMC test board (black board with two SD card slots and eMMC)
|
||||
* ESP32-S3 USB_OTG v1. (Also works with an older ESP32-S2 variant of the board.)
|
||||
* ESP32-S3 eMMC test board (white board with two SD card slots and eMMC)
|
||||
* ESP32-S3-EYE
|
||||
* Breakout board for ESP32-C3 DevKitM-1
|
||||
* Custom board definition: specify the pin mapping in `menuconfig`.
|
||||
|
||||
## Using the app
|
||||
|
||||
### Select the target, configure, build and flash the app
|
||||
|
||||
1. Choose the chip target, and open menuconfig:
|
||||
```bash
|
||||
idf.py set-target esp32
|
||||
idf.py menuconfig
|
||||
```
|
||||
2. Select the development board in `SDMMC Test Board Configuration` menu. This will select the correct pins for the SD card slot on the board.
|
||||
3. Save the configuration and exit menuconfig.
|
||||
4. Build the app:
|
||||
```bash
|
||||
idf.py build
|
||||
```
|
||||
5. Flash and monitor:
|
||||
```bash
|
||||
idf.py flash monitor
|
||||
```
|
||||
|
||||
### Advanced: multiple build configurations side-by-side
|
||||
|
||||
It is often useful to verify changes in `sdmmc` component on multiple chips or development boards. To do this, it is possible to build the app multiple times, with different configurations, keeping the builds in separate directories.
|
||||
|
||||
1. Build the app for the first target. This command does multiple things: selects the target, sets the build directory to `build_esp32`, and puts the sdkconfig file into the build directory:
|
||||
```bash
|
||||
idf.py -D IDF_TARGET=esp32 -B build_esp32 -D SDKCONFIG=build_esp32/sdkconfig build
|
||||
```
|
||||
2. Flash and monitor. Note that the build directory has to be specified with `-B` option:
|
||||
```bash
|
||||
idf.py -B build_esp32 flash monitor
|
||||
```
|
||||
3. Now you can build the app for the second target in another build directory:
|
||||
```bash
|
||||
idf.py -D IDF_TARGET=esp32s3 -B build_esp32s3 -D SDKCONFIG=build_esp32s3/sdkconfig build
|
||||
```
|
||||
4. Flash and monitor, again specifying the build directory:
|
||||
```bash
|
||||
idf.py -B build_esp32s3 flash monitor
|
||||
```
|
||||
|
||||
Compared to the `idf.py set-target` approach, this method allows keeping multiple build configurations side-by-side, and switching between them easily. If you have multiple terminal windows open, you can use one window per board. Set ESPPORT environment variable to the correct serial port in each window, and flash and monitor the app in each window with the corresponding build directory (`-B`) argument.
|
||||
|
||||
### Console commands
|
||||
|
||||
The app supports the following console commands:
|
||||
|
||||
- Common system commands: `help`, `restart`, `version`, `free`, `heap`
|
||||
- Log control: `log_level <tag> <level>` — dynamically change the log level for a given tag. For example, `log_level sdmmc_req debug` will enable debug logging in sdmmc_transaction.c
|
||||
- Running unit tests: `test [index|name|tag|*]`.
|
||||
- If no argument is given, prints the list of available tests.
|
||||
- If a test index is given, runs the test with that index.
|
||||
- If a test name is given, runs the test with that name.
|
||||
- If a test tag is given, runs all tests with that tag. You can negate the tag by prefixing it with `!`, for example `test ![sdspi]` will run all tests except those tagged with `[sdspi]`.
|
||||
- SDMMC low-level commands: `sdmmc_host_init`, `sdmmc_host_deinit`, `card_init`, `card_info`. Refer to the `help` output for more details.
|
||||
|
||||
As most other IDF console applications, the app supports line editing, commands history and tab completion.
|
||||
|
||||
### Running test cases
|
||||
|
||||
When running the tests, keep in mind that once an SD card has been initialized in SPI mode, it cannot be re-initalized in SD mode without first powering it off. This means that on boards without an SD card power control circuit, it is not possible to run all the tests in one go with `test *` command. Run SDMMC tests first, then SDSPI tests: `test [sdmmc]` and then `test [sdspi]`. If you need to run SDMMC test again, power cycle the card first.
|
||||
|
||||
On chips without an SDMMC host controller only SDSPI tests are compiled. In this case, `test *` can be used to run all tests.
|
||||
|
||||
### Skipped tests
|
||||
|
||||
To make the app compatible with various development boards without having lots of ifdefs in test cases, the tests will be ignored if the board is not compatible with the test case. For example, on boards with just one SD card slot (Slot 1), every test which uses Slot 0 is skipped.
|
||||
|
||||
For example, when running sdspi tests on ESP32-WROVER-KIT you will see something like this:
|
||||
```
|
||||
12 Tests 0 Failures 5 Ignored
|
||||
```
|
||||
|
||||
This means that the 5 tests which use Slot 0 were skipped.
|
||||
|
@ -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)
|
@ -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 ========== */
|
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)
|
@ -0,0 +1,94 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "sdkconfig.h"
|
||||
#include "soc/soc_caps.h"
|
||||
#include "unity.h"
|
||||
#include "esp_log.h"
|
||||
#include "sdmmc_test_board.h"
|
||||
#include "driver/sdspi_host.h"
|
||||
#include "sd_protocol_defs.h"
|
||||
#include "sdmmc_cmd.h"
|
||||
#include "sdmmc_test_begin_end_spi.h"
|
||||
|
||||
void sdmmc_test_spi_skip_if_board_incompatible(int slot, int freq_khz)
|
||||
{
|
||||
sdmmc_host_t config = SDSPI_HOST_DEFAULT();
|
||||
sdspi_device_config_t dev_config = SDSPI_DEVICE_CONFIG_DEFAULT();
|
||||
spi_bus_config_t bus_config = {};
|
||||
|
||||
if (!sdmmc_test_board_has_slot(slot)) {
|
||||
TEST_IGNORE_MESSAGE("Board doesn't have the required slot");
|
||||
}
|
||||
if (sdmmc_test_board_slot_is_emmc(slot)) {
|
||||
TEST_IGNORE_MESSAGE("Can't run SPI mode test on a slot with eMMC");
|
||||
}
|
||||
sdmmc_test_board_get_config_sdspi(slot, &config, &bus_config, &dev_config);
|
||||
int board_max_freq_khz = sdmmc_test_board_get_slot_info(slot)->max_freq_khz;
|
||||
if (board_max_freq_khz > 0 && board_max_freq_khz < freq_khz) {
|
||||
TEST_IGNORE_MESSAGE("Board doesn't support required max_freq_khz");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void sdmmc_test_spi_begin(int slot, int freq_khz, sdmmc_card_t *out_card)
|
||||
{
|
||||
sdmmc_host_t config = SDSPI_HOST_DEFAULT();
|
||||
sdspi_device_config_t dev_config = SDSPI_DEVICE_CONFIG_DEFAULT();
|
||||
spi_bus_config_t bus_config = {};
|
||||
sdspi_dev_handle_t handle;
|
||||
|
||||
/* Similar to the checks in sdmmc_test_spi_skip_if_board_incompatible, but
|
||||
* we fail the test if we somehow got to this point with an incompatible board.
|
||||
*/
|
||||
if (!sdmmc_test_board_has_slot(slot)) {
|
||||
TEST_FAIL_MESSAGE("Board doesn't have the required slot");
|
||||
}
|
||||
if (sdmmc_test_board_slot_is_emmc(slot)) {
|
||||
TEST_FAIL_MESSAGE("Can't run SPI mode test on a slot with eMMC");
|
||||
}
|
||||
sdmmc_test_board_get_config_sdspi(slot, &config, &bus_config, &dev_config);
|
||||
int board_max_freq_khz = sdmmc_test_board_get_slot_info(slot)->max_freq_khz;
|
||||
if (board_max_freq_khz > 0 && board_max_freq_khz < freq_khz) {
|
||||
TEST_FAIL_MESSAGE("Board doesn't support required max_freq_khz");
|
||||
}
|
||||
|
||||
config.max_freq_khz = freq_khz;
|
||||
|
||||
sdmmc_test_board_card_power_set(true);
|
||||
TEST_ESP_OK(spi_bus_initialize(dev_config.host_id, &bus_config, SPI_DMA_CH_AUTO));
|
||||
TEST_ESP_OK(sdspi_host_init());
|
||||
TEST_ESP_OK(sdspi_host_init_device(&dev_config, &handle));
|
||||
TEST_ESP_OK(sdmmc_card_init(&config, out_card));
|
||||
}
|
||||
|
||||
void sdmmc_test_spi_end(int slot, sdmmc_card_t *card)
|
||||
{
|
||||
TEST_ESP_OK(sdspi_host_deinit());
|
||||
TEST_ESP_OK(spi_bus_free(SDSPI_DEFAULT_HOST));
|
||||
|
||||
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->d3_cs,
|
||||
};
|
||||
const int num_pins = sizeof(pins) / sizeof(pins[0]);
|
||||
// Silence logging in gpio_reset_pin, which logs at INFO level
|
||||
esp_log_level_t old_level = esp_log_level_get("gpio");
|
||||
esp_log_level_set("gpio", ESP_LOG_WARN);
|
||||
for (int i = 0; i < num_pins; i++) {
|
||||
if (pins[i] >= 0) {
|
||||
gpio_reset_pin(pins[i]);
|
||||
gpio_pullup_dis(pins[i]);
|
||||
}
|
||||
}
|
||||
esp_log_level_set("gpio", old_level);
|
||||
|
||||
sdmmc_test_board_card_power_set(false);
|
||||
}
|
@ -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
|
@ -0,0 +1,61 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#include <stddef.h>
|
||||
#include "unity.h"
|
||||
#include "sdmmc_cmd.h"
|
||||
#include "driver/sdspi_host.h"
|
||||
#include "sdmmc_cmd.h"
|
||||
#include "sdmmc_test_board.h"
|
||||
#include "sdmmc_test_begin_end_spi.h"
|
||||
#include "sdmmc_test_cd_wp_common.h"
|
||||
|
||||
TEST_CASE("CD input works in SPI mode", "[sdspi]")
|
||||
{
|
||||
const int slot = 1;
|
||||
sdmmc_host_t config = SDSPI_HOST_DEFAULT();
|
||||
spi_bus_config_t bus_config = {};
|
||||
sdspi_dev_handle_t handle;
|
||||
sdspi_device_config_t dev_config = SDSPI_DEVICE_CONFIG_DEFAULT();
|
||||
sdmmc_test_board_get_config_sdspi(slot, &config, &bus_config, &dev_config);
|
||||
const int test_gpio = sdmmc_test_board_get_slot_info(slot)->unused_pin;
|
||||
dev_config.gpio_cd = test_gpio;
|
||||
sdmmc_test_board_card_power_set(true);
|
||||
TEST_ESP_OK(spi_bus_initialize(dev_config.host_id, &bus_config, SPI_DMA_CH_AUTO));
|
||||
TEST_ESP_OK(sdspi_host_init());
|
||||
TEST_ESP_OK(sdspi_host_init_device(&dev_config, &handle));
|
||||
|
||||
config.slot = handle;
|
||||
|
||||
sdmmc_test_cd_input(test_gpio, &config);
|
||||
|
||||
TEST_ESP_OK(sdspi_host_deinit());
|
||||
TEST_ESP_OK(spi_bus_free(SDSPI_DEFAULT_HOST));
|
||||
sdmmc_test_board_card_power_set(false);
|
||||
}
|
||||
|
||||
TEST_CASE("WP input works in SPI mode", "[sdspi]")
|
||||
{
|
||||
const int slot = 1;
|
||||
sdmmc_host_t config = SDSPI_HOST_DEFAULT();
|
||||
spi_bus_config_t bus_config = {};
|
||||
sdspi_dev_handle_t handle;
|
||||
sdspi_device_config_t dev_config = SDSPI_DEVICE_CONFIG_DEFAULT();
|
||||
sdmmc_test_board_get_config_sdspi(slot, &config, &bus_config, &dev_config);
|
||||
const int test_gpio = sdmmc_test_board_get_slot_info(slot)->unused_pin;
|
||||
dev_config.gpio_wp = test_gpio;
|
||||
sdmmc_test_board_card_power_set(true);
|
||||
TEST_ESP_OK(spi_bus_initialize(dev_config.host_id, &bus_config, SPI_DMA_CH_AUTO));
|
||||
TEST_ESP_OK(sdspi_host_init());
|
||||
TEST_ESP_OK(sdspi_host_init_device(&dev_config, &handle));
|
||||
|
||||
config.slot = handle;
|
||||
|
||||
sdmmc_test_wp_input(test_gpio, &config);
|
||||
|
||||
TEST_ESP_OK(sdspi_host_deinit());
|
||||
TEST_ESP_OK(spi_bus_free(SDSPI_DEFAULT_HOST));
|
||||
sdmmc_test_board_card_power_set(false);
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#include <stddef.h>
|
||||
#include "unity.h"
|
||||
#include "sdmmc_cmd.h"
|
||||
#include "sdmmc_test_begin_end_spi.h"
|
||||
|
||||
static void do_one_sdspi_probe(int slot, int freq_khz)
|
||||
{
|
||||
sdmmc_card_t card;
|
||||
sdmmc_test_spi_skip_if_board_incompatible(slot, freq_khz);
|
||||
sdmmc_test_spi_begin(slot, freq_khz, &card);
|
||||
sdmmc_card_print_info(stdout, &card);
|
||||
uint8_t* buffer = heap_caps_calloc(512, 1, MALLOC_CAP_DMA);
|
||||
TEST_ESP_OK(sdmmc_read_sectors(&card, buffer, 0, 1));
|
||||
sdmmc_test_spi_end(slot, &card);
|
||||
}
|
||||
|
||||
TEST_CASE("sdspi probe, slot 0", "[sdspi]")
|
||||
{
|
||||
do_one_sdspi_probe(SLOT_0, SDMMC_FREQ_PROBING);
|
||||
do_one_sdspi_probe(SLOT_0, SDMMC_FREQ_DEFAULT);
|
||||
}
|
||||
|
||||
TEST_CASE("sdspi probe, slot 0, HS", "[sdspi]")
|
||||
{
|
||||
do_one_sdspi_probe(SLOT_0, SDMMC_FREQ_HIGHSPEED);
|
||||
}
|
||||
|
||||
TEST_CASE("sdspi probe, slot 1", "[slot1][manual][ignore]")
|
||||
{
|
||||
do_one_sdspi_probe(SLOT_1, SDMMC_FREQ_PROBING);
|
||||
do_one_sdspi_probe(SLOT_1, SDMMC_FREQ_DEFAULT);
|
||||
}
|
||||
|
||||
TEST_CASE("sdspi probe, slot 1, HS", "[slot1][manual][ignore]")
|
||||
{
|
||||
do_one_sdspi_probe(SLOT_1, SDMMC_FREQ_HIGHSPEED);
|
||||
}
|
@ -0,0 +1,76 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#include <stddef.h>
|
||||
#include "unity.h"
|
||||
#include "sdmmc_cmd.h"
|
||||
#include "sdmmc_test_begin_end_spi.h"
|
||||
#include "sdmmc_test_rw_common.h"
|
||||
|
||||
/* ========== Read/write performance tests, SPI ========== */
|
||||
|
||||
static void do_one_sdspi_perf_test(int slot, int freq_khz)
|
||||
{
|
||||
sdmmc_card_t card;
|
||||
sdmmc_test_spi_skip_if_board_incompatible(slot, freq_khz);
|
||||
sdmmc_test_spi_begin(slot, freq_khz, &card);
|
||||
sdmmc_card_print_info(stdout, &card);
|
||||
sdmmc_test_rw_performance(&card, NULL);
|
||||
sdmmc_test_spi_end(slot, &card);
|
||||
}
|
||||
|
||||
TEST_CASE("sdspi read/write performance, slot 0", "[sdspi]")
|
||||
{
|
||||
do_one_sdspi_perf_test(SLOT_0, SDMMC_FREQ_HIGHSPEED);
|
||||
}
|
||||
|
||||
TEST_CASE("sdspi read/write performance, slot 1", "[slot1][manual][ignore]")
|
||||
{
|
||||
do_one_sdspi_perf_test(SLOT_1, SDMMC_FREQ_HIGHSPEED);
|
||||
}
|
||||
|
||||
/* ========== Read/write tests with offset, SPI ========== */
|
||||
|
||||
static void do_one_sdspi_rw_test_with_offset(int slot, int freq_khz)
|
||||
{
|
||||
sdmmc_card_t card;
|
||||
sdmmc_test_spi_skip_if_board_incompatible(slot, freq_khz);
|
||||
sdmmc_test_spi_begin(slot, freq_khz, &card);
|
||||
sdmmc_card_print_info(stdout, &card);
|
||||
sdmmc_test_rw_with_offset(&card);
|
||||
sdmmc_test_spi_end(slot, &card);
|
||||
}
|
||||
|
||||
TEST_CASE("sdspi read/write performance with offset, slot 0", "[sdspi]")
|
||||
{
|
||||
do_one_sdspi_rw_test_with_offset(SLOT_0, SDMMC_FREQ_HIGHSPEED);
|
||||
}
|
||||
|
||||
TEST_CASE("sdspi read/write performance with offset, slot 1", "[slot1][manual][ignore]")
|
||||
{
|
||||
do_one_sdspi_rw_test_with_offset(SLOT_1, SDMMC_FREQ_HIGHSPEED);
|
||||
}
|
||||
|
||||
/* ========== Read/write tests with unaligned source/destination buffer, SPI ========== */
|
||||
|
||||
static void do_one_sdspi_rw_test_unaligned_buffer(int slot, int freq_khz)
|
||||
{
|
||||
sdmmc_card_t card;
|
||||
sdmmc_test_spi_skip_if_board_incompatible(slot, freq_khz);
|
||||
sdmmc_test_spi_begin(slot, freq_khz, &card);
|
||||
sdmmc_card_print_info(stdout, &card);
|
||||
sdmmc_test_rw_unaligned_buffer(&card);
|
||||
sdmmc_test_spi_end(slot, &card);
|
||||
}
|
||||
|
||||
TEST_CASE("sdspi read/write using unaligned buffer, slot 0", "[sdspi]")
|
||||
{
|
||||
do_one_sdspi_rw_test_unaligned_buffer(SLOT_0, SDMMC_FREQ_DEFAULT);
|
||||
}
|
||||
|
||||
TEST_CASE("sdspi read/write using unaligned buffer, slot 1", "[sdspi]")
|
||||
{
|
||||
do_one_sdspi_rw_test_unaligned_buffer(SLOT_1, SDMMC_FREQ_DEFAULT);
|
||||
}
|
@ -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
|
@ -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,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()
|
@ -0,0 +1,28 @@
|
||||
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_boards 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 sdmmc_tests_tools
|
||||
# various console comamnds
|
||||
cmd_unity cmd_system cmd_sdmmc
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user