diff options
| author | Ralf Kistner <ralf.kistner@gmail.com> | 2013-03-18 22:42:13 +0200 |
|---|---|---|
| committer | Ralf Kistner <ralf.kistner@gmail.com> | 2013-03-18 22:42:13 +0200 |
| commit | e521a3edd13d66738db04d2451db5a08daeef4a0 (patch) | |
| tree | e4791d605a257c34f9f3b0c981f13d70fe4aea06 | |
| parent | cf833623492bc92cc1b8b02c54b8098207ab8f68 (diff) | |
Add USB development notes.
| -rw-r--r-- | USB-dev-notes.md | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/USB-dev-notes.md b/USB-dev-notes.md new file mode 100644 index 0000000..0b95892 --- /dev/null +++ b/USB-dev-notes.md @@ -0,0 +1,50 @@ +# USB Development Notes + +Devices such as the Arduino Leonardo supports the implementation of almost any USB client device (except high speed devices probably). +Here are some notes of things I found useful while implementing MIDI-USB. + +## Ubuntu + +I did all my development on Ubuntu, which has some great tools for USB debugging. Here are the tools I've used: + +### lsusb + +`lsusb` will show you all the connected USB devices. To see the descriptors and endpoints for each device, get the device ID (manufacturer and +product id) with `lsusb`, then use `lsusb -v -d <vid:pid>`. For example, for the Arduino Leonardo, use `lsusb -v -d 2341:8036`. + +### Wireshark + +Wireshark is well known for sniffing network packets, but it can also be used for USB. To enable USB monitoring support, run `sudo modprobe usbmon` +before launching wireshark, and the USB busses will show up as monitorable devices the next time you launch Wireshark. For more details, see +[their wiki][1]. + +## Development process + +### Descriptors and endpoints + +The first step is to get the descriptors and endpoints as they should be. Try to replicate the descriptors of an existing device, and use lsusb +to compare it with yours. If you don't have another device of the same USB type, you may find some lsusb output for a similar device on the internet. + +### The send and receive implementations + +Try to work off an existing implementation, such as the CDC or HID implementations by Arduino. Here Wireshark helps a lot for debugging. +Note that data is only sent to the PC if an application is connected. This means that for Serial or MIDI debugging, you need +to connect an application to the device first before you'll be able to see any data in Wireshark. + +### Reset + +When developing USB drivers, it is easy get the device to not respond at all, including for code upload. In this case, preset the reset button +on the board immediately after pressing upload in the Arduino IDE. + +## MIDI-specific + +`amidi` is useful to display raw MIDI messages coming from the device. + +`aplaymidi` is useful to send MIDI data (typically midi files) to the device. + +`aconnect` can be used to connect MIDI endpoints together, for example to connect the device to fsynth. + + + [1]: http://wiki.wireshark.org/CaptureSetup/USB + + |
