mirror of
https://github.com/espressif/esp-idf.git
synced 2025-07-30 10:47:19 +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:
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
@ -8,6 +8,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
#include "esp_timer.h"
|
||||||
#include "test_utils.h"
|
#include "test_utils.h"
|
||||||
#include "sdkconfig.h"
|
#include "sdkconfig.h"
|
||||||
#include "soc/soc_caps.h"
|
#include "soc/soc_caps.h"
|
||||||
@ -154,3 +155,43 @@ void sdmmc_test_rw_with_offset(sdmmc_card_t* card)
|
|||||||
do_single_rw_perf_test(card, card->csd.capacity/2, 8, 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, 128, 1, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
xSemaphoreGive(args.stop);
|
||||||
|
xSemaphoreTake(args.done, portMAX_DELAY);
|
||||||
|
vSemaphoreDelete(args.stop);
|
||||||
|
vSemaphoreDelete(args.done);
|
||||||
|
}
|
||||||
|
@ -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
|
* 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);
|
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
|
#ifdef __cplusplus
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
@ -101,3 +101,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);
|
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);
|
||||||
|
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