<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-gb">
	<link rel="self" type="application/atom+xml" href="https://forums.obdev.at/app.php/feed/topic/10168" />

	<title>Objective Development Forums</title>
	
	<link href="https://forums.obdev.at/index.php" />
	<updated>2015-12-09T04:48:43+02:00</updated>

	<author><name><![CDATA[Objective Development Forums]]></name></author>
	<id>https://forums.obdev.at/app.php/feed/topic/10168</id>

		<entry>
		<author><name><![CDATA[YuGiOhJCJ]]></name></author>
		<updated>2015-12-09T04:48:43+02:00</updated>

		<published>2015-12-09T04:48:43+02:00</published>
		<id>https://forums.obdev.at/viewtopic.php?t=10168&amp;p=30597#p30597</id>
		<link href="https://forums.obdev.at/viewtopic.php?t=10168&amp;p=30597#p30597"/>
		<title type="html"><![CDATA[device descriptor read/64, error -62]]></title>

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