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

Replies