SerialUSB: A cheap USB proxy for input devices

Input devices generally use interrupt IN and OUT endpoints, and operate at low or full speed modes.
The maximum throughput is 64 kB/s = 512kbps in each direction (1000Hz, 64-byte packets).
A USB proxy requires a system with both device and host interfaces.
Many ARM boards fulfill this requirement, but those aren't as cheap (yet).

serialusb is the combination of:

  • a PC software operating the host side of the proxy
  • an atmega32u4 firmware operating the device side of the proxy

The atmega32u4 and the PC are connected using a USB to UART adapter, running at a baudrate of 500kbps.

target device ↔ PC ↔ USB to UART adapter ↔ atmega32u4 ↔ target host

I'm the developper of the GIMX project, which aims at allowing people to use any input device with any gaming console. It is quite frequent that people contact me asking if GIMX could emulate a specific device. As I can't afford buying every input device, the only solution is that people provide me a USB capture of the device protocol. Commercial USB capture tools are costly, and many people can't afford buying one. serialusb aims to be a solution to this problem.

serialusb attempts to meet the following goals:

  1. low cost (< $10)
  2. low latency and low CPU footprint
  3. low disturbance on transfered data
  4. reusability:
    • allow code parts to be used into the GIMX project
    • make it easy to later add support for cheap ARM-based devices such as CHIP

These goals led to the following decisions:

  • use the same hardware as the GIMX DIY USB adapter → 1.
  • interrupt-driven event processing in a single-threaded process → 2.
  • once the proxy is started, only use libusb's asynchronous API → 2.
  • use raw descriptors (don't reconstruct descriptors) → 3.
  • abstract USB device and serial port handling → 4.

    Software requirements

    Hardware requirements

    • a computer with 2 USB host ports
    • an atmega32u4 board running at 5V (~$4 on ebay)
    • a CP2102- or FT232RL-based USB to UART adapter with 5V tolerance (~$1 on ebay)
      • the FT232RL is better as its max baudrate is 3Mbps (vs 921600bps)cheap USB proxy

Instructions

  • Assemble the atmega32u4 board and the USB to UART adapter as explained on the GIMX DIY USB adapter wiki page.
    Use the latest emu-X.Y.hex firmware from the release page.
  • Connect the USB to UART adapter to the PC, and the atmega32u4 board to the target host.
  • Connect the target device to the PC.
  • Either install serialusb from the sources, or install the package I built for Linux Mint 17.3 64-bit.
    The prebuilt packages should work with any Ubuntu 14.04 64-bit derivate.
  • Once installed, run the helper script: sudo serialusb-capture.sh
  • Select the USB to UART adapter, and the target device.

Limitations

  • Only control and interrupt endpoints are currently supported.
  • Multiple configurations are not supported. Only the first configuration can be used.
  • The size of any control transfer (setup + data) should not exceed 254 bytes.
    This limitation does not apply to the standard descriptors, see below.
  • All standard descriptors should fit into 1kB, which is the size of the RAM buffer used to store them into the atmega32u4.
    This limitation applies to the following standard descriptors:
    • device descriptor
    • configuration descriptors
    • langId0 descriptor
    • strings referenced in the device and configuration descriptors
    • HID report descriptors
  • This is a software proxy, not a hardware one: it's usefull for reverse-engineering protocols, not for investigating hardware issues.

For more detail:  SerialUSB: A cheap USB proxy for input devices


About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top