Gentoo Archives: gentoo-user

From: tuxic@××××××.de
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] USB device (ATtiny86 w. mcronucleus bootloader) not recognized ?
Date: Mon, 07 Aug 2017 15:51:41
Message-Id: 20170807155119.njezo33giyg7ae7d@solfire
In Reply to: Re: [gentoo-user] USB device (ATtiny86 w. mcronucleus bootloader) not recognized ? by R0b0t1
1 On 08/07 08:48, R0b0t1 wrote:
2 > On Mon, Aug 7, 2017 at 4:29 AM, Stefan Mark <mark@××××××××.de> wrote:
3 > > On Sun, 6 Aug 2017 19:04:09 -0500
4 > > R0b0t1 <r030t1@×××××.com> wrote:
5 > >
6 > >> On Sun, Aug 6, 2017 at 11:50 AM, <tuxic@××××××.de> wrote:
7 > >> > When I plug in such a little board into my PC, demesg
8 > >> > reports:
9 > >> > [ 1429.834140] usb 7-4: new low-speed USB device number 15 using
10 > >> > ohci-pci [ 1429.965142] usb 7-4: device descriptor read/64, error
11 > >> > -62 [ 1430.203151] usb 7-4: device descriptor read/64, error -62
12 > >> > [ 1430.438161] usb 7-4: new low-speed USB device number 16 using
13 > >> > ohci-pci [ 1430.569151] usb 7-4: device descriptor read/64, error
14 > >> > -62 [ 1430.803174] usb 7-4: device descriptor read/64, error -62
15 > >> > [ 1431.038184] usb 7-4: new low-speed USB device number 17 using
16 > >> > ohci-pci [ 1431.456157] usb 7-4: device not accepting address 17,
17 > >> > error -62 [ 1431.582204] usb 7-4: new low-speed USB device number
18 > >> > 18 using ohci-pci [ 1432.000209] usb 7-4: device not accepting
19 > >> > address 18, error -62 [ 1432.000244] usb usb7-port4: unable to
20 > >> > enumerate USB device
21 > >>
22 > >> >
23 > >> > My first thought was: The micronucleus bootloaed is missing or
24 > >> > is defective...
25 > >> >
26 > >> > But plugging in the board into my Android tablet (the tablet runs
27 > >> > Lollipop and is nothing special at all beside being rooted) via
28 > >> > an OTG cable and using lsusb after that, it shows
29 > >> > Bus 001 Device 003 ID 16d0:0753 MCS Digistump DigiSpark
30 > >> >
31 > >>
32 > >> What the dmesg output is saying is that your USB hardware has reported
33 > >> a communication error to the driver. It is my guess that the ATtiny85
34 > >> is not meeting the timing requirements for USB.
35 > >>
36 > >> Looking at the board there does not seem to be a crystal oscillator
37 > >> which most people would consider necessary for doing USB
38 > >> communication. This is an oversight on DigiStump's part and it is very
39 > >> likely you will not be able to fix the communication issues. You
40 > >> should contact them and tell them that your computer will not
41 > >> recognize their device and that you suspect it is because the clock is
42 > >> too inaccurate.
43 > >>
44 > >> >
45 > >> > What can I do to make this Digispark being correctly recognized?
46 > >> >
47 > >> > Thank you VERY much for any help in advance!
48 > >> >
49 > >>
50 > >> Three things:
51 > >>
52 > >> 1) Return the one you bought and get a new one. The ATtiny85's
53 > >> internal oscillator might be at the end of the bell curve but within
54 > >> manufacturer tolerance, which isn't enough to produce a USB signal
55 > >> close enough to the specified frequency. Expect the seller to pay for
56 > >> return shipping.
57 > >>
58 > >> 2) You can calibrate the oscillator using instructions in this
59 > >> application note:
60 > >> http://www.atmel.com/Images/Atmel-2555-Internal-RC-Oscillator-Calibration-for-tinyAVR-and-megaAVR-Devices_ApplicationNote_AVR053.pdf.
61 > >> This process still might not get you close enough.
62 > >>
63 > >> 3) Add a crystal oscillator to the ATtiny85 and change its fuses to
64 > >> use the oscillator. You will need to recompile the firmware if the
65 > >> crystal is a different frequency from the internal oscillator.
66 > >>
67 > >> It might work on your phone and not your desktop because of
68 > >> differences in the USB hardware (your phone's serial decoder in the
69 > >> USB hardware performs clock recovery but your PC does not) or because
70 > >> there are multiple things on a USB hub in your PC and the ATtiny85 is
71 > >> less accurate than those already present devices. Admittedly I'm
72 > >> surprised it gets most of the way to registering as a device and then
73 > >> fails, but I don't think the problem is with the drivers or your
74 > >> kernel.
75 > > USB uses a variant of non-return-to-zero for clock synchronisation,
76 > > that should™ take care of timing issues.
77 > > Actually, using microcontrollers without crystal for soft-usb is fairly
78 > > common (i have a bunch myself). As far as i understand (but im no
79 > > expert), trouble usually arises more from the improvised level shifters
80 > > than timing issues.
81 > > Anyway, i neither think there is a driver problem, i had a fair bit of
82 > > the messages myself, usually fixed by fixing the level shifter.
83 >
84 > An NRZ signal is part of the reason USB is so finicky. With USB the
85 > clock has to be within some tolerance of the bus speed (the
86 > justification being that there are multiple devices on the bus that
87 > need to read the bus at all times) and this is fairly inflexible. With
88 > other protocols, like most USART transceivers, the hardware can
89 > recover the sender's frequency and compensate if it is wrong.
90 >
91 > The level shifters might be causing timing problems, seeing as some
92 > hardware does recognize the ATtiny85 and the levels might be right. It
93 > seems less likely that a voltage difference would be OK between two
94 > pieces of hardware to me.
95 >
96 > There's a lot of old advice related to microcontrollers that says you
97 > need to use crystals when you actually don't with modern parts, so I
98 > think it reasonable that your advice will work. I hope Meino gets back
99 > to us.
100 >
101
102 I think any modifications on that board is beyond my scope of
103 abilities regarding soldering a clearly seeing what I doing there...
104 these SMD thingies are THAT tiny that I fear to inhale that stuff...
105 than I will be part of the resistance... ;)
106
107 I ordered a similiar board yesterday, with a more reasonable setup:
108 ATmega32u4 and a attached sdcard slot for the flash memory.
109 The ATmega32u4 has a fully fledged USB 2.0 stack (is it called a "stack"?)
110 and does not bitbang the whole stuff but "talks USB natively".
111 I have gathered some hope so far, that this thingy will
112 a) work with USB < 3.0
113 b) is more stable and more versatile
114
115 Cheers
116 Meino