Skip to content
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

Uploads to native USB boards fail when Serial Monitor or Plotter is open #1032

Closed
3 tasks done
per1234 opened this issue Jun 9, 2022 · 0 comments · Fixed by #1040
Closed
3 tasks done

Uploads to native USB boards fail when Serial Monitor or Plotter is open #1032

per1234 opened this issue Jun 9, 2022 · 0 comments · Fixed by #1040
Assignees
Labels
conclusion: resolved Issue was resolved topic: code Related to content of the project itself topic: serial monitor Related to the Serial Monitor type: imperfection Perceived defect in any part of project

Comments

@per1234
Copy link
Contributor

per1234 commented Jun 9, 2022

Describe the problem

Because the USB communication with the user's computer is handled directly by the primary microcontroller (rather than a separate chip as on the Uno, Mega, etc.), a special process is used when uploading to the native USB boards:

  1. IDE (actually Arduino CLI under the hood) momentarily opens a serial connection to the board (AKA "touch") at 1200 bps as a signal to the board that it should go into bootloader mode.
  2. Board switches from application into bootloader mode, which causes its CDC serial port to disappear for a short time.
  3. IDE waits for a new port to appear.
    This port (which might be different from the one the board had previously) will be used for the upload.
  4. If no new port appears after some time, the IDE proceeds. The port the board had previously will be used for the upload.
  5. IDE uploads the sketch to the board

🐛 If Serial Monitor or Serial Plotter is open during the upload, the "1200 bps touch" does not go through, the board stays in application mode, the IDE never sees the new port appear, the IDE attempts to upload to the board which does not have the bootloader running, the upload fails.

To reproduce

Equipment

Any native USB type Arduino board. Including:

  • Leonardo
  • Micro
  • Yun, Yun Rev2
  • MKR
  • Nano 33 IoT
  • Zero (use the "Native USB" port)
  • Portenta H7
  • Nano 33 BLE
  • Nano 33 RP2040
  • Due (use either port)
  • 101

Steps

  1. Connect the board to your computer.
  2. Select the board and port in the Arduino IDE.
  3. Open the Serial Monitor view.
  4. Attempt to upload a sketch to the board.

🐛 The upload fails.

If you have Show verbose output during > ☐ upload enabled in the IDE preferences, you will see something like this in the Output panel:

Performing 1200-bps touch reset on serial port COM31
Waiting for upload port...
No upload port found, using address:"COM31" label:"COM31" protocol:"serial" protocol_label:"Serial Port (USB)" as fallback

Expected behavior

Serial Monitor does not interfere with uploads.

Arduino IDE version

2.0.0-rc7

Operating system

Windows

Operating system version

10

Additional context

I have not been able to reproduce this on my Linux machine, so it may be Windows-specific.


I bisected the issue to df8658e (does not occur when using the build for 4c55807).


The issue also affects the Nano Every. Even though this is not a native USB board, it still uses the "1200 bps touch" feature.


Uploading works fine once I close the Serial Monitor view.


Uploading does succeed with Serial Monitor open if I manually put the board into bootloader mode before the upload (e.g., press the reset button twice on most boards).


Arduino IDE 1.x handles uploading under these conditions as expected.

Issue checklist

  • I searched for previous reports in the issue tracker
  • I verified the problem still occurs when using the latest nightly build
  • My report contains all necessary details
@per1234 per1234 added topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project labels Jun 9, 2022
@per1234 per1234 changed the title Uploads to native USB boards fail when Serial Monitor is open Uploads to native USB boards fail when Serial Monitor or Plotter is open Jun 9, 2022
@per1234 per1234 added the topic: serial monitor Related to the Serial Monitor label Jun 10, 2022
@davegarthsimpson davegarthsimpson linked a pull request Jun 13, 2022 that will close this issue
4 tasks
davegarthsimpson added a commit that referenced this issue Jun 22, 2022
* 1032 failing upload flag for monitor mgr

* move upload failure fix logic to frontend

* misc corrections

* avoid starting monitor when upload is in progress

* avoid starting monitor when upload is in progress

* prevent monitor side effects on upload (WIP)

* send upload req after notifying mgr

* dispose instead of pause on upld (code not final)

* Revert "dispose instead of pause on upld (code not final)"

This reverts commit 2d5dff2.

* force wait before upload (test)

* always start queued services after uplaod finishes

* test cli with monitor close delay

* clean up unnecessary await(s)

* remove unused dependency

* revert CLI to 0.23

* use master cli for testing, await in upload finish

* remove upload port from pending monitor requests

* fix startQueuedServices

* refinements queued monitors

* clean up monitor mgr state

* fix typo from prev cleanup

* avoid dupl queued monitor services

* variable name changes

* reference latest cli commit in package.json

Co-authored-by: Alberto Iannaccone <[email protected]>
@per1234 per1234 added the conclusion: resolved Issue was resolved label Jun 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
conclusion: resolved Issue was resolved topic: code Related to content of the project itself topic: serial monitor Related to the Serial Monitor type: imperfection Perceived defect in any part of project
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants