Pages: [1]   Go Down
Author Topic: Leonardo USB won't stay connected  (Read 1419 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 1
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have a Leonardo board and was happily uploading sketches, no problem.

Then after one upload (I'm not sure it finished successfully) my leonardo now automatically disconnects from windows (win 7, 64 bit) after about 12 seconds. Too quickly for me to upload another sketch. The COM port comes up, but it's like the device itself crashes and takes down the USB connection with it. (Maybe having a seperate USB processor was a good thing afterall smiley

There was nothing being printed out to the serial port in the sketch so I can't tell if that's working (nothing appears on the serial monitor)

The orange L LED glows up and down as normal after booting (about 10 seconds), then goes blank. A few seconds later the USB disconnects.
The green ON LED stays on. Power is still being supplied down 5v etc (I have a gameduino attached, my code appears not to be executing, though it was the first time non-sample code was uploaded)
Disconnecting everything from the board makes no difference (so it's not to do with the gameduino)

I've tried a couple of other USB ports on my machine, pressing reset just causes it to re-connect to windows... and disconnect again.

Does anyone know if there is something I can debug, some USB logs in windows? some way I can flash the arduino again? (maybe a command line tool might be faster with a very-blank pre-compiled sketch?)
Logged

Offline Offline
Newbie
*
Karma: 1
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Okay, with a bit of luck and good timing, I managed to get blink to compile & upload before it disconnects and the problem has gone away!

Clearly my code did mess up the USB connection in someway...
Logged

California
Offline Offline
God Member
*****
Karma: 13
Posts: 629
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Okay, with a bit of luck and good timing, I managed to get blink to compile & upload before it disconnects and the problem has gone away!

Clearly my code did mess up the USB connection in someway...

Not likely.  If it happens again, try putting a USB Hub in-between the PC and the Leonardo.  It smooths these glitches for me.
Logged


Offline Offline
Newbie
*
Karma: 1
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have boiled my code down to a vague area and can re-create the issue. (Still getting it down to specific code)

Everytime I upload this sketch it causes the issue listed above, and uploading the Blink sketch fixes it again.

I'll try it with a hub inbetween later when I investigate this some more. (and find specific code which is causing this)
Logged

Offline Offline
Newbie
*
Karma: 1
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

FYI, this seems to occur when I have a variable too large on the stack.

In this case 4k/4096 bytes...
Logged

California
Offline Offline
God Member
*****
Karma: 13
Posts: 629
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Well, that would throw a wrench into the upload smiley-wink  At least you have that extra 0.5kb SRAM over the Atmega328 :p

Nice troubleshooting!
Logged


Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hey mine goes off at 5 sec interval not even able to upload the blink sketch!!! What should I do?
Logged

Left Coast, CA (USA)
Online Online
Brattain Member
*****
Karma: 331
Posts: 16499
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

That is one fundamental disadvantage of using a Leonardo type board Vs a standard UNO type board. The Uno uses a separate chip dedicated to just providing the USB serial function, and the sketch runs in the separate 328p chip. So a users sketch cannot cause loss of USB functionality no matter how flawed or crashed the code causes. On the Leonardo board the one and only chip has to perform both the serial USB function as well as executing the users sketch, and if the users sketch has logical errors or crashes due to say using too much SRAM it can prevent the USB function to operate and cause PC USB problems.

I could argue that one should only utilize a Leonardo type board only if the project requires interfacing with a USB slave device. Otherwise certainly beginners are better off utilizing a Uno type board.
Lefty
Logged

Pages: [1]   Go Up
Jump to: