Gentoo Archives: gentoo-user

From: Stefan Mark <mark@××××××××.de>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] USB device (ATtiny86 w. mcronucleus bootloader) not recognized ?
Date: Tue, 08 Aug 2017 08:35:34
Message-Id: 20170808103502.3990c103@vdhh-linux
In Reply to: Re: [gentoo-user] USB device (ATtiny86 w. mcronucleus bootloader) not recognized ? by R0b0t1
1 On Mon, 7 Aug 2017 12:10:30 -0500
2 R0b0t1 <r030t1@×××××.com> wrote:
3
4 > On Mon, Aug 7, 2017 at 11:29 AM, Stefan Mark <mark@××××××××.de> wrote:
5 > > On Mon, 7 Aug 2017 08:48:50 -0500
6 > > R0b0t1 <r030t1@×××××.com> wrote:
7 > >
8 > >> On Mon, Aug 7, 2017 at 4:29 AM, Stefan Mark <mark@××××××××.de>
9 > >> wrote:
10 > >> > On Sun, 6 Aug 2017 19:04:09 -0500
11 > >> > R0b0t1 <r030t1@×××××.com> wrote:
12 > >> >
13 > >> >> On Sun, Aug 6, 2017 at 11:50 AM, <tuxic@××××××.de> wrote:
14 > >> >> > When I plug in such a little board into my PC, demesg
15 > >> >> > reports:
16 > >> >> > [ 1429.834140] usb 7-4: new low-speed USB device number 15
17 > >> >> > using ohci-pci [ 1429.965142] usb 7-4: device descriptor
18 > >> >> > read/64, error -62 [ 1430.203151] usb 7-4: device descriptor
19 > >> >> > read/64, error -62 [ 1430.438161] usb 7-4: new low-speed USB
20 > >> >> > device number 16 using ohci-pci [ 1430.569151] usb 7-4:
21 > >> >> > device descriptor read/64, error -62 [ 1430.803174] usb 7-4:
22 > >> >> > device descriptor read/64, error -62 [ 1431.038184] usb 7-4:
23 > >> >> > new low-speed USB device number 17 using ohci-pci
24 > >> >> > [ 1431.456157] usb 7-4: device not accepting address 17,
25 > >> >> > error -62 [ 1431.582204] usb 7-4: new low-speed USB device
26 > >> >> > number 18 using ohci-pci [ 1432.000209] usb 7-4: device not
27 > >> >> > accepting address 18, error -62 [ 1432.000244] usb
28 > >> >> > usb7-port4: unable to enumerate USB device
29 > >> >>
30 > >> >> >
31 > >> >> > My first thought was: The micronucleus bootloaed is missing or
32 > >> >> > is defective...
33 > >> >> >
34 > >> >> > But plugging in the board into my Android tablet (the tablet
35 > >> >> > runs Lollipop and is nothing special at all beside being
36 > >> >> > rooted) via an OTG cable and using lsusb after that, it shows
37 > >> >> > Bus 001 Device 003 ID 16d0:0753 MCS Digistump DigiSpark
38 > >> >> >
39 > >> >>
40 > >> >> What the dmesg output is saying is that your USB hardware has
41 > >> >> reported a communication error to the driver. It is my guess
42 > >> >> that the ATtiny85 is not meeting the timing requirements for
43 > >> >> USB.
44 > >> >>
45 > >> >> Looking at the board there does not seem to be a crystal
46 > >> >> oscillator which most people would consider necessary for doing
47 > >> >> USB communication. This is an oversight on DigiStump's part and
48 > >> >> it is very likely you will not be able to fix the communication
49 > >> >> issues. You should contact them and tell them that your
50 > >> >> computer will not recognize their device and that you suspect
51 > >> >> it is because the clock is too inaccurate.
52 > >> >>
53 > >> >> >
54 > >> >> > What can I do to make this Digispark being correctly
55 > >> >> > recognized?
56 > >> >> >
57 > >> >> > Thank you VERY much for any help in advance!
58 > >> >> >
59 > >> >>
60 > >> >> Three things:
61 > >> >>
62 > >> >> 1) Return the one you bought and get a new one. The ATtiny85's
63 > >> >> internal oscillator might be at the end of the bell curve but
64 > >> >> within manufacturer tolerance, which isn't enough to produce a
65 > >> >> USB signal close enough to the specified frequency. Expect the
66 > >> >> seller to pay for return shipping.
67 > >> >>
68 > >> >> 2) You can calibrate the oscillator using instructions in this
69 > >> >> application note:
70 > >> >> http://www.atmel.com/Images/Atmel-2555-Internal-RC-Oscillator-Calibration-for-tinyAVR-and-megaAVR-Devices_ApplicationNote_AVR053.pdf.
71 > >> >> This process still might not get you close enough.
72 > >> >>
73 > >> >> 3) Add a crystal oscillator to the ATtiny85 and change its
74 > >> >> fuses to use the oscillator. You will need to recompile the
75 > >> >> firmware if the crystal is a different frequency from the
76 > >> >> internal oscillator.
77 > >> >>
78 > >> >> It might work on your phone and not your desktop because of
79 > >> >> differences in the USB hardware (your phone's serial decoder in
80 > >> >> the USB hardware performs clock recovery but your PC does not)
81 > >> >> or because there are multiple things on a USB hub in your PC
82 > >> >> and the ATtiny85 is less accurate than those already present
83 > >> >> devices. Admittedly I'm surprised it gets most of the way to
84 > >> >> registering as a device and then fails, but I don't think the
85 > >> >> problem is with the drivers or your kernel.
86 > >> > USB uses a variant of non-return-to-zero for clock
87 > >> > synchronisation, that should™ take care of timing issues.
88 > >> > Actually, using microcontrollers without crystal for soft-usb is
89 > >> > fairly common (i have a bunch myself). As far as i understand
90 > >> > (but im no expert), trouble usually arises more from the
91 > >> > improvised level shifters than timing issues.
92 > >> > Anyway, i neither think there is a driver problem, i had a fair
93 > >> > bit of the messages myself, usually fixed by fixing the level
94 > >> > shifter.
95 > >>
96 > >> An NRZ signal is part of the reason USB is so finicky. With USB the
97 > >> clock has to be within some tolerance of the bus speed (the
98 > >> justification being that there are multiple devices on the bus that
99 > >> need to read the bus at all times) and this is fairly inflexible.
100 > >> With other protocols, like most USART transceivers, the hardware
101 > >> can recover the sender's frequency and compensate if it is wrong.
102 > > As far as i had understand it, the idea of NRZ is to compensate
103 > > minor drifts between the two clocks. If not that, what its then for?
104 > > Strangely, i had often trouble with uart when i dont used crystal.
105 > > The connection always failed after a while. Never had that with
106 > > vusb.
107 >
108 > NRZ just means that every time period of your signal indicates a
109 > value. You don't spend any time resting between bits. Because you
110 > don't spend any time resting and every time period contains a value,
111 > you need to have an accurate clock to read the data from the signal.
112 Yes, but USB uses a variant ("Non-return-to-zero space") where every n
113 Bits (6 for USB) a Zero (Level change) is inserted to synchronize
114 clocks. At least thats what the Wikipedia says.
115
116 > I can usually get a crystalless UART to work at room temperature in a
117 > habitable room. That isn't really enough for me to assume it would
118 > work anywhere else. I think you are seeing problems with your serial
119 > communication because you are doing more of it and it contains no
120 > built in error correction. I expect VUSB retries failed packets, and
121 > USB packets are themselves very short.
122 Might just be that the connection is not used most of the time. Maybe i
123 can even fix it if i send some data every few seconds. Damn, never
124 thought about it that way oO
125
126 > >> The level shifters might be causing timing problems, seeing as some
127 > >> hardware does recognize the ATtiny85 and the levels might be
128 > >> right. It seems less likely that a voltage difference would be OK
129 > >> between two pieces of hardware to me.
130 > >>
131 > >> There's a lot of old advice related to microcontrollers that says
132 > >> you need to use crystals when you actually don't with modern
133 > >> parts, so I think it reasonable that your advice will work. I hope
134 > >> Meino gets back to us.
135 > >>
136 > > I have build (or helped building) at least 20 littlewires
137 > > (attiny85 based, no crystal). They work :)
138 >
139 > As above, this isn't really enough to assume that this works in
140 > general. Circuits usually work at room temperature. USB, even low
141 > speed USB, is a very technically demanding specification to implement
142 > because of the timing requirements (the specification being nearly
143 > incomprehensible is a separate matter). There's very little reason you
144 > can't theoretically make an RC network accurate enough to do USB
145 > communication, but typically, cheap microcontrollers are made on
146 > cheaper, larger, and less accurate IC processes that have looser
147 > tolerances.
148 >
149 No, didnt meant to. But it usually works under "common" circumstances.
150 Wouldnt recommend it for production use :D