summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhathach <[email protected]>2025-10-01 20:56:20 +0700
committerhathach <[email protected]>2025-10-02 10:43:55 +0700
commit6d32256188d578079b0d050509f2c7d7178897a0 (patch)
tree76e5f21d6321480da5bb1f87b318c06793455cd5
parent26939587b55dc3c6958a3b630664e6a0b7d9da9b (diff)
HIL add timeout for opening mtp device
-rw-r--r--.github/workflows/build.yml3
-rw-r--r--docs/reference/getting_started.rst2
-rw-r--r--examples/device/mtp/src/usb_descriptors.c2
-rwxr-xr-xtest/hil/hil_test.py24
4 files changed, 20 insertions, 11 deletions
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'