Gentoo Archives: gentoo-user

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

Replies