Before running tests, please make sure to use a top-level requirements.txt file to install all the required Python modules.
pip install -r requirements.txt
Additional, platform-specific setup is described below. See also Known issues.
Zadig
application from the Zadig website.Zadig
.libusb-win32 (v1.2.6.0)
driver.Install Driver
and click it.libusb-win32 (v1.2.6.0)
driver.Install Driver
and click it.Zadig
.Install the hidapi
Python module, otherwise some USB HID test cases will be skipped. This module is not installed during the initial setup due to external dependencies for Linux.
For Debian-based Linux distros, the dependencies can be installed as follows (based on module's README):
apt-get install python-dev libusb-1.0-0-dev libudev-dev pip install --upgrade setuptools
To install the hidapi
module itself, please use the attached requirements.txt file:
pip install -r TESTS/usb_device/hid/requirements.txt
Update the udev
rules for Mbed USB CDC device as follows (source):
sudo tee /etc/udev/rules.d/99-ttyacms.rules >/dev/null <<EOF ATTRS{idVendor}=="1f00" ATTRS{idProduct}=="2013", ENV{ID_MM_DEVICE_IGNORE}="1" ATTRS{idVendor}=="1f00" ATTRS{idProduct}=="2012", ENV{ID_MM_DEVICE_IGNORE}="1" EOF sudo udevadm control --reload-rules
This will prevent the ModemManager
daemon from automatically opening the port and sending the AT commands
, which it does for every new /dev/ttyACM
device registered in system.
No setup method has been verified for this platform.
USB_DEVICE_TESTS
is needed to be defined when running tests:
mbed test -t <toolchain> -m <target> -DUSB_DEVICE_TESTS -n *-tests-usb_device-*
Some of the tests require privileged access to the USB device. Running these as an unprivileged user will manifest with either of the following errors:
[HTST][INF] Device not found
[HTST][INF] TEST ERROR: Failed with "The device has no langid". Tried 20 times.
Execute tests with elevated permissions using sudo
:
mbed test -t <toolchain> -m <target> -DUSB_DEVICE_TESTS -n tests-usb_device-* --compile sudo mbed test -t <toolchain> -m <target> -n *-tests-usb_device-* --run -v
Note only the mbed test --run
command requires sudo
. You can still mbed test --compile
as a normal user.
Add an udev
rule to set the ownership of the device node as shown here.
The tests-usb_device-basic
/ "endpoint test data toggle reset"
test fails with the following error:
[HTST][INF] TEST FAILED: Data toggle not reset when calling ClearFeature(ENDPOINT_HALT) on an endpoint that has not been halted.
Implementations of the xHCI driver prior to version 4.17 of the Linux kernel did not have the functionality necessary to test "endpoint test data toggle reset"
. Even though the data toggle is correctly reset on the device side, the host side will not be synchronized and the test will falsely fail.
Make sure that at least one of the following prerequisites is met:
Changing the USB driver may be as simple as updating one of the BIOS settings on your machine. If you'd rather avoid rebooting, you can try using setpci command.
The tests-usb_device-msd
test outputs the following message:
[CONN][RXD] SKIP: Not enough heap memory for HeapBlockDevice creation
A device with at least 70 kB of RAM is required to run this test. The FAT32 filesystem cannot be mounted on a device smaller than 64 kB.
The test can be easily extended to use any block device available in Mbed.
By default Windows 8 and 10 access and write to removable drives shortly after they are connected. It's caused by drive indexing mechanisms. Because disk used in test has only 64kB its content can be easily corrupted by writing large files, what actually was encountered during test runs.
To prevent Windows from writing to removable drives on connect drive indexing can be turned off with the following procedure:
You may want to connect the device directly to the host machine with no hubs on the way.