ezieragabriel / arduino

Automatically exported from code.google.com/p/arduino
Other
0 stars 0 forks source link

Leonardo upload failures #1033

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Uploading sketches to Leonardo can fail, due to timing interaction of the USB 
code on the Leonardo, and the host systems USB device enumeration and 
initialization.

The sequence where the Leonardo is reset, comes up running USB code, gets 
enumerated, uploads the sketch, restarts to run the sketch (including 
restarting the USB code) can cause assorted problems depending on the exact 
timing and other (unknown) dependencies.

One symptom is that the sketch can show up running on a different com port than 
the port on which the upload occurred.

See also http://code.google.com/p/arduino/issues/detail?id=650

I don't know if this is a solvable problem; I created this issue primarily to 
document the problem in a more official spot than the forums.
http://arduino.cc/forum/index.php/topic,110103.0.html
http://arduino.cc/forum/index.php/topic,120512.0.html

Original issue reported on code.google.com by wes...@gmail.com on 4 Sep 2012 at 10:48

GoogleCodeExporter commented 9 years ago
The Leonardo upload process is certainly tricky and fragile, so I can imagine 
it's possible for it to break but I didn't really see any specific examples of 
problem cases in the posts you link to. Are there particular situations you've 
seen or read about that we should be working on?

Also, the sketch and the bootloader will almost certainly appear as different 
COM ports on Windows. That shouldn't be a problem; in fact, the IDE looks for 
any new COM port (i.e. the bootloader) to appear, not necessarily the one that 
just disappeared (the sketch).

Original comment by dmel...@gmail.com on 5 Sep 2012 at 3:08

GoogleCodeExporter commented 9 years ago

Original comment by dmel...@gmail.com on 5 Sep 2012 at 2:17

GoogleCodeExporter commented 9 years ago
I have an example that will cause the Leonardo not to receive an upload but 
it's not for the reasons the OP talks about.  (See the linked post below for 
more information.)

http://arduino.cc/forum/index.php/topic,141812.0.html

Original comment by mkwi...@gmail.com on 9 Jan 2013 at 8:54

GoogleCodeExporter commented 9 years ago
I've been investigating this issue for some time and have found a possible 
solution, at least for the errors I was seeing on my Mac Pro system running 
Ardino 1.04.  The problem I had was that the upload process to a Leonarado 
board would frequently fail while displaying one, of two possible errors 
messages.  One failure message was:

processing.app.SerialException: Serial port '/dev/tty.usbmodemfd111' already in 
use. Try quitting any programs that may be using it.
at processing.app.Serial.touchPort(Serial.java:123)
at 
processing.app.debug.AvrdudeUploader.uploadViaBootloader(AvrdudeUploader.java:20
1)
at 
processing.app.debug.AvrdudeUploader.uploadUsingPreferences(AvrdudeUploader.java
:67)
at processing.app.Sketch.upload(Sketch.java:1671)
at processing.app.Sketch.exportApplet(Sketch.java:1627)
at processing.app.Sketch.exportApplet(Sketch.java:1599)
at processing.app.Editor$DefaultExportHandler.run(Editor.java:2380)
at java.lang.Thread.run(Thread.java:680)
Caused by: gnu.io.PortInUseException: Unknown Application
at gnu.io.CommPortIdentifier.open(CommPortIdentifier.java:354)
at processing.app.Serial.touchPort(Serial.java:113)
... 7 more

the other possible error was:

processing.app.SerialException: Error touching serial port 
'/dev/tty.usbmodemfd111'.
at processing.app.Serial.touchPort(Serial.java:126)
at 
processing.app.debug.AvrdudeUploader.uploadViaBootloader(AvrdudeUploader.java:20
1)
at 
processing.app.debug.AvrdudeUploader.uploadUsingPreferences(AvrdudeUploader.java
:67)
at processing.app.Sketch.upload(Sketch.java:1671)
at processing.app.Sketch.exportApplet(Sketch.java:1627)
at processing.app.Sketch.exportApplet(Sketch.java:1599)
at processing.app.Editor$DefaultExportHandler.run(Editor.java:2380)
at java.lang.Thread.run(Thread.java:680)
Caused by: gnu.io.UnsupportedCommOperationException: Invalid Parameter
at gnu.io.RXTXPort.setSerialPortParams(RXTXPort.java:171)
at processing.app.Serial.touchPort(Serial.java:116)
... 7 more

Both errors seemed to happen on the 2nd call to Serial.touchPort() and the 
"error" didn't seem to correspond with an actual problem with the upload, as 
the code changes sent to the Leonardo always seemed to take effect.  In 
addition, the incidence of occurence seemed to increase when the Leonard was 
plugged into a hub rather than directly into a USB port on my MacPro.  This led 
me to suspect that timing was a factor in this issue.  Eventually, I noticed 
this bit of code in the AvrdudeUploader.java file:

    // For Leonardo wait until the bootloader serial port disconnects and the sketch serial
    // port reconnects (or timeout after a few seconds if the sketch port never comes back).
    // Doing this saves users from accidentally opening Serial Monitor on the soon-to-be-orphaned
    // bootloader port.
    if (true == avrdudeResult && boardPreferences.get("bootloader.path") != null &&
        (boardPreferences.get("bootloader.path").equals("caterina") ||
         boardPreferences.get("bootloader.path").equals("caterina-LilyPadUSB"))) {
      try {
        Thread.sleep(500);
      } catch (InterruptedException ex) { }

On a hunch, I tried increasing the delay on the Thread.sleep() call from 500 to 
1000 and, at least for me, this seemed to "fix" the problem.  I can't say that 
this is a complete solution, as the timing may still vary due to factors I have 
not identified, but I think this chaneg may be worth considering.

Wayne

Original comment by wayne.ho...@gmail.com on 26 Apr 2013 at 3:49

GoogleCodeExporter commented 9 years ago
I didn't read everything on here, maybe it was posted already sorry if it was. 

On MAC OS X 10.8.3  running IDE 1.05 I found that changing the baud rate for 
the SERIAL MONITOR to the 300 rate the issue goes away completely. the issue 
being:

"
processing.app.SerialException: Serial port '/dev/tty.usbmodemfd111' already in 
use. Try quitting any programs that may be using it.
at processing.app.Serial.touchPort(Serial.java:123)

"

Original comment by kuw...@oxy.edu on 18 Jun 2013 at 10:58