device descriptor read/64, error -62
Posted: Wed Dec 09, 2015 4:48 am
Hello,
I would like to build an USB device using V-USB.
This is what I have done:
1) Download the V-USB package
2) Modify the source code
As you can see, the only differences are that:
- there is a new script for compiling the source code (build.sh)
- there is a new C file containing the main function (main.c)
- there are some generated files (main.elf, main.hex, usbdrvasm.o and usbdrv.o)
- there is a renamed file (usbconfig-prototype.h -> usbconfig.h)
One interesting thing is the difference between the original usbconfig-prototype.h file and the new usbconfig.h file:
An other interesting thing is to see the new C file containing the main function:
3) Compile the source code
4) Update the flash of my attiny2313
5) Update the fuse of my attiny2313
6) Follow the schematics of the V-USB homepage [1]
7) Connect the device to an USB connector of my PC
As you can see there is something wrong.
Any idea what is wrong?
Thank you.
Best regards.
[1] https://www.obdev.at/Images/vusb/circuit-zoomed.gif
I would like to build an USB device using V-USB.
This is what I have done:
1) Download the V-USB package
Code: Select all
$ wget -c https://www.obdev.at/downloads/vusb/vusb-20121206.tar.gz
2) Modify the source code
Code: Select all
$ diff -r vusb-20121206/usbdrv my-usb-device
Only in my-usb-device: build.sh
Only in my-usb-device: main.c
Only in my-usb-device: main.elf
Only in my-usb-device: main.hex
Only in my-usb-device: usbconfig.h
Only in vusb-20121206/usbdrv: usbconfig-prototype.h
Only in my-usb-device: usbdrvasm.o
Only in my-usb-device: usbdrv.o
As you can see, the only differences are that:
- there is a new script for compiling the source code (build.sh)
- there is a new C file containing the main function (main.c)
- there are some generated files (main.elf, main.hex, usbdrvasm.o and usbdrv.o)
- there is a renamed file (usbconfig-prototype.h -> usbconfig.h)
One interesting thing is the difference between the original usbconfig-prototype.h file and the new usbconfig.h file:
Code: Select all
$ diff vusb-20121206/usbdrv/usbconfig-prototype.h my-usb-device/usbconfig.h
32c32
< #define USB_CFG_DMINUS_BIT 4
---
> #define USB_CFG_DMINUS_BIT 3
An other interesting thing is to see the new C file containing the main function:
Code: Select all
$ cat my-usb-device/main.c
#include <util/delay.h> /* for _delay_ms */
#include <avr/interrupt.h> /* for sei */
#include "usbdrv.h" /* for usbMsgLen_t */
/* This function is called when the host sends or receives a control message on endpoint 0 */
usbMsgLen_t usbFunctionSetup(uchar setupData[8])
{
usbRequest_t *rq = (void *) setupData;
switch(rq->bRequest)
{
case 1:
/* Turn LED on */
PORTB |= 1;
break;
case 2:
/* Turn LED off */
PORTB &= ~1;
break;
}
return 0;
}
/* The main function */
void main()
{
/* Enforce (re-)enumeration of the device */
usbDeviceDisconnect();
_delay_ms(100);
usbDeviceConnect();
/* Initialize the driver */
usbInit();
/* Enable interrupts */
sei();
/* Main loop */
while(1)
{
usbPoll();
}
}
3) Compile the source code
Code: Select all
$ avr-gcc -mmcu=atmega8 -Os -DF_CPU=12000000 -c usbdrvasm.S
$ avr-gcc -mmcu=atmega8 -Os -DF_CPU=12000000 -c usbdrv.c
$ avr-gcc -mmcu=atmega8 -Os -DF_CPU=12000000 main.c usbdrv.o usbdrvasm.o -o main.elf
$ avr-objcopy -j .text -j .data -O ihex main.elf main.hex
4) Update the flash of my attiny2313
Code: Select all
$ sudo avrdude -p t2313 -c usbasp -U flash:w:main.hex
5) Update the fuse of my attiny2313
Code: Select all
$ sudo avrdude -p t2313 -c usbasp -U lfuse:w:0xef:m
6) Follow the schematics of the V-USB homepage [1]
7) Connect the device to an USB connector of my PC
Code: Select all
$ sudo dmesg
[...]
[59014.200804] usb 5-2: new low-speed USB device number 6 using ohci-pci
[59014.328847] usb 5-2: device descriptor read/64, error -62
[59014.557867] usb 5-2: device descriptor read/64, error -62
As you can see there is something wrong.
Any idea what is wrong?
Thank you.
Best regards.
[1] https://www.obdev.at/Images/vusb/circuit-zoomed.gif