I have built some circuits that interface with computer USB ports. On several occasions, I had built the circuits but for whatever reason they did not seem to work. Since most USB firmware is rather complex in nature, it is usually useful to first identify whether the issue at hand is related to hardware or software.
If you are using Linux, whether the hardware is working correctly can be easily identified. I recently was building a PIC USB device using PIC18F2550, and after I completed the circuit and successfully loaded the firmware I connected it to the USB port. But nothing happened. So I needed to find out what was going on. Basically there are three likely scenarios:
- The chip was damaged during assembling.
- Wiring problems
- USB firmware problems
Since I did not have a spare PIC18F2550 on hand, I could not have just swapped out the chip and ruled out whether the chip itself was faulty. So any of the three scenarios was possible at that point.
To further diagnose the problem, I typed the following command right before and right after I plugged in the USB device:
dmesg | grep usb
And right after I plugged in the USB device, I saw the following new entries in the dmesg output:
[ 7143.471263] usb 3-2: new low speed USB device using uhci_hcd and address 112
[ 7143.600009] usb 3-2: device descriptor read/64, error -71
[ 7143.840010] usb 3-2: device descriptor read/64, error -71
[ 7144.070009] usb 3-2: new low speed USB device using uhci_hcd and address 113
[ 7144.211258] usb 3-2: device descriptor read/64, error -71
[ 7144.450006] usb 3-2: device descriptor read/64, error -71
[ 7144.680007] usb 3-2: new low speed USB device using uhci_hcd and address 114
[ 7145.100005] usb 3-2: device not accepting address 114, error -71
[ 7145.220007] usb 3-2: new low speed USB device using uhci_hcd and address 115
[ 7145.640006] usb 3-2: device not accepting address 115, error -71
I saw similar error message before and from my past experience, this message suggested that the most likely problem was that I had the D+ and D- pin connections swapped. So I double-checked the pin connections, and sure enough, I had those two pins connected wrong. After I corrected the connections, I ran dmesg again and this time the output looked like this:
[13337.953762] usb 3-2: new full speed USB device using uhci_hcd and address 124
[13338.144246] usb 3-2: configuration #1 chosen from 1 choice
The above dmesg output suggests that the USB communication had been established successfully. To further confirm this, I ran lsusb and saw the following entry:
Bus 003 Device 002: ID 04d8:000e Microchip Technology, Inc.
So it reaffirmed that pin connection was indeed the issue. And after I resolved the D+/D- connection issue, the circuit worked beautifully.