Skip to content

Commit 6e2d52c

Browse files
committed
test(sdio): dual board test sd host p4 + sdio slave c5
1 parent 69164ed commit 6e2d52c

File tree

13 files changed

+157
-40
lines changed

13 files changed

+157
-40
lines changed
Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
1-
set(srcs "essl.c")
2-
3-
if(CONFIG_SOC_GPSPI_SUPPORTED)
4-
list(APPEND srcs "essl_spi.c")
5-
endif()
6-
7-
if(CONFIG_SOC_SDIO_SLAVE_SUPPORTED)
8-
list(APPEND srcs "essl_sdio.c" "essl_sdio_defs.c")
9-
endif()
10-
11-
idf_component_register(
12-
SRCS "${srcs}"
13-
INCLUDE_DIRS "include"
14-
PRIV_INCLUDE_DIRS "." "include/esp_serial_slave_link"
15-
REQUIRES sdmmc driver
1+
idf_component_register(SRCS "essl.c"
2+
"essl_sdio.c"
3+
"essl_spi.c"
4+
"essl_sdio_defs.c"
5+
INCLUDE_DIRS "include"
6+
REQUIRES "sdmmc"
7+
"driver"
8+
PRIV_INCLUDE_DIRS "."
9+
"include/esp_serial_slave_link"
1610
)

components/driver/test_apps/components/test_driver_utils/include/test_dualboard_utils.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,10 @@ void test_prepare_buffer_pool(size_t pool_size, uint32_t flags);
4545
*
4646
* @param offset A random offset
4747
* @param size Buffer size
48+
* @param alignment Alignment
4849
* @param[out] out_buffer Out buffer
4950
*/
50-
void test_get_buffer_from_pool(uint32_t offset, size_t size, void **out_buffer);
51+
void test_get_buffer_from_pool(uint32_t offset, size_t size, size_t alignment, void **out_buffer);
5152

5253
/**
5354
* Destroy the pool

components/driver/test_apps/components/test_driver_utils/test_dualboard_utils.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ void test_prepare_buffer_pool(size_t pool_size, uint32_t flags)
4343
test_fill_random_to_buffer(199, s_pool, pool_size);
4444
}
4545

46-
void test_get_buffer_from_pool(uint32_t offset, size_t size, void **out_buffer)
46+
void test_get_buffer_from_pool(uint32_t offset, size_t size, size_t alignment, void **out_buffer)
4747
{
4848
//to make sure the out_buffer is within the pool
49-
offset = ((offset % (s_pool_size - size)) + 3) & ~3;
49+
offset = ((offset % (s_pool_size - size)) + (alignment - 1)) & ~(alignment - 1);
5050
// TEST_ASSERT(offset + size < (uint32_t)s_pool + s_pool_size)
5151

5252
*out_buffer = (void *)(s_pool + offset);

components/esp_driver_sdio/test_apps/.build-test-rules.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
components/esp_driver_sdio/test_apps/sdio/sdio_common_tests/host_sdmmc:
22
enable:
3-
- if: IDF_TARGET == "esp32"
4-
reason: always use ESP32 SDMMC as host
3+
- if: IDF_TARGET in ["esp32", "esp32p4"]
4+
reason: runners use ESP32 / ESP32P4 SDMMC as host
55
depends_components:
66
- sdmmc
77
- esp_driver_sdmmc

components/esp_driver_sdio/test_apps/sdio/sdio_common_tests/host_sdmmc/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
| Supported Targets | ESP32 |
2-
| ----------------- | ----- |
1+
| Supported Targets | ESP32 | ESP32-P4 |
2+
| ----------------- | ----- | -------- |
33

44
# SDIO Cross Chips Test Apps: SDMMC Host App
55

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
menu "SDIO Slave Test Host Configuration"
2+
choice TEST_SDIO_SLAVE_TARGET
3+
prompt "SDIO Slave Chip"
4+
default TEST_SDIO_SLAVE_TARGET_ESP32
5+
help
6+
SDIO Slave chip target
7+
8+
config TEST_SDIO_SLAVE_TARGET_ESP32
9+
bool "SDIO Slave ESP32"
10+
config TEST_SDIO_SLAVE_TARGET_ESP32C6
11+
bool "SDIO Slave ESP32C6"
12+
config TEST_SDIO_SLAVE_TARGET_ESP32C5
13+
bool "SDIO Slave ESP32C5"
14+
endchoice
15+
endmenu

components/esp_driver_sdio/test_apps/sdio/sdio_common_tests/host_sdmmc/main/test_sdio_sdhost.c

Lines changed: 46 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -32,6 +32,15 @@ static const char *TAG = "test_sdio_sdhost";
3232
#define TEST_INT_MASK_ALL 0xff
3333
#define TEST_REG_ADDR_MAX 60
3434
#define TEST_TIMEOUT_MAX UINT32_MAX
35+
#define TEST_WIDTH 4
36+
#if CONFIG_TEST_SDIO_SLAVE_TARGET_ESP32C5
37+
#define TEST_PIN_CLK 33
38+
#define TEST_PIN_CMD 4
39+
#define TEST_PIN_D0 32
40+
#define TEST_PIN_D1 23
41+
#define TEST_PIN_D2 53
42+
#define TEST_PIN_D3 5
43+
#endif
3544

3645
typedef struct {
3746
uint32_t host_flags;
@@ -48,6 +57,11 @@ static void s_master_init(test_sdio_param_t *host_param, essl_handle_t *out_hand
4857
{
4958
sdmmc_host_t host_config = (sdmmc_host_t)SDMMC_HOST_DEFAULT();
5059
host_config.flags = host_param->host_flags;
60+
#if CONFIG_TEST_SDIO_SLAVE_TARGET_ESP32C5
61+
//On P4-SDMMC + C5 SDIO test runner environment, hardware delay needs to be considered
62+
host_config.input_delay_phase = SDMMC_DELAY_PHASE_2;
63+
#endif
64+
5165
if (host_config.flags & SDMMC_HOST_FLAG_4BIT) {
5266
ESP_LOGI(TAG, "Probe using SD 4-bit...");
5367
} else if (host_config.flags & SDMMC_HOST_FLAG_1BIT) {
@@ -59,6 +73,16 @@ static void s_master_init(test_sdio_param_t *host_param, essl_handle_t *out_hand
5973
//init sdmmc host
6074
TEST_ESP_OK(sdmmc_host_init());
6175
sdmmc_slot_config_t slot_config = SDMMC_SLOT_CONFIG_DEFAULT();
76+
#if CONFIG_TEST_SDIO_SLAVE_TARGET_ESP32C5
77+
slot_config.width = TEST_WIDTH;
78+
slot_config.clk = TEST_PIN_CLK;
79+
slot_config.cmd = TEST_PIN_CMD;
80+
slot_config.d0 = TEST_PIN_D0;
81+
slot_config.d1 = TEST_PIN_D1;
82+
slot_config.d2 = TEST_PIN_D2;
83+
slot_config.d3 = TEST_PIN_D3;
84+
#endif
85+
6286
TEST_ESP_OK(sdmmc_host_init_slot(SDMMC_HOST_SLOT_1, &slot_config));
6387

6488
//host init slave
@@ -127,7 +151,6 @@ TEST_CASE("SDIO_SDMMC: test interrupt", "[sdio]")
127151

128152
//tests all 8 interrupts of the slave, in which int 7 is used to terminate the test on the slave.
129153
for (int i = 0; i < 8; i ++) {
130-
esp_rom_printf("to essl_send_slave_intr\n");
131154
TEST_ESP_OK(essl_send_slave_intr(handle, BIT(i), TEST_TIMEOUT_MAX));
132155
//the slave should return interrupt with the same bit in 10 ms
133156
TEST_ESP_OK(essl_wait_int(handle, 10));
@@ -223,8 +246,13 @@ TEST_CASE("SDIO_SDMMC: test reset", "[sdio]")
223246
/*---------------------------------------------------------------
224247
SDMMC_SDIO: test fixed addr
225248
---------------------------------------------------------------*/
226-
#include "soc/soc.h"
249+
#if CONFIG_TEST_SDIO_SLAVE_TARGET_ESP32C5
250+
#define HOST_SLCHOST_CONF_W0_REG (0x60018000 + 0x6C)
251+
#elif DR_REG_SLCHOST_BASE
227252
#define HOST_SLCHOST_CONF_W0_REG (DR_REG_SLCHOST_BASE + 0x6C)
253+
#else
254+
#define HOST_SLCHOST_CONF_W0_REG 0
255+
#endif
228256

229257
TEST_CASE("SDIO_SDMMC: test fixed addr", "[sdio]")
230258
{
@@ -318,7 +346,11 @@ static void test_from_host(bool check_data)
318346
for (int j = 0; j < TEST_TRANS_NUMS; j++) {
319347
ESP_LOGD(TAG, "j: %d", j);
320348

321-
test_get_buffer_from_pool(j, TEST_RX_BUFFER_SIZE, &tx_buf_ptr);
349+
size_t alignment = 4;
350+
#if CONFIG_IDF_TARGET_ESP32P4
351+
alignment = 64;
352+
#endif
353+
test_get_buffer_from_pool(j, TEST_RX_BUFFER_SIZE, alignment, &tx_buf_ptr);
322354
ESP_LOG_BUFFER_HEX_LEVEL(TAG, tx_buf_ptr, TEST_RX_BUFFER_SIZE, TEST_HEX_LOG_LEVEL);
323355
TEST_ESP_OK(essl_send_packet(handle, tx_buf_ptr, TEST_RX_BUFFER_SIZE, TEST_TIMEOUT_MAX));
324356
}
@@ -383,8 +415,12 @@ static void test_to_host(bool check_data)
383415

384416
if (check_data) {
385417
size_t compared_len = 0;
418+
size_t alignment = 4;
419+
#if CONFIG_IDF_TARGET_ESP32P4
420+
alignment = 64;
421+
#endif
386422
do {
387-
test_get_buffer_from_pool(offset, TEST_RX_BUFFER_SIZE, &tx_buf_ptr);
423+
test_get_buffer_from_pool(offset, TEST_RX_BUFFER_SIZE, alignment, &tx_buf_ptr);
388424
TEST_ASSERT_EQUAL_HEX8_ARRAY(tx_buf_ptr, &host_rx_buffer[compared_len], TEST_RX_BUFFER_SIZE);
389425
compared_len += TEST_RX_BUFFER_SIZE;
390426
offset += TEST_RX_BUFFER_SIZE;
@@ -418,6 +454,11 @@ TEST_CASE("SDIO_SDMMC: test to host", "[sdio]")
418454
test_to_host(true);
419455
}
420456

457+
TEST_CASE("SDIO_SDMMC: test to host (Performance)", "[sdio_speed]")
458+
{
459+
test_to_host(false);
460+
}
461+
421462
TEST_CASE("SDIO_SDMMC: test sleep retention", "[sdio_retention]")
422463
{
423464
essl_handle_t handle = NULL;
@@ -431,8 +472,3 @@ TEST_CASE("SDIO_SDMMC: test sleep retention", "[sdio_retention]")
431472
s_send_finish_test(handle);
432473
s_master_deinit();
433474
}
434-
435-
TEST_CASE("SDIO_SDMMC: test to host (Performance)", "[sdio_speed]")
436-
{
437-
test_to_host(false);
438-
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CONFIG_TEST_SDIO_SLAVE_TARGET_ESP32C5=y

components/esp_driver_sdio/test_apps/sdio/sdio_common_tests/pytest_sdio.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,16 @@ def parameter_expand(existing_parameters: List[List[str]], value_list: List[str]
2929
]
3030
]
3131

32+
esp32p4_c5_param = [
33+
[
34+
f'{os.path.join(os.path.dirname(__file__), "host_sdmmc")}|{os.path.join(os.path.dirname(__file__), "sdio")}',
35+
'esp32p4|esp32c5',
36+
]
37+
]
38+
3239
esp32_param_default = [pytest.param(*param) for param in parameter_expand(esp32_32_param, ['default|default'])]
3340
c6_param_default = [pytest.param(*param) for param in parameter_expand(esp32_c6_param, ['default|default'])]
41+
c5_param_default = [pytest.param(*param) for param in parameter_expand(esp32p4_c5_param, ['esp32p4_esp32c5|default'])]
3442

3543
c6_param_retention = [pytest.param(*param) for param in parameter_expand(esp32_c6_param, ['default|sleep_retention'])]
3644

@@ -74,6 +82,19 @@ def test_sdio_esp32_esp32(dut: Tuple[IdfDut, IdfDut]) -> None:
7482
test_sdio_flow(dut)
7583

7684

85+
@pytest.mark.sdio_multidev_p4_c5
86+
@pytest.mark.parametrize(
87+
'count',
88+
[
89+
2,
90+
],
91+
indirect=True,
92+
)
93+
@pytest.mark.parametrize('app_path, target, config', c5_param_default, indirect=True)
94+
def test_sdio_esp32p4_esp32c5(dut: Tuple[IdfDut, IdfDut]) -> None:
95+
test_sdio_flow(dut)
96+
97+
7798
# From host speed tests
7899
def test_sdio_speed_frhost_flow(dut: Tuple[IdfDut, IdfDut], expected_4b_speed: int, expected_1b_speed: int) -> None:
79100
dut[1].expect('Press ENTER to see the list of tests')
@@ -120,6 +141,19 @@ def test_sdio_speed_frhost_esp32_esp32(dut: Tuple[IdfDut, IdfDut]) -> None:
120141
test_sdio_speed_frhost_flow(dut, 12200, 4000)
121142

122143

144+
@pytest.mark.sdio_multidev_p4_c5
145+
@pytest.mark.parametrize(
146+
'count',
147+
[
148+
2,
149+
],
150+
indirect=True,
151+
)
152+
@pytest.mark.parametrize('app_path, target, config', c5_param_default, indirect=True)
153+
def test_sdio_speed_frhost_esp32p4_esp32c5(dut: Tuple[IdfDut, IdfDut]) -> None:
154+
test_sdio_speed_frhost_flow(dut, 10000, 4000)
155+
156+
123157
# To host speed tests
124158
def test_sdio_speed_tohost_flow(dut: Tuple[IdfDut, IdfDut], expected_4b_speed: int, expected_1b_speed: int) -> None:
125159
dut[1].expect('Press ENTER to see the list of tests')
@@ -166,6 +200,19 @@ def test_sdio_speed_tohost_esp32_esp32(dut: Tuple[IdfDut, IdfDut]) -> None:
166200
test_sdio_speed_tohost_flow(dut, 12200, 4000)
167201

168202

203+
@pytest.mark.sdio_multidev_p4_c5
204+
@pytest.mark.parametrize(
205+
'count',
206+
[
207+
2,
208+
],
209+
indirect=True,
210+
)
211+
@pytest.mark.parametrize('app_path, target, config', c5_param_default, indirect=True)
212+
def test_sdio_speed_tohost_esp32p4_esp32c5(dut: Tuple[IdfDut, IdfDut]) -> None:
213+
test_sdio_speed_tohost_flow(dut, 9000, 4000)
214+
215+
169216
# Retention tests
170217
def test_sdio_retention(dut: Tuple[IdfDut, IdfDut]) -> None:
171218
dut[1].expect('Press ENTER to see the list of tests')
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
menu "SDIO Slave Test Slave Configuration"
2+
choice TEST_SDIO_HOST_TARGET
3+
prompt "SDIO Host Chip"
4+
default TEST_SDIO_HOST_TARGET_ESP32
5+
help
6+
SDIO Host chip target
7+
8+
config TEST_SDIO_HOST_TARGET_ESP32
9+
bool "SDIO Host ESP32"
10+
config TEST_SDIO_HOST_TARGET_ESP32P4
11+
bool "SDIO Host ESP32P4"
12+
endchoice
13+
endmenu

0 commit comments

Comments
 (0)