mirror of
https://github.com/espressif/esp-idf.git
synced 2025-07-29 18:27:20 +02:00
test(sdmmc): add test for high-prio task busy while writing
Related to https://github.com/espressif/esp-idf/issues/13934
This commit is contained in:
@ -5,5 +5,5 @@ set(public_include "include")
|
||||
idf_component_register(
|
||||
SRCS ${srcs}
|
||||
INCLUDE_DIRS ${public_include}
|
||||
PRIV_REQUIRES sdmmc unity test_utils
|
||||
PRIV_REQUIRES sdmmc unity test_utils esp_timer
|
||||
)
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@ -50,6 +50,12 @@ void sdmmc_test_rw_unaligned_buffer(sdmmc_card_t* card);
|
||||
*/
|
||||
void sdmmc_test_rw_with_offset(sdmmc_card_t* card);
|
||||
|
||||
/**
|
||||
* @brief Test read/write with higher priority tasks running concurrently
|
||||
* @param card Pointer to the card object, must be initialized before calling this function.
|
||||
*/
|
||||
void sdmmc_test_rw_highprio_task(sdmmc_card_t* card);
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include <sys/time.h>
|
||||
#include "esp_dma_utils.h"
|
||||
#include "esp_heap_caps.h"
|
||||
#include "esp_timer.h"
|
||||
#include "test_utils.h"
|
||||
#include "sdkconfig.h"
|
||||
#include "soc/soc_caps.h"
|
||||
@ -185,3 +186,43 @@ void sdmmc_test_rw_with_offset(sdmmc_card_t* card)
|
||||
do_single_rw_perf_test(card, card->csd.capacity / 2, 8, 1, NULL, 0);
|
||||
do_single_rw_perf_test(card, card->csd.capacity / 2, 128, 1, NULL, 0);
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
SemaphoreHandle_t stop;
|
||||
SemaphoreHandle_t done;
|
||||
uint32_t busy_time_us;
|
||||
} highprio_busy_task_args_t;
|
||||
|
||||
static void highprio_busy_task(void* varg)
|
||||
{
|
||||
highprio_busy_task_args_t* args = (highprio_busy_task_args_t*) varg;
|
||||
while (xSemaphoreTake(args->stop, 0) != pdTRUE) {
|
||||
vTaskDelay(1);
|
||||
int64_t start = esp_timer_get_time();
|
||||
while (esp_timer_get_time() - start < args->busy_time_us) {
|
||||
usleep(100);
|
||||
}
|
||||
}
|
||||
xSemaphoreGive(args->done);
|
||||
vTaskDelete(NULL);
|
||||
}
|
||||
|
||||
void sdmmc_test_rw_highprio_task(sdmmc_card_t* card)
|
||||
{
|
||||
highprio_busy_task_args_t args = {
|
||||
.stop = xSemaphoreCreateBinary(),
|
||||
.done = xSemaphoreCreateBinary(),
|
||||
.busy_time_us = 250000,
|
||||
};
|
||||
|
||||
TEST_ASSERT(xTaskCreate(highprio_busy_task, "highprio_busy_task", 4096, &args, 20, NULL));
|
||||
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
do_single_rw_perf_test(card, 0, 64, 0, NULL, 0);
|
||||
}
|
||||
|
||||
xSemaphoreGive(args.stop);
|
||||
xSemaphoreTake(args.done, portMAX_DELAY);
|
||||
vSemaphoreDelete(args.stop);
|
||||
vSemaphoreDelete(args.done);
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@ -106,3 +106,25 @@ TEST_CASE("sdmmc read/write using unaligned buffer, slot 1, 4-bit", "[sdmmc]")
|
||||
{
|
||||
do_one_sdmmc_rw_test_unaligned_buffer(SLOT_1, 4, SDMMC_FREQ_DEFAULT, 0);
|
||||
}
|
||||
|
||||
/* ========== Read/write tests with higher priority tasks running concurrently ========== */
|
||||
|
||||
static void do_one_sdmmc_rw_test_highprio_task(int slot, int width)
|
||||
{
|
||||
sdmmc_card_t card;
|
||||
sdmmc_test_sd_skip_if_board_incompatible(slot, width, SDMMC_FREQ_DEFAULT, NO_DDR, NO_EMMC);
|
||||
sdmmc_test_sd_begin(slot, width, SDMMC_FREQ_DEFAULT, NO_DDR, &card);
|
||||
sdmmc_card_print_info(stdout, &card);
|
||||
sdmmc_test_rw_highprio_task(&card);
|
||||
sdmmc_test_sd_end(&card);
|
||||
}
|
||||
|
||||
TEST_CASE("sdmmc read/write with concurrent high-prio task, slot 0, 4-bit", "[sdmmc]")
|
||||
{
|
||||
do_one_sdmmc_rw_test_highprio_task(0, 4);
|
||||
}
|
||||
|
||||
TEST_CASE("sdmmc read/write with concurrent high-prio task, slot 1, 4-bit", "[sdmmc]")
|
||||
{
|
||||
do_one_sdmmc_rw_test_highprio_task(1, 4);
|
||||
}
|
||||
|
Reference in New Issue
Block a user