I'm using the Arduino IDE 2.0 beta rc9.2 with an Adafruit Metro ESP32-S2. Overall it works well, but for one frustrating bug.
There are two board/port combos available in the dropdown at the top of the window: /dev/cu.Bluetooth-Incoming-Port
and /dev/cu.usbmodem1101
. That's true in the classic IDE as well. I want cu.usbmodem1101
. In the classic IDE, when I select it and then upload my sketch, it remains selected (e.g., if I upload again it works). But in 2.0, after every upload it resets to cu.Bluetooth-Incoming-Port
(e.g., I have to switch ports before uploading again).
Is this a known issue? Is there a workaround? Thanks!
Hi @dfeldman . This is a known issue:
opened 02:10PM - 21 Dec 21 UTC
closed 10:31AM - 24 Aug 22 UTC
conclusion: resolved
topic: code
type: imperfection
## Describe the bug
Some Arduino boards have native USB capability which allo… ws 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.
1. Sketch program stops, which kills the CDC serial port it produces.
1. Bootloader program starts, which produces another CDC serial port.
1. Upload happens.
1. Bootloader program stops, which kills the CDC serial port it produces.
1. 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.
1. 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.
1. Select the real port of your native USB board from the **Tools > Port** menu in the Arduino IDE.
1. Select **Sketch > Upload** from the Arduino IDE menus.
:bug: 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:
- https://github.com/arduino/arduino-ide/issues/43
- https://github.com/arduino/arduino-ide/issues/82
- https://github.com/arduino/arduino-ide/issues/180
- https://github.com/arduino/arduino-ide/issues/287
---
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:
- https://forum.arduino.cc/t/port-keeps-switching-after-upload/1024611
opened 09:44AM - 06 Mar 21 UTC
closed 10:31AM - 24 Aug 22 UTC
conclusion: resolved
topic: code
type: imperfection
criticality: medium
**Describe the bug**
I accidentally selected the wrong com port (Bluetooth) not… it always defaults to that com port. After every time it disconnects usb and reconnect it ignores the last working version and defaults to the incorrect one probably because it is a lower com port number. Also couldn't find a way to purge the list so it stops happening.
**To Reproduce**
Steps to reproduce the behavior:
1. create any com port that is not an arduino (like bluetooth)
2. select it with a board
3. Now connect a real arduino with a com port that is a larger number
4. Each time you disconnect it will go back to wrong com port.
**Expected behavior**
It will select the last working connection if it is available not the first one. Should also be an easy way to purge the saved combinations.
**Screenshots**

**Desktop (please complete the following information):**
- Windows 10
**Additional context**
I constantly find it has failed to upload only to see it has reverted back again.
The developers are working on a fix right now:
arduino:main
← arduino:180-board-selection
opened 12:59PM - 16 Aug 22 UTC
### Motivation
Users reported erroneous auto-selection of ports, in relation to… uploads, unknown boards and using multiple boards of the same fqbn.
### Issue Identified
We were on occasion erroneously auto-reconnecting to the wrong port with the same associated board after upload / on disconnect. We were failing to check if the port we were auto-connecting to actually appeared due to an upload.
### Change description
Checks if a new port is created by an upload. Knowing if we have an "upload created port," we can now correctly determine if we should auto-reconnect after an upload.
### Other information
This is a draft serving to illustrate where this issue resides and a potential solution, these changes should be unit tested prior to merge, and we may wish to centralise the new logic.
This PR also resolves the issue of "double selections" in the board selector dropdown with an additional check [here](https://github.com/arduino/arduino-ide/blob/09534c64074fa497db192582fa788dae67142820/arduino-ide-extension/src/browser/boards/boards-service-provider.ts#L584).
### Reviewer checklist
* [ ] PR addresses a single concern.
* [ ] The PR has no duplicates (please search among the [Pull Requests](https://github.com/arduino/arduino-ide/pulls) before creating one)
* [ ] PR title and description are properly filled.
* [ ] Docs have been added / updated (for bug fixes / features)
There is a workaround you can use immediately:
Select Tools > Port > /dev/cu.Bluetooth-Incoming-Port from the Arduino IDE menus.
Select Tools > Boards > Arduino AVR Boards > Arduino Nano from the Arduino IDE menus.
Select the port of your Pico board from the Tools > Port menu.
Select the board for your Pico board from the Tools > Board menu.
The "Arduino NG or older" board was picked arbitrarily. The problem is that Arduino IDE 2.x persistently associates a board with a port as soon as you select that combination. That can be helpful when the association is correct, but it is also very easy to inadvertently create an association between a board and some unrelated port such as /dev/cu.Bluetooth-Incoming-Port
. The workaround is to change that port's association to any other board you don't use.
1 Like
This worked perfectly. Thank you so much!!
(And the 2.0 beta compile & upload process is so much faster than the 1.x one!)
You are welcome. I'm glad it is working now. Thanks for taking the time to post an update with your results.
Regards, Per
system
Closed
February 19, 2023, 11:20pm
5
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.