Following a recent Ceph USB gateway project, I was looking at ways to test a Linux USB device without the need to fiddle with cables, or deal with slow embedded board boot times.
Ideally USB gadget testing could be performed by running the USB device code within a virtual machine, and attaching the VM's virtual USB device port to an emulated USB host controller on the hypervisor system.
I was unfortunately unable to find support for virtual USB device ports in QEMU, so I abandoned the above architecture, and discovered dummy_hcd.ko instead.
The dummy_hcd Linux kernel module is an excellent utility for USB device testing from within a standalone system or VM.
dummy_hcd.ko offers the following features:
- Re-route USB device traffic back to the local system
- Effectively providing device loopback functionality
- USB high-speed and super-speed connection simulation
Nice approach...I spent yesterday figuring this all out for myself only to stumble upon your post today! It is worth amplifying that dummy_hcd is both a combined USB Host Driver and USB Device Driver, so technically those two boxes in your diagram should really sit inside dummy_hcd.
ReplyDeleteIt also works with the testusb application and usbtest kernel driver (assuming you load g_zero gadget) so you can also easily create a test framework for USB.