From 4e4e2be5662bf26fc3da6f79022db2f11134a64c Mon Sep 17 00:00:00 2001 From: hathach Date: Wed, 1 Oct 2025 15:26:04 +0700 Subject: test mtp with hil --- .github/workflows/build.yml | 2 -- 1 file changed, 2 deletions(-) (limited to '.github/workflows') diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ff59421ce..676e2d428 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -208,8 +208,6 @@ jobs: - name: Checkout TinyUSB if: github.run_attempt == '1' uses: actions/checkout@v4 - with: - sparse-checkout: test/hil - name: Download Artifacts if: github.run_attempt == '1' -- cgit v1.3.1 From 26939587b55dc3c6958a3b630664e6a0b7d9da9b Mon Sep 17 00:00:00 2001 From: hathach Date: Wed, 1 Oct 2025 17:22:44 +0700 Subject: hil tinyusb always checkoutt/download artifacts --- .github/workflows/build.yml | 3 --- 1 file changed, 3 deletions(-) (limited to '.github/workflows') diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 676e2d428..a0daefab9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -199,18 +199,15 @@ jobs: runs-on: [self-hosted, X64, hathach, hardware-in-the-loop] steps: - name: Clean workspace - if: github.run_attempt == '1' run: | echo "Cleaning up for the first run" rm -rf "${{ github.workspace }}" mkdir -p "${{ github.workspace }}" - name: Checkout TinyUSB - if: github.run_attempt == '1' uses: actions/checkout@v4 - name: Download Artifacts - if: github.run_attempt == '1' uses: actions/download-artifact@v4 with: path: cmake-build -- cgit v1.3.1 From 6d32256188d578079b0d050509f2c7d7178897a0 Mon Sep 17 00:00:00 2001 From: hathach Date: Wed, 1 Oct 2025 20:56:20 +0700 Subject: HIL add timeout for opening mtp device --- .github/workflows/build.yml | 3 +++ docs/reference/getting_started.rst | 2 +- examples/device/mtp/src/usb_descriptors.c | 2 +- test/hil/hil_test.py | 24 +++++++++++++++--------- 4 files changed, 20 insertions(+), 11 deletions(-) (limited to '.github/workflows') diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a0daefab9..676e2d428 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -199,15 +199,18 @@ jobs: runs-on: [self-hosted, X64, hathach, hardware-in-the-loop] steps: - name: Clean workspace + if: github.run_attempt == '1' run: | echo "Cleaning up for the first run" rm -rf "${{ github.workspace }}" mkdir -p "${{ github.workspace }}" - name: Checkout TinyUSB + if: github.run_attempt == '1' uses: actions/checkout@v4 - name: Download Artifacts + if: github.run_attempt == '1' uses: actions/download-artifact@v4 with: path: cmake-build diff --git a/docs/reference/getting_started.rst b/docs/reference/getting_started.rst index bb9ff1cb4..f1a755804 100644 --- a/docs/reference/getting_started.rst +++ b/docs/reference/getting_started.rst @@ -178,7 +178,7 @@ By default log message is printed via on-board UART which is slow and take lots * Pros: work with most if not all MCUs * Software viewer is JLink RTT Viewer/Client/Logger which is bundled with JLink driver package. -* ``LOGGER=swo``\ : Use dedicated SWO pin of ARM Cortex SWD debug header. +* ``LOGGER=swo`` : Use dedicated SWO pin of ARM Cortex SWD debug header. * Cons: only work with ARM Cortex MCUs minus M0 * Pros: should be compatible with more debugger that support SWO. diff --git a/examples/device/mtp/src/usb_descriptors.c b/examples/device/mtp/src/usb_descriptors.c index 810137c46..ddda4d686 100644 --- a/examples/device/mtp/src/usb_descriptors.c +++ b/examples/device/mtp/src/usb_descriptors.c @@ -143,7 +143,7 @@ char const *string_desc_arr[] = "TinyUsb", // 1: Manufacturer "TinyUsb Device", // 2: Product NULL, // 3: Serials will use unique ID if possible - "TinyUSBB MTP", // 4: MTP Interface + "TinyUSB MTP", // 4: MTP Interface }; static uint16_t _desc_str[32 + 1]; diff --git a/test/hil/hil_test.py b/test/hil/hil_test.py index 1a846dd4a..c747ad763 100755 --- a/test/hil/hil_test.py +++ b/test/hil/hil_test.py @@ -42,8 +42,6 @@ import hashlib import ctypes from pymtp import MTP -mtp = MTP() - ENUM_TIMEOUT = 30 STATUS_OK = "\033[32mOK\033[0m" @@ -140,6 +138,19 @@ def read_disk_file(uid, lun, fname): return None +def open_mtp_dev(uid): + mtp = MTP() + timeout = ENUM_TIMEOUT + while timeout > 0: + for raw in mtp.detect_devices(): + mtp.device = mtp.mtp.LIBMTP_Open_Raw_Device(ctypes.byref(raw)) + if mtp.device and mtp.get_serialnumber().decode('utf-8') == uid: + return mtp + time.sleep(1) + timeout -= 1 + return None + + # ------------------------------------------------------------- # Flashing firmware # ------------------------------------------------------------- @@ -505,19 +516,14 @@ def test_device_mtp(board): _null = os.open(os.devnull, os.O_WRONLY) os.dup2(_null, fd) - for raw in mtp.detect_devices(): - mtp.device = mtp.mtp.LIBMTP_Open_Raw_Device(ctypes.byref(raw)) - if mtp.device and mtp.get_serialnumber().decode('utf-8') == uid: - break - else: - mtp.device = None + mtp = open_mtp_dev(uid) # --- AFTER: restore stderr --- os.dup2(_saved, fd) os.close(_null) os.close(_saved) - if mtp.device is None: + if mtp is None or mtp.device is None: assert False, 'MTP device not found' assert b"TinyUSB" == mtp.get_manufacturer(), 'MTP wrong manufacturer' -- cgit v1.3.1 From 610f353d8d602c3192f9edc03669ab792056f7da Mon Sep 17 00:00:00 2001 From: hathach Date: Thu, 2 Oct 2025 18:54:31 +0700 Subject: use cache to store skip board in hil ci --- .github/workflows/build.yml | 11 ++++++++--- test/hil/hil_test.py | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) (limited to '.github/workflows') diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 676e2d428..9243c866d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -199,23 +199,28 @@ jobs: runs-on: [self-hosted, X64, hathach, hardware-in-the-loop] steps: - name: Clean workspace - if: github.run_attempt == '1' run: | echo "Cleaning up for the first run" rm -rf "${{ github.workspace }}" mkdir -p "${{ github.workspace }}" - name: Checkout TinyUSB - if: github.run_attempt == '1' uses: actions/checkout@v4 - name: Download Artifacts - if: github.run_attempt == '1' uses: actions/download-artifact@v4 with: path: cmake-build merge-multiple: true + - name: Cache skip list + uses: actions/cache@v4 + with: + path: ${{ env.HIL_JSON }}.skip + key: hil-skip-${{ github.run_id }}-${{ github.run_attempt }} + restore-keys: | + hil-skip-${{ github.run_id }}- + - name: Test on actual hardware run: | ls cmake-build/ diff --git a/test/hil/hil_test.py b/test/hil/hil_test.py index 2e6840a6d..fc8255f1b 100755 --- a/test/hil/hil_test.py +++ b/test/hil/hil_test.py @@ -583,7 +583,7 @@ device_tests = [ 'device/dfu_runtime', 'device/cdc_msc_freertos', 'device/hid_boot_interface', - # 'device/mtp' + 'device/mtp' ] dual_tests = [ -- cgit v1.3.1