BeagleBoard/GSoC/2010 Projects/USBSniffer

Google Summer of Code 2010 Project


 * Student: Nicolas Boichat
 * Mentors: Hunyue Yau, Laine Walker-Avina, Frans Meulenbroeks

BeagleBoard project: usbsniffer

Project at gitorious.org: http://gitorious.org/beagleboard-usbsniffer

Blog: http://beagleboard-usbsniffer.blogspot.com/ (RSS)

Abstract
The goal of this project is to use the BeagleBoard as an USB sniffer. The host computer would be connected to the slave USB port of the BeagleBoard, and the device to be sniffed on the host USB port.

The BeagleBoard would then forward USB data, while logging it.

This presents the following advantages over a software-based solution: No software modification is required; support of proprietary OSes; allows debugging of new USB stacks; and possibly lower-level debugging of USB frames...

Build and run instructions
To get the proxy driver to work, you need to follow these steps:


 * Clone my kernel git tree. Use the stable-20100702 branch.
 * Compile the kernel with the default beagleboard configuration (see BeagleBoard). You just need to add CONFIG_USB_G_PROXY=m. I also disabled MUSB in host and OTG mode, as well as USB suspend, but this may not be necessary.
 * Install the new kernel on the board.
 * Clone the helper scripts git tree, and copy the content of the arm directory to the BeagleBoard (you need to modify load/setup scripts if you do not have have a copy of musb_hdrc.ko and g_proxy.ko in the same directory).
 * Run ./setup on the BeagleBoard, this will unload the g_ether gadget driver.
 * Plug your device (through a USB hub if it is a low/full-speed device).
 * Plug your PC to the BeagleBoard USB slave port (this can be done earlier as well).
 * Run ./unbind: This will unbind the device from the normal Linux driver.
 * Run ./load: this will (re)load the g_proxy driver.
 * Use the device, it should work.

MUSB testing code
Some instructions on how to use the code to trigger the MUSB bug with short isochronous packets:

Checkout |http://gitorious.org/beagleboard-usbsniffer/musb-test. There are 2 directories: host</tt>, and device</tt>.

For the device side (on the beagleboard), you need to cross-compile usbtest</tt>. You need libaio</tt>, which can be built using Angstrom, and gadgetfs</tt> in the Linux kernel. Then, the gadgetfs driver is loaded as follows:

modprobe gadgetfs mkdir /dev/gadget/ -p mount -t gadgetfs none /dev/gadget ./usbtest -v -s 512 -p 1 -I0 -a 1

The host code must be run on your host PC. It requires the usbtest</tt> module (CONFIG_USB_TEST=m</tt>), then isochronous IN transfers are tested with the following command: ./testusb -a -t 16 -g 1

While running the test, you can monitor the USB traffic using usbmon, you should see isochronous packets of length 18, i.e., something like this: ... S Zi:7:062:1 -115:1:152618721 1 -18:0:512 512 < ... C Zi:7:062:1 0:1:152618723:0 1 0:0:18 18 = 00010203 04050607 08090a0b 0c0d0e0f 1011