pytest_sdio_test.py 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. # SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
  2. # SPDX-License-Identifier: Apache-2.0
  3. import os
  4. from typing import Tuple
  5. import pytest
  6. from pytest_embedded_idf import IdfDut
  7. @pytest.mark.esp32
  8. @pytest.mark.sdio_master_slave
  9. @pytest.mark.parametrize(
  10. 'count, app_path',
  11. [
  12. (2, f'{os.path.join(os.path.dirname(__file__), "host")}|{os.path.join(os.path.dirname(__file__), "slave")}'),
  13. ],
  14. indirect=True,
  15. )
  16. def test_example_sdio_communication(dut: Tuple[IdfDut, IdfDut]) -> None:
  17. """
  18. Configurations
  19. host = host -> slave = slave
  20. should be in the same group of devices, otherwise may meet download issue
  21. group1: (Wroom-32 Series or PICO-D4 modules: PICO-Kit, DevKitC, WroverKit v2 or earlier)
  22. group2: (Wrover module: WroverKit v3)
  23. GPIO14->GPIO14
  24. GPIO15->GPIO15
  25. GPIO2->GPIO2
  26. GPIO4->GPIO4
  27. GND->GND
  28. VDD3.3 -> GPIO13 if slave uses WroverKit v3
  29. or use sdio test board, which has two wrover modules connect to a same FT3232
  30. Assume that first dut is host and second is slave
  31. """
  32. host = dut[0]
  33. slave = dut[1]
  34. host.pexpect_proc.timeout = 5
  35. slave.pexpect_proc.timeout = 5
  36. host.expect_exact('host ready, start initializing slave...')
  37. host.expect_exact('0a 0d 10 13 16 19 1c 1f 22 25 28 2b 2e 31 34 37')
  38. host.expect_exact('3a 3d 40 43 46 49 4c 4f 52 55 58 5b 5e 61 64 67')
  39. host.expect_exact('6a 6d 70 73 76 79 7c 7f 82 85 88 8b 8e 91 94 97')
  40. host.expect_exact('9a 9d a0 a3 a6 a9 ac af b2 b5 b8 bb')
  41. slave.expect_exact('================ JOB_WRITE_REG ================')
  42. slave.expect_exact('0a 0d 10 13 16 19 1c 1f 22 25 28 2b 2e 31 34 37')
  43. slave.expect_exact('3a 3d 40 43 46 49 4c 4f 52 55 58 5b 5e 61 64 67')
  44. slave.expect_exact('6a 6d 70 73 76 79 7c 7f 82 85 88 8b 8e 91 94 97')
  45. slave.expect_exact('9a 9d a0 a3 a6 a9 ac af b2 b5 b8 bb')
  46. host.expect_exact('host int: 0')
  47. host.expect_exact('host int: 1')
  48. host.expect_exact('host int: 2')
  49. host.expect_exact('host int: 3')
  50. host.expect_exact('host int: 4')
  51. host.expect_exact('host int: 5')
  52. host.expect_exact('host int: 6')
  53. host.expect_exact('host int: 7')
  54. host.expect_exact('host int: 0')
  55. host.expect_exact('host int: 1')
  56. host.expect_exact('host int: 2')
  57. host.expect_exact('host int: 3')
  58. host.expect_exact('host int: 4')
  59. host.expect_exact('host int: 5')
  60. host.expect_exact('host int: 6')
  61. host.expect_exact('host int: 7')
  62. slave.expect_exact('================ JOB_SEND_INT ================')
  63. slave.expect_exact('================ JOB_SEND_INT ================')
  64. host.expect_exact('send packet length: 6')
  65. host.expect_exact('send packet length: 12')
  66. host.expect_exact('send packet length: 1024')
  67. host.expect_exact('send packet length: 512')
  68. host.expect_exact('send packet length: 3')
  69. slave.expect_exact('Packet received, len: 6')
  70. slave.expect_exact('Buffer 0, len: 6')
  71. slave.expect_exact('Packet received, len: 12')
  72. slave.expect_exact('Buffer 0, len: 12')
  73. # 1024
  74. slave.expect_exact('Packet received, len: 1024')
  75. for i in range(8):
  76. slave.expect_exact(f'Buffer {i}, len: 128')
  77. # 512
  78. slave.expect_exact('Packet received, len: 512')
  79. for i in range(4):
  80. slave.expect_exact(f'Buffer {i}, len: 128')
  81. # 3
  82. slave.expect_exact('Packet received, len: 3')
  83. slave.expect_exact('Buffer 0, len: 3')
  84. # same as slave received
  85. host.expect_exact('receive data, size: 6')
  86. host.expect_exact('receive data, size: 12')
  87. for _ in range(8):
  88. host.expect_exact('receive data, size: 128')
  89. for _ in range(4):
  90. host.expect_exact('receive data, size: 128')
  91. host.expect_exact('receive data, size: 3')
  92. # the last valid line of one round
  93. host.expect_exact('aa af b4')
  94. # the first 2 lines of the second round
  95. host.expect_exact('46 4b 50 55 5a 5f')
  96. host.expect_exact('6e 73 78 7d 82 87 8c 91 96 9b a0 a5')