Skip to content

Port changes on native USB upload when two ports are associated with the selected board name #710

Closed
@per1234

Description

@per1234

Describe the bug

Some Arduino boards have native USB capability which allows the primary microcontroller to produce a CDC serial port over which sketches are uploaded. The upload process for these boards goes like so:

  1. Arduino IDE signals the board to run the bootloader.
  2. Sketch program stops, which kills the CDC serial port it produces.
  3. Bootloader program starts, which produces another CDC serial port.
  4. Upload happens.
  5. Bootloader program stops, which kills the CDC serial port it produces.
  6. Sketch program starts, which produces another CDC serial port.

During this process, the port disappears and reappears. This causes the IDE to select the wrong port if any other ports have been associated with the currently selected board name .

The obvious way that multiple ports might be associated with the same board name is having multiple boards of the same model connected to your computer. However, it occurs even with a single board simply by selecting the wrong port once.

To Reproduce

You will need:

  • Arduino board with native USB capability (e.g., Leonardo, MKR, Nano 33 BLE)
  • An additional serial port on your computer. This could be an internal built-in port (i.e., COM1), a spare Arduino board connected to your computer, or any other device that produces a port (e.g., FTDI adapter).
  1. Select the additional serial port from the Tools > Port menu in the Arduino IDE.
  2. Select your native USB board from the Tools > Board menu in the Arduino IDE.
    You have now associated the selected port with this board name.
  3. Select the real port of your native USB board from the Tools > Port menu in the Arduino IDE.
  4. Select Sketch > Upload from the Arduino IDE menus.

🐛 The port selection will now switch to the port that was selected in step (1).

Note: The above instructions use Tools > ... menu paths for the sake of clarity. The issue also occurs when using the board/port selection dropdown menu and the "Select other board and port..." dialog.

Expected behavior

Retain the port I selected.

Desktop

  • OS: Windows 10
  • Version: 2.0.0-rc2-snapshot.c064673
    Date: 2021-12-15T09:32:43.552Z
    CLI Version: 0.20.2 [13783819]

Additional context

The tried and true established approach used by the classic Arduino IDE handles this just fine. So its behavior can serve as a reference for the solution.


There are several other issues related to the IDE not correctly handling the port selection:


The issue also occurs on pressing the reset button instead of doing a full upload.


Originally reported at https://forum.arduino.cc/t/each-day-a-new-problem/937997

Also reported at:

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions