Trouble-shooting using Linux Host

General discussions about V-USB, our firmware-only implementation of a low speed USB device on Atmel's AVR microcontrollers
Post Reply
Mark1

Trouble-shooting using Linux Host

Post by Mark1 » Thu Oct 27, 2011 1:48 pm

I had some problems getting a basic V-USB device working.
I looked at the log files on the host system (my PC), to help trouble-shoot my V-USB device.

I'm a bit of a newbie. This post is a summary of what I learned or assumed, (and it took quite a while :)
in the hope that it helps anyone else as a starting point.

Good luck!
Mk


My host system: Linux: OpenSuSE 11.4 on a 64-bit AMD based system.


To see the USB devices connected to your system, use the command:
> lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 008 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 002: ID 0424:2502 Standard Microsystems Corp.
Bus 005 Device 002: ID 045e:0745 Microsoft Corp. Nano Transceiver v1.0 for Bluetooth
Bus 001 Device 003: ID 0424:2504 Standard Microsystems Corp. USB 2.0 Hub
Bus 001 Device 004: ID 0424:223a Standard Microsystems Corp. 8-in-1 Card Reader
Bus 001 Device 005: ID 046d:082b Logitech, Inc.
Bus 009 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 008 Device 013: ID 16c0:05dc VOTI shared ID for use with libusb


as you can see, each Bus has a root hub connected as Device 001.
We are interested in device numbers > 1,
and in particular with the final line, which shows my V-SUB hardware device has been enumerated:
Bus 008 Device 013: ID 16c0:05dc VOTI shared ID for use with libusb

Earlier, when the device was not working, I didn't get this last line.

So I checked the host (PC) USB port and USB cable by plugging the cable into a USB device that I knew was good
(my AVR Dragon programmer), and confirmed that 'lsusb' generated a new line for the programmer - which it did.


When my V-USB device wasn't connecting, I looked in the system logs,
where you can see the kernel attempting to enumerate the USB devices when they are plugged in:

> sudo tail /var/log/messages -n100


Good result (this is what it should look like):

Oct 27 11:55:20 linux-pn5m kernel: [ 6042.619118] usb 8-2: new low speed USB device using ohci_hcd and address 13
Oct 27 11:55:20 linux-pn5m kernel: [ 6042.872173] usb 8-2: New USB device found, idVendor=16c0, idProduct=05dc
Oct 27 11:55:20 linux-pn5m kernel: [ 6042.872182] usb 8-2: New USB device strings: Mfr=1, Product=2, SerialNumber=0
Oct 27 11:55:20 linux-pn5m kernel: [ 6042.872189] usb 8-2: Product: MyProduct
Oct 27 11:55:20 linux-pn5m kernel: [ 6042.872194] usb 8-2: Manufacturer: MyCompany.com
Oct 27 11:55:20 linux-pn5m mtp-probe: checking bus 8, device 13: "/sys/devices/pci0000:00/0000:00:14.4/0000:04:07.0/usb8/8-2"
Oct 27 11:55:20 linux-pn5m mtp-probe: bus: 8, device: 13 was not an MTP device


Bad result from earlier (when failing to enumerate my V-USB hardware):

Oct 27 11:42:30 linux-pn5m kernel: [ 5273.246152] usb 8-2: new low speed USB device using ohci_hcd and address 7
Oct 27 11:42:30 linux-pn5m kernel: [ 5273.410136] usb 8-2: device descriptor read/64, error -62
Oct 27 11:42:31 linux-pn5m kernel: [ 5273.675029] usb 8-2: device descriptor read/64, error -62
Oct 27 11:42:31 linux-pn5m kernel: [ 5273.933152] usb 8-2: new low speed USB device using ohci_hcd and address 8
Oct 27 11:42:31 linux-pn5m kernel: [ 5274.097148] usb 8-2: device descriptor read/64, error -62
Oct 27 11:42:31 linux-pn5m kernel: [ 5274.362124] usb 8-2: device descriptor read/64, error -62
Oct 27 11:42:32 linux-pn5m kernel: [ 5274.620137] usb 8-2: new low speed USB device using ohci_hcd and address 9
Oct 27 11:42:32 linux-pn5m kernel: [ 5275.024083] usb 8-2: device not accepting address 9, error -62
Oct 27 11:42:32 linux-pn5m kernel: [ 5275.181124] usb 8-2: new low speed USB device using ohci_hcd and address 10
Oct 27 11:42:33 linux-pn5m kernel: [ 5275.585139] usb 8-2: device not accepting address 10, error -62
Oct 27 11:42:33 linux-pn5m kernel: [ 5275.585160] hub 8-0:1.0: unable to enumerate USB device on port 2


Note on the first line that we have "using ohci_hcd"
this tells us which usb driver the kernel is using.

OK - so it's detected that a new device has been plugged in,
and it's assigned it an address on the host (temporarily).
But it seems to be failing to read the device descriptor.
And hasn't picked up the vendor ID or product ID (which are contained in the device descriptor)
So this seems to be fairly early on in the process.

I assume that 'read/64' is simply saying that the error occurred during a 64-bit read operation on the device descriptor.


If we look errno.h

On my system, there were several errno.h files.
The file /usr/include/errno.h was not very helpful.
So then I started in /usr/include/asm/errno.h, which simply contained a #include to /usr/include/asm-generic/errno.h

/usr/include/asm-generic/errno.h contains a list of standard error code enumerations, and tells us that error code '62' is enumerated to 'ETIME'
(I don't know if that's what the 'error -62' refers to - but we'll come back to that in a moment).


Kernel Documentation
====================

Again, use the software package manager to check that kernel documentation is installed,
and to check where the files are located.

For me, it's in /usr/src/linux-2.6.37.1-1.2/Documentation,
and there is a 'usb' directory in there.


Of particular interest is:
/usr/src/linux-2.6.37.1-1.2/Documentation/usb/error-codes.txt
which includes the line:

-ETIME (**) No response packet received within the prescribed
bus turn-around time. This error may instead be
reported as -EPROTO or -EILSEQ.


So - if the error code '-62' is 'ETIME' (from errno.h), then it seems that my hardware is not responding to the host packets at all.


Kernel source
=============

Using your software package manager, check that kernel source is installed.
This will also show you where the files are installed.

For me, it's in /usr/src/linux-2.6.37.1-1.2/
and interestingly: /usr/src/linux-2.6.37.1-1.2/drivers/usb/host

where we find the ohci_hcd.c source file.


At this point I went back to the V-USB firmware on my AVR, and got it working.
So I didn't pursue the host-side any further.

Post Reply