From bfbdff32529372e46ab9900dcfa10fbcdeb39cb4 Mon Sep 17 00:00:00 2001 From: Aanchal Chaurasia Date: Fri, 23 May 2025 12:17:05 +0530 Subject: [PATCH 1/3] Add script to test USB Device enumeration on Windows PC The script verifies successful USB enumeration on Host PC for given PID when DUT is connected via USB. Signed-off-by: Aanchal Chaurasia --- USBDevice/Windows/run.py | 54 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 USBDevice/Windows/run.py diff --git a/USBDevice/Windows/run.py b/USBDevice/Windows/run.py new file mode 100644 index 00000000..486f1276 --- /dev/null +++ b/USBDevice/Windows/run.py @@ -0,0 +1,54 @@ +# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +# SPDX-License-Identifier: BSD-3-Clause-Clear + +import time +import subprocess + +def check_enum(pid): + # Run devcon status command with the given PID + command = f'devcon status *{pid}*' + result = subprocess.run(command, capture_output=True, universal_newlines=True, stdin=subprocess.DEVNULL,shell=True) + out, err = result.stdout, result.stderr + if out.find("The device has the following problem") != -1: + print("USB is not properly enumerated:{}".format(out)) + print('Retry after 10 secs...') + time.sleep(10) + result = subprocess.run(command, capture_output=True, universal_newlines=True, stdin=subprocess.DEVNULL,shell=True) + out, err = result.stdout, result.stderr + if out.find("The device has the following problem") != -1: + print("USB is not properly enumerated. Please check for yellow bang on USB driver in the Device Manager:{}".format(out)) + return False + elif out.find("Driver is running") != -1: + print("USB is properly enumerated") + return True + else: + print("USB enumeration failed!") + print(out) + return False + elif out.find("Driver is running") != -1: + print("USB is properly enumerated") + return True + else: + print("USB enumeration failed!") + print(out) + print('Retry after 10 secs...') + time.sleep(10) + result = subprocess.run(command, capture_output=True, universal_newlines=True, stdin=subprocess.DEVNULL,shell=True) + out, err = result.stdout, result.stderr + if out.find("The device has the following problem") != -1: + print("USB is not properly enumerated. Please check for yellow bang on USB driver in the Device Manager:{}".format(out)) + return False + elif out.find("Driver is running") != -1: + print("USB is properly enumerated") + return True + else: + print("USB enumeration failed!") + print(out) + return False + +if __name__ == "__main__": + pid = input("Enter USB PID to check enumeration: ") + if check_enum(pid): + print("[PASS] USB Device Enumeration in {} is successful".format(pid)) + else: + print("[FAIL] USB Device Enumeration in {} has failed".format(pid)) \ No newline at end of file From 7e85bdaead68a20cf379c8a4886d75ffdbce5d88 Mon Sep 17 00:00:00 2001 From: Aanchal Chaurasia Date: Fri, 23 May 2025 12:20:27 +0530 Subject: [PATCH 2/3] Add script to test USB enumeration on Linux PC The script verifies successful enumeration on Ubuntu/Mac PCs with given PID when DUT is connected via USB. Signed-off-by: Aanchal Chaurasia --- USBDevice/Linux/run.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 USBDevice/Linux/run.py diff --git a/USBDevice/Linux/run.py b/USBDevice/Linux/run.py new file mode 100644 index 00000000..a2d1d5d8 --- /dev/null +++ b/USBDevice/Linux/run.py @@ -0,0 +1,20 @@ +# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +# SPDX-License-Identifier: BSD-3-Clause-Clear + +import os + +def check_enum(pid): + command = f'lsusb | grep -i {pid}' + if(os.system(command) == 0): + print("USB is properly enumerated") + return True + else: + print("USB enumeration failed!") + return False + +if __name__ == "__main__": + pid = input("Enter USB PID to check enumeration: ") + if check_enum(pid): + print("[PASS] USB Device Enumeration in {} is successful".format(pid)) + else: + print("[FAIL] USB Device Enumeration in {} has failed".format(pid)) \ No newline at end of file From a71202c5f3dd1d00b9add6a4d432a4f8f3c66995 Mon Sep 17 00:00:00 2001 From: Aanchal Chaurasia Date: Fri, 23 May 2025 12:23:17 +0530 Subject: [PATCH 3/3] Add documentation for using USB Device test scripts The documentation includes setup details, usage and examples for running USB Device mode test scripts. Signed-off-by: Aanchal Chaurasia --- USBDevice/README.md | 84 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 USBDevice/README.md diff --git a/USBDevice/README.md b/USBDevice/README.md new file mode 100644 index 00000000..56d436d0 --- /dev/null +++ b/USBDevice/README.md @@ -0,0 +1,84 @@ +``` +Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +SPDX-License-Identifier: BSD-3-Clause-Clear +``` + +# USB Device Mode Validation + +## Overview + +This test verifies enumeration of DUT (Device-Under-Test) connected via USB to Host PC. + +--- + +## Setup + +- Connect DUT to Host PC via USB. +- Only applicable for USB port(s) on DUT that support Peripheral/Device Mode functionality. + +--- + +## Usage + +### Prerequisites + +1. Install Python3 on Host PC. + +2. The script requires user to input USB PID (Product ID) against which the test checks successful USB enumeration on Host PC. Following is the list of supported PIDs: +``` +A4A1 NCM +4EE7 ADB +900E DIAG +901C DIAG + UAC2 +901D DIAG + ADB +9015 MASS_STORAGE + ADB +9024 RNDIS + ADB +902A RNDIS + MASS_STORAGE +902B RNDIS + ADB + MASS_STORAGE +902C RNDIS + DIAG +902D RNDIS + DIAG + ADB +902F RNDIS + DIAG + MASS_STORAGE +908C NCM + ADB +90CA DIAG + UAC2 + ADB +90CB DIAG + UVC + ADB +90CC DIAG + UAC2 + UVC + ADB +90DF DIAG + UVC +90E0 DIAG + UAC2 + UVC +9135 DIAG + QDSS + ADB +9136 DIAG + QDSS +F000 MASS_STORAGE +F00E RNDIS +``` + +### Windows + +1. **Connect DUT to Windows PC via USB** + + +2. **Execute run.py under USBDevice/Windows directory** + Use `python3` to execute run.py script on the Windows host by giving PID (Product ID) as user argument to test USB enumeration of target device. + + +### Example + +```py +python3 run.py +``` + +### Linux + +1. **Connect DUT to Linux PC via USB** + + +2. **Execute run.py under USBDevice/Linux directory** + Use `python3` to execute run.py script on the Linux host by giving PID (Product ID) as user argument to test USB enumeration of target device. + +--- + + +## License + +``` +Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +SPDX-License-Identifier: BSD-3-Clause-Clear +```