diff --git a/.gitlab/ci/dependencies/dependencies.yml b/.gitlab/ci/dependencies/dependencies.yml index 9d5abc4947..8220351063 100644 --- a/.gitlab/ci/dependencies/dependencies.yml +++ b/.gitlab/ci/dependencies/dependencies.yml @@ -132,14 +132,15 @@ build:integration_test: - *target_test - *all_targets - - bt # example_test_005 - - wifi # example_test_002, example_test*wifi* - - ethernet # example_test*ethernet* - - sdio # component_ut_pytest_esp32_sdio + - wifi # pytest*wifi* + - ethernet # pytest*ethernet* + - sdio # pytest*sdio* - usb # USB Device & Host tests - - adc # component_ut_pytest_esp32x_adc + - adc # pytest*adc* - i154 - flash_multi - ecdsa + - ccs811 # pytest*ccs811* patterns: - "{0}-{1}-{2}" - "{0}-{2}" @@ -213,31 +214,10 @@ build:integration_test: ################################# # Triggered Only By Labels Jobs # ################################# -"labels:iperf_stress_test": # example_test - labels: - - iperf_stress_test - included_in: - - build:example_test - - build:example_test-esp32 - - build:target_test - -"labels:weekend_test": # custom test - labels: - - weekend_test - included_in: - - build:custom_test - - build:custom_test-esp32 - - build:target_test - "labels:nvs_coverage": # host_test labels: - nvs_coverage -"labels:fuzzer_test-weekend_test": # host test - labels: - - fuzzer_test - - weekend_test - "labels-protected:lan8720": # UT # FIXME: IDFCI-1176 temporary run this on master/release or with label labels: - lan8720 diff --git a/.gitlab/ci/rules.yml b/.gitlab/ci/rules.yml index 23b1d30b40..deb633f3f0 100644 --- a/.gitlab/ci/rules.yml +++ b/.gitlab/ci/rules.yml @@ -246,6 +246,7 @@ - "components/driver/include/driver/sdio*.h" - "components/driver/include/driver/sdmmc*.h" - "components/sdmmc/**/*" + - "examples/peripherals/sdio/**/*" # for jobs: component_ut_pytest_sdio related .patterns-component_ut-sdio: &patterns-component_ut-sdio @@ -259,6 +260,13 @@ - "components/driver/include/driver/sdmmc*.h" - "components/sdmmc/**/*" +.patterns-example_test-ccs811: &patterns-example_test-ccs811 + # components + - "examples/system/console/advanced/components/**/*" + - "components/driver/i2c/**/*" + # tests + - "examples/peripherals/i2c/i2c_tools/**/*" + # for jobs: UT_xx_SDSPI related .patterns-unit_test-sdio: &patterns-unit_test-sdio - "components/hal/sdio*.c" @@ -509,9 +517,6 @@ .if-label-example_test_esp32s3: &if-label-example_test_esp32s3 if: '$BOT_LABEL_EXAMPLE_TEST_ESP32S3 || $CI_MERGE_REQUEST_LABELS =~ /^(?:[^,\n\r]+,)*example_test_esp32s3(?:,[^,\n\r]+)*$/i' -.if-label-fuzzer_test: &if-label-fuzzer_test - if: '$BOT_LABEL_FUZZER_TEST || $CI_MERGE_REQUEST_LABELS =~ /^(?:[^,\n\r]+,)*fuzzer_test(?:,[^,\n\r]+)*$/i' - .if-label-host_test: &if-label-host_test if: '$BOT_LABEL_HOST_TEST || $CI_MERGE_REQUEST_LABELS =~ /^(?:[^,\n\r]+,)*host_test(?:,[^,\n\r]+)*$/i' @@ -524,9 +529,6 @@ .if-label-integration_test_wifi: &if-label-integration_test_wifi if: '$BOT_LABEL_INTEGRATION_TEST_WIFI || $CI_MERGE_REQUEST_LABELS =~ /^(?:[^,\n\r]+,)*integration_test_wifi(?:,[^,\n\r]+)*$/i' -.if-label-iperf_stress_test: &if-label-iperf_stress_test - if: '$BOT_LABEL_IPERF_STRESS_TEST || $CI_MERGE_REQUEST_LABELS =~ /^(?:[^,\n\r]+,)*iperf_stress_test(?:,[^,\n\r]+)*$/i' - .if-label-lan8720: &if-label-lan8720 if: '$BOT_LABEL_LAN8720 || $CI_MERGE_REQUEST_LABELS =~ /^(?:[^,\n\r]+,)*lan8720(?:,[^,\n\r]+)*$/i' @@ -569,9 +571,6 @@ .if-label-unit_test_esp32s3: &if-label-unit_test_esp32s3 if: '$BOT_LABEL_UNIT_TEST_ESP32S3 || $CI_MERGE_REQUEST_LABELS =~ /^(?:[^,\n\r]+,)*unit_test_esp32s3(?:,[^,\n\r]+)*$/i' -.if-label-weekend_test: &if-label-weekend_test - if: '$BOT_LABEL_WEEKEND_TEST || $CI_MERGE_REQUEST_LABELS =~ /^(?:[^,\n\r]+,)*weekend_test(?:,[^,\n\r]+)*$/i' - .if-label-windows: &if-label-windows if: '$BOT_LABEL_WINDOWS || $CI_MERGE_REQUEST_LABELS =~ /^(?:[^,\n\r]+,)*windows(?:,[^,\n\r]+)*$/i' @@ -889,7 +888,6 @@ - <<: *if-label-custom_test_esp32s2 - <<: *if-label-custom_test_esp32s3 - <<: *if-label-target_test - - <<: *if-label-weekend_test - <<: *if-dev-push changes: *patterns-build_components - <<: *if-dev-push @@ -916,7 +914,6 @@ - <<: *if-label-custom_test - <<: *if-label-custom_test_esp32 - <<: *if-label-target_test - - <<: *if-label-weekend_test - <<: *if-dev-push changes: *patterns-build_components - <<: *if-dev-push @@ -1121,7 +1118,6 @@ - <<: *if-label-example_test_esp32h2 - <<: *if-label-example_test_esp32s2 - <<: *if-label-example_test_esp32s3 - - <<: *if-label-iperf_stress_test - <<: *if-label-target_test - <<: *if-dev-push changes: *patterns-build-example_test @@ -1135,6 +1131,8 @@ changes: *patterns-example_test - <<: *if-dev-push changes: *patterns-example_test-bt + - <<: *if-dev-push + changes: *patterns-example_test-ccs811 - <<: *if-dev-push changes: *patterns-example_test-ethernet - <<: *if-dev-push @@ -1163,7 +1161,6 @@ - <<: *if-label-build - <<: *if-label-example_test - <<: *if-label-example_test_esp32 - - <<: *if-label-iperf_stress_test - <<: *if-label-target_test - <<: *if-dev-push changes: *patterns-build-example_test @@ -1177,6 +1174,8 @@ changes: *patterns-example_test - <<: *if-dev-push changes: *patterns-example_test-bt + - <<: *if-dev-push + changes: *patterns-example_test-ccs811 - <<: *if-dev-push changes: *patterns-example_test-ethernet - <<: *if-dev-push @@ -1217,6 +1216,8 @@ changes: *patterns-example_test - <<: *if-dev-push changes: *patterns-example_test-bt + - <<: *if-dev-push + changes: *patterns-example_test-ccs811 - <<: *if-dev-push changes: *patterns-example_test-ethernet - <<: *if-dev-push @@ -1258,6 +1259,8 @@ changes: *patterns-example_test - <<: *if-dev-push changes: *patterns-example_test-bt + - <<: *if-dev-push + changes: *patterns-example_test-ccs811 - <<: *if-dev-push changes: *patterns-example_test-ethernet - <<: *if-dev-push @@ -1298,6 +1301,8 @@ changes: *patterns-example_test - <<: *if-dev-push changes: *patterns-example_test-bt + - <<: *if-dev-push + changes: *patterns-example_test-ccs811 - <<: *if-dev-push changes: *patterns-example_test-ethernet - <<: *if-dev-push @@ -1338,6 +1343,8 @@ changes: *patterns-example_test - <<: *if-dev-push changes: *patterns-example_test-bt + - <<: *if-dev-push + changes: *patterns-example_test-ccs811 - <<: *if-dev-push changes: *patterns-example_test-ethernet - <<: *if-dev-push @@ -1378,6 +1385,8 @@ changes: *patterns-example_test - <<: *if-dev-push changes: *patterns-example_test-bt + - <<: *if-dev-push + changes: *patterns-example_test-ccs811 - <<: *if-dev-push changes: *patterns-example_test-ethernet - <<: *if-dev-push @@ -1418,6 +1427,8 @@ changes: *patterns-example_test - <<: *if-dev-push changes: *patterns-example_test-bt + - <<: *if-dev-push + changes: *patterns-example_test-ccs811 - <<: *if-dev-push changes: *patterns-example_test-ethernet - <<: *if-dev-push @@ -1505,7 +1516,6 @@ - <<: *if-label-integration_test - <<: *if-label-integration_test_ble - <<: *if-label-integration_test_wifi - - <<: *if-label-iperf_stress_test - <<: *if-label-lan8720 - <<: *if-label-target_test - <<: *if-label-unit_test @@ -1516,7 +1526,6 @@ - <<: *if-label-unit_test_esp32h2 - <<: *if-label-unit_test_esp32s2 - <<: *if-label-unit_test_esp32s3 - - <<: *if-label-weekend_test - <<: *if-dev-push changes: *patterns-build-example_test - <<: *if-dev-push @@ -1539,6 +1548,8 @@ changes: *patterns-example_test - <<: *if-dev-push changes: *patterns-example_test-bt + - <<: *if-dev-push + changes: *patterns-example_test-ccs811 - <<: *if-dev-push changes: *patterns-example_test-ethernet - <<: *if-dev-push @@ -2339,6 +2350,19 @@ - <<: *if-dev-push changes: *patterns-example_test-bt +.rules:test:example_test-esp32-ccs811: + rules: + - <<: *if-revert-branch + when: never + - <<: *if-protected + - <<: *if-label-build-only + when: never + - <<: *if-label-example_test + - <<: *if-label-example_test_esp32 + - <<: *if-label-target_test + - <<: *if-dev-push + changes: *patterns-example_test-ccs811 + .rules:test:example_test-esp32-ethernet: rules: - <<: *if-revert-branch diff --git a/.gitlab/ci/target-test.yml b/.gitlab/ci/target-test.yml index ce51b37120..43d92bab0c 100644 --- a/.gitlab/ci/target-test.yml +++ b/.gitlab/ci/target-test.yml @@ -97,6 +97,22 @@ pytest_examples_esp32_jtag: SETUP_TOOLS: "1" # need gdb openocd PYTEST_EXTRA_FLAGS: "--log-cli-level DEBUG" +pytest_examples_esp32_ccs811: + extends: + - .pytest_examples_dir_template + - .rules:test:example_test-esp32-ccs811 + needs: + - build_pytest_examples_esp32 + tags: [ esp32, ccs811 ] + +pytest_examples_esp32_sdio: + extends: + - .pytest_examples_dir_template + - .rules:test:example_test-esp32-sdio + needs: + - build_pytest_examples_esp32 + tags: [ esp32, sdio_master_slave ] + pytest_examples_esp32s2_generic: extends: - .pytest_examples_dir_template @@ -1106,12 +1122,6 @@ example_test_001C: - ESP32 - Example_GENERIC -.example_test_003: - extends: .example_test_esp32_template - tags: - - ESP32 - - Example_SDIO - example_test_005: extends: - .example_test_esp32_template @@ -1120,12 +1130,6 @@ example_test_005: - ESP32 - Example_WIFI_BT -example_test_007: - extends: .example_test_esp32_template - tags: - - ESP32 - - Example_I2C_CCS811_SENSOR - example_test_C3_GENERIC: extends: .example_test_esp32c3_template tags: diff --git a/conftest.py b/conftest.py index 967587f47b..1a9dabce2c 100644 --- a/conftest.py +++ b/conftest.py @@ -122,6 +122,7 @@ ENV_MARKERS = { 'psramv0': 'Runner with PSRAM version 0', 'esp32eco3': 'Runner with esp32 eco3 connected', 'ecdsa_efuse': 'Runner with test ECDSA private keys programmed in efuse', + 'ccs811': 'Runner with CCS811 connected', # multi-dut markers 'ieee802154': 'ieee802154 related tests should run on ieee802154 runners.', 'openthread_br': 'tests should be used for openthread border router.', diff --git a/examples/peripherals/.build-test-rules.yml b/examples/peripherals/.build-test-rules.yml index 0774976cec..39bfc110d1 100644 --- a/examples/peripherals/.build-test-rules.yml +++ b/examples/peripherals/.build-test-rules.yml @@ -165,10 +165,18 @@ examples/peripherals/sdio/host: - if: IDF_TARGET == "esp32" temporary: true reason: Only the SDSPI of ESP32 supports ESP SDIO slave for now + disable_test: + - if: IDF_TARGET != "esp32" + temporary: true + reason: lack of runners examples/peripherals/sdio/slave: disable: - if: SOC_SDIO_SLAVE_SUPPORTED != 1 + disable_test: + - if: IDF_TARGET != "esp32" + temporary: true + reason: lack of runners examples/peripherals/secure_element/atecc608_ecdsa: enable: diff --git a/examples/peripherals/i2c/i2c_tools/example_test.py b/examples/peripherals/i2c/i2c_tools/example_test.py deleted file mode 100644 index 67d48b4810..0000000000 --- a/examples/peripherals/i2c/i2c_tools/example_test.py +++ /dev/null @@ -1,37 +0,0 @@ -from __future__ import print_function - -import ttfw_idf - -EXPECT_TIMEOUT = 20 - - -@ttfw_idf.idf_example_test(env_tag='Example_I2C_CCS811_SENSOR') -def test_i2ctools_example(env, extra_data): - # Get device under test, flash and start example. "i2ctool" must be defined in EnvConfig - dut = env.get_dut('i2ctools', 'examples/peripherals/i2c/i2c_tools', dut_class=ttfw_idf.ESP32DUT) - dut.start_app() - dut.expect('i2c-tools>', timeout=EXPECT_TIMEOUT) - # Get i2c address - dut.write('i2cdetect') - dut.expect('5b', timeout=EXPECT_TIMEOUT) - # Get chip ID - dut.write('i2cget -c 0x5b -r 0x20 -l 1') - dut.expect('0x81', timeout=EXPECT_TIMEOUT) - # Reset sensor - dut.write('i2cset -c 0x5b -r 0xFF 0x11 0xE5 0x72 0x8A') - dut.expect('OK', timeout=EXPECT_TIMEOUT) - # Get status - dut.write('i2cget -c 0x5b -r 0x00 -l 1') - dut.expect_any('0x10', timeout=EXPECT_TIMEOUT) - # Change work mode - dut.write('i2cset -c 0x5b -r 0xF4') - dut.expect('OK', timeout=EXPECT_TIMEOUT) - dut.write('i2cset -c 0x5b -r 0x01 0x10') - dut.expect('OK', timeout=EXPECT_TIMEOUT) - # Get new status - dut.write('i2cget -c 0x5b -r 0x00 -l 1') - dut.expect_any('0x98', '0x90', timeout=EXPECT_TIMEOUT) - - -if __name__ == '__main__': - test_i2ctools_example() diff --git a/examples/peripherals/i2c/i2c_tools/pytest_examples_i2c_tools.py b/examples/peripherals/i2c/i2c_tools/pytest_examples_i2c_tools.py new file mode 100644 index 0000000000..cc152e0070 --- /dev/null +++ b/examples/peripherals/i2c/i2c_tools/pytest_examples_i2c_tools.py @@ -0,0 +1,32 @@ +# SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD +# SPDX-License-Identifier: Unlicense OR CC0-1.0 +import pytest +from pytest_embedded_idf import IdfDut + +EXPECT_TIMEOUT = 20 + + +@pytest.mark.esp32 +@pytest.mark.ccs811 +def test_i2ctools_example(dut: IdfDut) -> None: + dut.expect_exact('i2c-tools>', timeout=EXPECT_TIMEOUT) + # Get i2c address + dut.write('i2cdetect') + dut.expect_exact('5b', timeout=EXPECT_TIMEOUT) + # Get chip ID + dut.write('i2cget -c 0x5b -r 0x20 -l 1') + dut.expect_exact('0x81', timeout=EXPECT_TIMEOUT) + # Reset sensor + dut.write('i2cset -c 0x5b -r 0xFF 0x11 0xE5 0x72 0x8A') + dut.expect_exact('OK', timeout=EXPECT_TIMEOUT) + # Get status + dut.write('i2cget -c 0x5b -r 0x00 -l 1') + dut.expect_exact('0x10', timeout=EXPECT_TIMEOUT) + # Change work mode + dut.write('i2cset -c 0x5b -r 0xF4') + dut.expect_exact('OK', timeout=EXPECT_TIMEOUT) + dut.write('i2cset -c 0x5b -r 0x01 0x10') + dut.expect_exact('OK', timeout=EXPECT_TIMEOUT) + # Get new status + dut.write('i2cget -c 0x5b -r 0x00 -l 1') + dut.expect_exact(['0x98', '0x90'], timeout=EXPECT_TIMEOUT) diff --git a/examples/peripherals/sdio/host/main/app_main.c b/examples/peripherals/sdio/host/main/app_main.c index 0ef1a20ebf..ff39f922b1 100644 --- a/examples/peripherals/sdio/host/main/app_main.c +++ b/examples/peripherals/sdio/host/main/app_main.c @@ -416,7 +416,7 @@ void job_write_reg(essl_handle_t handle, int value) } ESP_LOGI(TAG, "read registers:"); - ESP_LOG_BUFFER_HEXDUMP(TAG, reg_read, 64, ESP_LOG_INFO); + ESP_LOG_BUFFER_HEXDUMP(TAG, reg_read, 60, ESP_LOG_INFO); } //the slave only load 16 buffers a time diff --git a/examples/peripherals/sdio/pytest_sdio_test.py b/examples/peripherals/sdio/pytest_sdio_test.py new file mode 100644 index 0000000000..487d8d35f6 --- /dev/null +++ b/examples/peripherals/sdio/pytest_sdio_test.py @@ -0,0 +1,112 @@ +# SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD +# SPDX-License-Identifier: Apache-2.0 +import os +from typing import Tuple + +import pytest +from pytest_embedded_idf import IdfDut + + +@pytest.mark.esp32 +@pytest.mark.sdio_master_slave +@pytest.mark.parametrize( + 'count, app_path', + [ + (2, f'{os.path.join(os.path.dirname(__file__), "host")}|{os.path.join(os.path.dirname(__file__), "slave")}'), + ], + indirect=True, +) +def test_example_sdio_communication(dut: Tuple[IdfDut, IdfDut]) -> None: + """ + Configurations + host = host -> slave = slave + should be in the same group of devices, otherwise may meet download issue + group1: (Wroom-32 Series or PICO-D4 modules: PICO-Kit, DevKitC, WroverKit v2 or earlier) + group2: (Wrover module: WroverKit v3) + + GPIO14->GPIO14 + GPIO15->GPIO15 + GPIO2->GPIO2 + GPIO4->GPIO4 + GND->GND + + VDD3.3 -> GPIO13 if slave uses WroverKit v3 + + or use sdio test board, which has two wrover modules connect to a same FT3232 + Assume that first dut is host and second is slave + """ + host = dut[0] + slave = dut[1] + + host.pexpect_proc.timeout = 5 + slave.pexpect_proc.timeout = 5 + + host.expect_exact('host ready, start initializing slave...') + host.expect_exact('0a 0d 10 13 16 19 1c 1f 22 25 28 2b 2e 31 34 37') + host.expect_exact('3a 3d 40 43 46 49 4c 4f 52 55 58 5b 5e 61 64 67') + host.expect_exact('6a 6d 70 73 76 79 7c 7f 82 85 88 8b 8e 91 94 97') + host.expect_exact('9a 9d a0 a3 a6 a9 ac af b2 b5 b8 bb') + + slave.expect_exact('================ JOB_WRITE_REG ================') + slave.expect_exact('0a 0d 10 13 16 19 1c 1f 22 25 28 2b 2e 31 34 37') + slave.expect_exact('3a 3d 40 43 46 49 4c 4f 52 55 58 5b 5e 61 64 67') + slave.expect_exact('6a 6d 70 73 76 79 7c 7f 82 85 88 8b 8e 91 94 97') + slave.expect_exact('9a 9d a0 a3 a6 a9 ac af b2 b5 b8 bb') + + host.expect_exact('host int: 0') + host.expect_exact('host int: 1') + host.expect_exact('host int: 2') + host.expect_exact('host int: 3') + host.expect_exact('host int: 4') + host.expect_exact('host int: 5') + host.expect_exact('host int: 6') + host.expect_exact('host int: 7') + host.expect_exact('host int: 0') + host.expect_exact('host int: 1') + host.expect_exact('host int: 2') + host.expect_exact('host int: 3') + host.expect_exact('host int: 4') + host.expect_exact('host int: 5') + host.expect_exact('host int: 6') + host.expect_exact('host int: 7') + + slave.expect_exact('================ JOB_SEND_INT ================') + slave.expect_exact('================ JOB_SEND_INT ================') + + host.expect_exact('send packet length: 6') + host.expect_exact('send packet length: 12') + host.expect_exact('send packet length: 1024') + host.expect_exact('send packet length: 512') + host.expect_exact('send packet length: 3') + + slave.expect_exact('Packet received, len: 6') + slave.expect_exact('Buffer 0, len: 6') + slave.expect_exact('Packet received, len: 12') + slave.expect_exact('Buffer 0, len: 12') + # 1024 + slave.expect_exact('Packet received, len: 1024') + for i in range(8): + slave.expect_exact(f'Buffer {i}, len: 128') + # 512 + slave.expect_exact('Packet received, len: 512') + for i in range(4): + slave.expect_exact(f'Buffer {i}, len: 128') + # 3 + slave.expect_exact('Packet received, len: 3') + slave.expect_exact('Buffer 0, len: 3') + + # same as slave received + host.expect_exact('receive data, size: 6') + host.expect_exact('receive data, size: 12') + for _ in range(8): + host.expect_exact('receive data, size: 128') + for _ in range(4): + host.expect_exact('receive data, size: 128') + host.expect_exact('receive data, size: 3') + + # the last valid line of one round + host.expect_exact('aa af b4') + + # the first 2 lines of the second round + host.expect_exact('46 4b 50 55 5a 5f') + host.expect_exact('6e 73 78 7d 82 87 8c 91 96 9b a0 a5') diff --git a/examples/peripherals/sdio/sdio_test.py b/examples/peripherals/sdio/sdio_test.py deleted file mode 100644 index 07ec784a74..0000000000 --- a/examples/peripherals/sdio/sdio_test.py +++ /dev/null @@ -1,123 +0,0 @@ -# Copyright 2015-2017 Espressif Systems (Shanghai) PTE LTD -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http:#www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import ttfw_idf -from tiny_test_fw import TinyFW - - -@ttfw_idf.idf_example_test(env_tag='Example_SDIO', ignore=True) -def test_example_sdio_communication(env, extra_data): - """ - Configurations - dut1 = host -> dut2 = slave - should be in the same group of devices, otherwise may meet download issue - group1: (Wroom-32 Series or PICO-D4 modules: PICO-Kit, DevKitC, WroverKit v2 or earlier) - group2: (Wrover module: WroverKit v3) - - GPIO14->GPIO14 - GPIO15->GPIO15 - GPIO2->GPIO2 - GPIO4->GPIO4 - GND->GND - - VDD3.3 -> GPIO13 if dut2 uses WroverKit v3 - - or use sdio test board, which has two wrover modules connect to a same FT3232 - Assume that first dut is host and second is slave - """ - dut1 = env.get_dut('sdio_host', 'examples/peripherals/sdio/host', dut_class=ttfw_idf.ESP32DUT) - dut2 = env.get_dut('sdio_slave', 'examples/peripherals/sdio/slave', dut_class=ttfw_idf.ESP32DUT) - dut1.start_app() - # wait until the master is ready to setup the slave - dut1.expect('host ready, start initializing slave...') - - dut2.start_app() - dut1.expect('0a 0d 10 13 16 19 1c 1f 22 25 28 2b 2e 31 34 37') - dut1.expect('3a 3d 40 43 46 49 4c 4f 52 55 58 5b 00 00 00 00') - dut1.expect('6a 6d 70 73 76 79 7c 7f 82 85 88 8b 8e 91 94 97') - dut1.expect('9a 9d a0 a3 a6 a9 ac af b2 b5 b8 bb be c1 c4 c7') - - dut2.expect('================ JOB_WRITE_REG ================') - dut2.expect('0a 0d 10 13 16 19 1c 1f 22 25 28 2b 2e 31 34 37') - dut2.expect('3a 3d 40 43 46 49 4c 4f 52 55 58 5b 00 00 00 00') - dut2.expect('6a 6d 70 73 76 79 7c 7f 82 85 88 8b 8e 91 94 97') - dut2.expect('9a 9d a0 a3 a6 a9 ac af b2 b5 b8 bb be c1 c4 c7') - - dut1.expect('host int: 0') - dut1.expect('host int: 1') - dut1.expect('host int: 2') - dut1.expect('host int: 3') - dut1.expect('host int: 4') - dut1.expect('host int: 5') - dut1.expect('host int: 6') - dut1.expect('host int: 7') - dut1.expect('host int: 0') - dut1.expect('host int: 1') - dut1.expect('host int: 2') - dut1.expect('host int: 3') - dut1.expect('host int: 4') - dut1.expect('host int: 5') - dut1.expect('host int: 6') - dut1.expect('host int: 7') - - dut2.expect('================ JOB_SEND_INT ================') - dut2.expect('================ JOB_SEND_INT ================') - - dut1.expect('send packet length: 3') - dut1.expect('send packet length: 6') - dut1.expect('send packet length: 12') - dut1.expect('send packet length: 128') - dut1.expect('send packet length: 511') - dut1.expect('send packet length: 512') - - dut2.expect('recv len: 3') - dut2.expect('recv len: 6') - dut2.expect('recv len: 12') - dut2.expect('recv len: 128') - # 511 - dut2.expect('recv len: 128') - dut2.expect('recv len: 128') - dut2.expect('recv len: 128') - dut2.expect('recv len: 127') - # 512 - dut2.expect('recv len: 128') - dut2.expect('recv len: 128') - dut2.expect('recv len: 128') - dut2.expect('recv len: 128') - - dut1.expect('receive data, size: 3') - dut1.expect('receive data, size: 6') - dut1.expect('receive data, size: 12') - dut1.expect('receive data, size: 128') - - dut1.expect('receive data, size: 128') - dut1.expect('receive data, size: 128') - dut1.expect('receive data, size: 128') - dut1.expect('receive data, size: 127') - - dut1.expect('receive data, size: 128') - dut1.expect('receive data, size: 128') - dut1.expect('receive data, size: 128') - dut1.expect('receive data, size: 128') - - # the last valid line of one round - dut1.expect('ce d3 d8 dd e2 e7 ec f1 f6 fb 00 05 0a 0f 14 19') - # the first 2 lines of the second round - dut1.expect('46 4b 50') - dut1.expect('5a 5f 64 69 6e 73') - - -if __name__ == '__main__': - TinyFW.set_default_config(env_config_file='EnvConfigTemplate.yml', dut=ttfw_idf.IDFDUT) - test_example_sdio_communication() diff --git a/examples/peripherals/sdio/slave/main/app_main.c b/examples/peripherals/sdio/slave/main/app_main.c index f32766e0aa..f78ad91070 100644 --- a/examples/peripherals/sdio/slave/main/app_main.c +++ b/examples/peripherals/sdio/slave/main/app_main.c @@ -62,6 +62,9 @@ #define EV_STR(s) "================ "s" ================" +//skip interrupt regs. +#define SLAVE_ADDR(i) ((i) >= 28? (i) + 4: (i)) + typedef enum { JOB_IDLE = 0, JOB_RESET = 1, @@ -123,19 +126,15 @@ static esp_err_t task_write_reg(void) { //the host write REG1, the slave should write its registers according to value of REG1 uint8_t read = sdio_slave_read_reg(1); - for (int i = 0; i < 64; i++) { - //skip interrupt regs. - if (i >= 28 && i <= 31) continue; - sdio_slave_write_reg(i, read+3*i); + for (int i = 0; i < 60; i++) { + sdio_slave_write_reg(SLAVE_ADDR(i), read + 3*i); } - uint8_t reg[64] = {0}; - for (int i = 0; i < 64; i++) { - //skip interrupt regs. - if (i >= 28 && i <= 31) continue; - reg[i] = sdio_slave_read_reg(i); + uint8_t reg[60] = {0}; + for (int i = 0; i < 60; i++) { + reg[i] = sdio_slave_read_reg(SLAVE_ADDR(i)); } ESP_LOGI(TAG, "write regs:"); - ESP_LOG_BUFFER_HEXDUMP(TAG, reg, 64, ESP_LOG_INFO); + ESP_LOG_BUFFER_HEXDUMP(TAG, reg, 60, ESP_LOG_INFO); return ESP_OK; }