sdio_test.py 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. # Copyright 2015-2017 Espressif Systems (Shanghai) PTE LTD
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http:#www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. """ example of writing test with TinyTestFW """
  15. import os
  16. import sys
  17. try:
  18. import TinyFW
  19. except ImportError:
  20. # if we want to run test case outside `tiny-test-fw` folder,
  21. # we need to insert tiny-test-fw path into sys path
  22. test_fw_path = os.getenv("TEST_FW_PATH")
  23. if test_fw_path and test_fw_path not in sys.path:
  24. sys.path.insert(0, test_fw_path)
  25. import TinyFW
  26. import IDF
  27. from IDF.IDFDUT import ESP32DUT
  28. @IDF.idf_example_test(env_tag="Example_SDIO", ignore=True)
  29. def test_example_sdio_communication(env, extra_data):
  30. """
  31. Configurations
  32. dut1 = host -> dut2 = slave
  33. should be in the same group of devices, otherwise may meet download issue
  34. group1: (Wroom-32 Series or PICO-D4 modules: PICO-Kit, DevKitC, WroverKit v2 or earlier)
  35. group2: (Wrover module: WroverKit v3)
  36. GPIO14->GPIO14
  37. GPIO15->GPIO15
  38. GPIO2->GPIO2
  39. GPIO4->GPIO4
  40. GND->GND
  41. VDD3.3 -> GPIO13 if dut2 uses WroverKit v3
  42. or use sdio test board, which has two wrover modules connect to a same FT3232
  43. Assume that first dut is host and second is slave
  44. """
  45. dut1 = env.get_dut("sdio_host", "examples/peripherals/sdio/host", dut_class=ESP32DUT)
  46. dut2 = env.get_dut("sdio_slave", "examples/peripherals/sdio/slave", dut_class=ESP32DUT)
  47. dut1.start_app()
  48. # wait until the master is ready to setup the slave
  49. dut1.expect("host ready, start initializing slave...")
  50. dut2.start_app()
  51. dut1.expect("0a 0d 10 13 16 19 1c 1f 22 25 28 2b 2e 31 34 37")
  52. dut1.expect("3a 3d 40 43 46 49 4c 4f 52 55 58 5b 00 00 00 00")
  53. dut1.expect("6a 6d 70 73 76 79 7c 7f 82 85 88 8b 8e 91 94 97")
  54. dut1.expect("9a 9d a0 a3 a6 a9 ac af b2 b5 b8 bb be c1 c4 c7")
  55. dut2.expect("================ JOB_WRITE_REG ================")
  56. dut2.expect("0a 0d 10 13 16 19 1c 1f 22 25 28 2b 2e 31 34 37")
  57. dut2.expect("3a 3d 40 43 46 49 4c 4f 52 55 58 5b 00 00 00 00")
  58. dut2.expect("6a 6d 70 73 76 79 7c 7f 82 85 88 8b 8e 91 94 97")
  59. dut2.expect("9a 9d a0 a3 a6 a9 ac af b2 b5 b8 bb be c1 c4 c7")
  60. dut1.expect("host int: 0")
  61. dut1.expect("host int: 1")
  62. dut1.expect("host int: 2")
  63. dut1.expect("host int: 3")
  64. dut1.expect("host int: 4")
  65. dut1.expect("host int: 5")
  66. dut1.expect("host int: 6")
  67. dut1.expect("host int: 7")
  68. dut1.expect("host int: 0")
  69. dut1.expect("host int: 1")
  70. dut1.expect("host int: 2")
  71. dut1.expect("host int: 3")
  72. dut1.expect("host int: 4")
  73. dut1.expect("host int: 5")
  74. dut1.expect("host int: 6")
  75. dut1.expect("host int: 7")
  76. dut2.expect("================ JOB_SEND_INT ================")
  77. dut2.expect("================ JOB_SEND_INT ================")
  78. dut1.expect("send packet length: 3")
  79. dut1.expect("send packet length: 6")
  80. dut1.expect("send packet length: 12")
  81. dut1.expect("send packet length: 128")
  82. dut1.expect("send packet length: 511")
  83. dut1.expect("send packet length: 512")
  84. dut2.expect("recv len: 3")
  85. dut2.expect("recv len: 6")
  86. dut2.expect("recv len: 12")
  87. dut2.expect("recv len: 128")
  88. # 511
  89. dut2.expect("recv len: 128")
  90. dut2.expect("recv len: 128")
  91. dut2.expect("recv len: 128")
  92. dut2.expect("recv len: 127")
  93. # 512
  94. dut2.expect("recv len: 128")
  95. dut2.expect("recv len: 128")
  96. dut2.expect("recv len: 128")
  97. dut2.expect("recv len: 128")
  98. dut1.expect("receive data, size: 3")
  99. dut1.expect("receive data, size: 6")
  100. dut1.expect("receive data, size: 12")
  101. dut1.expect("receive data, size: 128")
  102. dut1.expect("receive data, size: 128")
  103. dut1.expect("receive data, size: 128")
  104. dut1.expect("receive data, size: 128")
  105. dut1.expect("receive data, size: 127")
  106. dut1.expect("receive data, size: 128")
  107. dut1.expect("receive data, size: 128")
  108. dut1.expect("receive data, size: 128")
  109. dut1.expect("receive data, size: 128")
  110. # the last valid line of one round
  111. dut1.expect("ce d3 d8 dd e2 e7 ec f1 f6 fb 00 05 0a 0f 14 19")
  112. # the first 2 lines of the second round
  113. dut1.expect("46 4b 50")
  114. dut1.expect("5a 5f 64 69 6e 73")
  115. if __name__ == '__main__':
  116. TinyFW.set_default_config(env_config_file="EnvConfigTemplate.yml", dut=IDF.IDFDUT)
  117. test_example_sdio_communication()