Skip to content

Upload fails after native USB board is disconnected w/ Serial Monitor open #8851

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
per1234 opened this issue May 5, 2019 · 8 comments
Closed
Labels
Component: IDE Serial monitor Tools > Serial Monitor Component: Uploading Uploading programs to an Arduino board Type: Bug Type: Regression Something that used to work and now doesn't

Comments

@per1234
Copy link
Collaborator

per1234 commented May 5, 2019

Arduino IDE Hourly Build 2019/04/18 12:33 / Arduino IDE 1.9.0-beta build 105, Windows 10 64 bit

  1. Plug the USB cable of a native USB (Leonardo, MKR, Due (Native USB Port)) into your computer.
  2. Tools > Serial Monitor
  3. Unplug the USB cable.
  4. Close Serial Monitor (to avoid v1.9b upload fails, must close serial monitor first #8518 when using Arduino IDE 1.9.0-beta).
  5. Plug the USB cable of the board into your computer. It doesn't matter whether this is done before or after closing Serial Monitor.
  6. Sketch > Upload

The upload process completes successfully, but the Arduino IDE doesn't recognize this and after a delay the upload is shown to have failed with the error:

Couldn't find a Board on the selected port. Check that you have the correct port selected.  If it is correct, try pressing the board's reset button after initiating the upload.

You must now exit the Arduino IDE and start it again before you can upload without the spurious failure.

When using Arduino IDE 1.8.9 or the Hourly Build, disconnecting the board while Serial Monitor is open and then reconnecting causes multiple duplicate ports to be shown in the Tools > Port menu. This does not occur with Arduino IDE 1.9.0-beta, but the spurious upload failure still does occur.

Clipboard02

The duplicate ports and spurious upload failure issue does not occur with Arduino IDE 1.8.8.

Originally reported at:

@per1234 per1234 added Type: Bug Type: Regression Something that used to work and now doesn't Component: Uploading Uploading programs to an Arduino board Component: IDE Serial monitor Tools > Serial Monitor labels May 5, 2019
@facchinm
Copy link
Member

facchinm commented May 6, 2019

Hi @per1234 , thanks for reporting here.
This looks like a windows-only bug since I'm unable to reproduce on Linux under any circumstance. I'll take a look later using a VM

@per1234
Copy link
Collaborator Author

per1234 commented May 6, 2019

I just gave it a try on Linux and indeed I could not reproduce the issue. So I think you're right about it being a Windows-only thing.

@GreyArea1966
Copy link

I seem to be having a similar problem with my Trinket M0...
image

  1. It will not automatically recognise when I upload a sketch
  2. IT seems every time the M0 is reset, it bunny hops to a new COM port...IDE will have the old one selected, but in the list is another port detected as having the M0
  3. If I select the new Port (with the M0 attached) and compile, IDE will "hunt" the COM ports but will not detect the new one until the reset switch is pressed on the board. At this point, the sketch uploads, but if I got back into IDE, the board will have "hopped" to the other COM port...leaving this long trail behind it.

@GreyArea1966
Copy link

BY the way - I have not yet used Serial Monitor with these M0 processors as I have only had them a day. This just happens whenever I connect one.

@GreyArea1966
Copy link

Another example...Arduino IDE says M0 connected to COM5....but in dropdown clearly shows on COM7 (albeit multiple times)

image

If I try to upload now...

"processing.app.debug.RunnerException
at cc.arduino.packages.uploaders.SerialUploader.uploadUsingPreferences(SerialUploader.java:152)
at cc.arduino.UploaderUtils.upload(UploaderUtils.java:77)
at processing.app.SketchController.upload(SketchController.java:732)
at processing.app.SketchController.exportApplet(SketchController.java:703)
at processing.app.Editor$UploadHandler.run(Editor.java:2070)
at java.lang.Thread.run(Thread.java:748)
Caused by: processing.app.SerialException: Error touching serial port 'COM5'.
at processing.app.Serial.touchForCDCReset(Serial.java:107)
at cc.arduino.packages.uploaders.SerialUploader.uploadUsingPreferences(SerialUploader.java:136)
... 5 more
Caused by: jssc.SerialPortException: Port name - COM5; Method name - openPort(); Exception type - Port not found.
at jssc.SerialPort.openPort(SerialPort.java:167)
at processing.app.Serial.touchForCDCReset(Serial.java:101)
... 6 more
"

If I select COM7 and upload;

image

Sometimes that process will find the chip itself, others it will fail, or I press reset.

If I try to upload again;

image

Then, one more try, it uploads...but when I go back to IDE Ports list...

image

expecting to hit COM255 by the weekend at this rate!

@GreyArea1966
Copy link

Sorry for many pictures...but I have Parkinsons and typing is difficult...

@facchinm
Copy link
Member

facchinm commented Jul 8, 2019

@per1234 @GreyArea1966 the multiple entries bug gets solved by #8046 (also merged in Beta 107).
About the error on upload after opening the serial port, it is due to Windows caching the previously opened port, so this code path fails

if (uploadResult && doTouch) {
try {
if (waitForUploadPort) {
// For Due/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.
// Reuse waitForUploadPort for this task, but this time we are simply waiting
// for one port to reappear. If no port reappears before the timeout, actualUploadPort is selected
finalUploadPort = waitForUploadPort(actualUploadPort, Serial.list(), false);
}
} catch (InterruptedException ex) {
// noop

It used to fail too before ffba05f but didn't report any error.

I'm wondering if partially reverting that patch could be the right approach. @cmaglie ?

@facchinm facchinm added this to the Release 1.8.10 milestone Jul 8, 2019
facchinm added a commit to facchinm/Arduino that referenced this issue Jul 8, 2019
@facchinm
Copy link
Member

facchinm commented Jul 8, 2019

I just pushed d2f8e15 in PR #8046 to also fix the upload problem.
Can you please test them as soon as @ArduinoBot produces the builds? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: IDE Serial monitor Tools > Serial Monitor Component: Uploading Uploading programs to an Arduino board Type: Bug Type: Regression Something that used to work and now doesn't
Projects
None yet
Development

No branches or pull requests

3 participants