Same COM port many times

IDE 1.8.9
Win 10 Pro US

Recently I am having issues with the Arduino IDE resulting in seeing the very same COM port number often twice and to a lesser degree up to four times. This despite the Device Manager only having one Arduino Zero COM port listed.

When it happens the uploading fails to finish but sometimes the code is still uploaded. Sometimes I have to unplug and restart the PC before I can proceed. I have tried to reburn the bootloader but in vain.

Double clicking the reset button doesn't help either - as it does when the upload COM port isn't found. But probably this is no surprise because the COM port is seen multiple times.

Why is this?

What can I do to stop this from happening?

It might be that this is something related to 1.8.9 because I can't remember if it has happened before.

TIA
MikD

I don't know why this happens, but I have the same problem with my MKR boards and the issue has been reported a few other times here:

I associate the problem with having the Serial Monitor open when I upload to the board. However, I just did a bunch of uploads using Arduino IDE 1.8.9 while the Serial Monitor was open and the board printing to it and now I can't reproduce the problem. If I could find a set of steps I could follow to reliably reproduce the issue, I could open a bug report with the Arduino developers. I don't really like to do that when I can't provide such a set of steps because it's extremely difficult to investigate and fix a problem if you can't reproduce it. If you manage to find a way to reliably cause this issue, please let me know, or open a bug report.

I've found the workaround for the problem is to close all Arduino IDE windows, unplug the board, then restart the Arduino IDE and plug it in again. That's much less of a hassle than restarting my computer (which is what I was previously using as a workaround).

There is a report of duplicate ports here:

but that's about network ports, so I don't think it's relevant. However, the pluggable discovery system was introduced in Arduino IDE 1.8.9 so if the problem does not occur in IDE versions prior to 1.8.9, it is possible that some change made with the pluggable discovery system is the culprit.

I managed to find a way to reliably reproduce this issue. The way to do it is to unplug the board while Serial Monitor is open. That does it every time.

I plug my Arduino boards into a USB hub that's seen better days, so it's possible that I sometimes get a momentary loss of USB connectivity if I jiggle the cable or bang my work bench, which could have been causing the same thing to be happening even when I didn't intentionally unplug the cable.

I found that the duplicate Tools > Port menu entries issue didn't occur when using the beta build of the Arduino IDE, but that the spurious upload error still did occur with that IDE version. The issue does not occur with Arduino IDE 1.8.8.

I opened a bug report in the Arduino IDE repository about this:

Hi pert and the forum

Thanks for getting back to me.

Here is another way to replicate problem:

Open Serial Monitor
Press reset
Close Serial Monitor
Open Serial Monitor

Then one more COM port entry with the same number is visible.

I hope this and your description can help the IDE developers.

Thanks!

Nice one! That's better than my approach.

I don't know but can this Native port problems help in any way in making the Arduino IDE/Zero USB communication and allocation more robust: Native port problems

I am experiencing the duplicate COM port described above. It happens every time I try to run my sketch, which makes the whole setup virtually unusable. I am new to Arduino, so I don't know how long I should expect to wait for this bug to get fixed. Can anyone tells me what to expect?

Not surprisingly, the Serial.available() test fails in this case, so I can't execute a Serial.read() to get input.

Also, can someone tell me more about the suggestion to use Arduino IDE/Zero USB. What do I need to try? Very frustrated by being dead in the water.

Hi chrisrenson. One of the Arduino developers already made a fix for the issue. It has not yet been released in a production version of the Arduino IDE, but a beta tester version is available here:

Note that I describe two issues here:

  • Duplicate entries for a port shown on the Tools > Port menu
  • Spurious upload failures

Although these issues are both caused by the same event, the test build I linked above only fixes the second issue. The first issue is merely cosmetic and is fixed in the Arduino IDE beta build. So both issues have been fixed, but separately, and there is currently no one version of the IDE that contains both fixes.

Note that the upload error message is false. The upload actually does finish successfully. So you could continue to use the regular Arduino IDE and just ignore the spurious upload errors. If you do that, make sure to turn on File > Preferences > Show verbose output during: upload so that you can see from the contents of the black console window after the upload whether the upload error was spurious or legitimate.

I appreciate that this is an old thread but I've just come across it after having several months of this problem.
I'm using 1.8.10 on two PCs and both suffer from multiple instances of the same port appearing under Tools.
It makes Serial monitor and uploading impossible and the only way to get rid of it is to shut down all the sketches running on that IDE - affects all of them - and restart.
After plugging and unplugging the USB cable in several times, the number of COM ports with the same number start to increase under Tools. All are highlighted and all are ticked. Sometimes, up to 6 instances of the same port show.
I thought it was a board problem, but it's not. It affects all the boards I use, Uno, Leonado, Mega.
No other USB devices or applications have this problem.
I never saw the problem before in all the previous years going back to 2010.
I use powered hubs that have always worked well. Using COM ports directly off the motherboard makes no difference.
I've also noticed another problem which may or may not be related.
Plugging a USB cable into one board, causes another board to reset.
I've scoped the USB data lines and they are clean.
All that seems to stop it is to disable RESET, but that's a pain.
I can live with that one, but the multiple COM ports is seriously trying.
I wondered if there had been any progress on getting a fix.

Hi tigger. This is strange. Following the steps in Upload fails after native USB board is disconnected w/ Serial Monitor open · Issue #8851 · arduino/Arduino · GitHub with Arduino IDE 1.8.10, I'm still able to cause the multiple ports menu entries, but I don't have any problems uploading. If you follow those steps exactly, do you get the upload error? Does it happen with all the different types of boards you use?

From what I know, the upload problem should have been fixed in Arduino IDE 1.8.10.

The multiple entries in the Tools > Ports menu issue remains, but that has already been fixed in the beta build of the Arduino IDE. So it's just a matter of waiting until that fix is ported from the beta build to the production build and released. I'm not sure how long that might take. I don't think the Arduino developers are treating that as a high priority bug since it doesn't affect any functionality.

tigger:
It affects all the boards I use, Uno, Leonado, Mega.

This is very strange. I have only ever seen this with the native USB boards like the Leonardo, Micro, MKR boards. I have never seen it with the Uno or Mega.

Multiple com ports has been reported in a variety of cases both on the forum, github, and directly.
More frequently happens with a Windows environment and is even more common with multiple live boards.

Testing has shown that it is possible for the windows com stack to become unstable after COM 30 but that is more of an edge case.

In some scenarios it may be advisable to reset the COM stack.
Quite a simple process under windows fortunately.

  1. Disconnect as many USB devices as possible.

  2. From an ELEVATED COMMAND PROMPT

  3. Type
    set DEVMGR_SHOW_NONPRESENT_DEVICES=1

  4. Then
    devmgmt.msc

  5. When device manager comes up select the "Show Hidden Devices"

  6. Goto the COM & LPT section (occasionally hidden under windows 10)

  7. Then simply delete all the COM ports with the exception of COM 1 and if it shows up COM 2
    Optional is also to remove drivers at each removal but I have only had to do that on quite rare occasions.

  8. Restart the computer and slowly add each device back.
    Note the port numbers may change from the original ones.

Almost sure I know why it happens with Arduinos in particular but it would probably be a complex fix and I am not that clever.

Bob.

EDIT... Per is correct in that the Leonardo's are more prone but the MKR and newer NANO's also exhibit the issue.

Also do not confuse this with BOOTLOADER ports as they are expected for many of the newer boards and the IDE knows about them and uses them appropriately.

Bob and pert
Thanks for the information which I will chew over.
I will try and firm up on exactly how and when the multiple ports crop up.
What I usually notice first is that the upload button stays active - yellow?- for ever and sure enough the COM port will be shown several times. I don't get up in to the 30's for COM port numbers.
Port busy or port unavailable often crops up, sometimes after closing and re-opening Serial Monitor.
The "fix" for that is to select another port from Tools, close the Tools menu then select the port you do need.
I'm running Win 10 pro on both PCs, all up to date.
I haven't seen the same problem on a Linux machine, but I don't use it that much.
One thing I am guilty of is running the PC and often IDEs for days on end. This often ends up with one of the IDE instances disappearing or getting "file does not exist" error.
I am also noticing on one PC a very long (20-minutes or more) startup of the IDE after a computer restart. Again, this is the only application that takes that amount of time.
I am seriously considering setting up the Arduino stuff on a dedicated PC, well away from the day to day office stuff.
pert - ref the boards - I principally work on Unos and Megas, a mix of genuine and good clones and it was a Mega showing multiple ports yesterday that prompted me to look it up.

Thanks for the extra info.

Having the IDE open for extended times has come up a couple of times and it was recommended IIRC to close it and re-open it to allow its threads to be re-claimed (or something similar to that)

Extended load times for the IDE has a few causes.
Some relate to JAVA but my own tests and some others had it down to extended security as being a major cause.

Adding the IDE's locations to extra security white list / exclusions lists showed a marked improvement on load times.

Slow compiles under Windows

These are only one aspect of the possible issue.

Add the Arduino directories to your antivirus / anti malware / other security exclusions.

So that would be at least two of the following.

C:\Program Files (x86)\Arduino
C:\Users\yourname\AppData\Local\Arduino15 (depends on IDE install type/location)
C:\Users\yourname\AppData\Roaming\Arduino15 (depends on IDE install type/location)

If you have your sketches set up in a different location it’s also worth adding that directory to the exclusions also.

Additionally if you also use the online IDE “CREATE” the following directories.

C:\Users\yourname\AppData\Roaming\ArduinoCreateAgent
C:\Users\yourname\AppData.arduino-create

If you have installed to a different drive swap the drive letter as needed.
If you also have an unzipped IDE installed that path should also be added to exclusions

Bob.

Thanks Bob
Some more to look at.
The slow loading of IDE is on one PC only (both PCs are identical), but the slow one is really heavily loaded with applications and things like many web pages up (e.g. >400) and does crash now and again, so I'm moving the Arduino stuff to the less busy PC that does run a lot smoother
I certainly agree that reloading the IDE frees things up until the next time it slows up.
The trouble is, I have slowly been setting up a house monitoring system and it relies heavily on running the serial monitor all the time (it's XBee based and has packets coming in every minute or so)
I'm looking to shift away from the dependence on the serial monitor as it does cause difficulties - most of it I don't read anyway.
So, I'll look at security(though both PCs are Norton 360) exclusions.
If I get a marked improvement, I'll post it.
By the way, what's IIRC?

IIRC "If I Remember Correctly"

I have a severe distrust in Norton products as they always show a marked slowness as does Mcafee.
Used to be world leaders but every time I have come across a users computer that was slower than it should be Usually somewhere along the road to fixing it those two names popped up.

Most simple home monitoring systems use WiFi in some form so moving away from serial is a good move.

Being the OP I can confirm that I also see the problem with IDE 1.8.10. But a lot less frequent than in April. However, since then I have cleared out my pile of COM port declarations that were in the 80'ies. So that the number of COM ports declarations may play a role is probably true.

Hi @MikD. By "the problem", do you only mean the duplicate entries in the Tools > Port menu, or are you also still having upload problems in Arduino IDE 1.8.10?

Is this only happening with the Zero?

It would be unusual to see 80 ghost COM ports for one particular board.

Were they all for the Zero or were other boards also involved ?

I did have a minor theory about different types of boards that would leap frog each other when they had 2 known ports such as the common COM and the bootloader COM
Where the next board used a different boards bootloader port which would make the original board when connected move one of its ports up in number.

But

Yes, I meant "duplicated entries" persists in IDE 1.8.10.

The >80 COM ports in use is not for the same device. From time to time my PC is used for configuration of many devices not Arduino related. I may have misunderstood the issue "become unstable after COM 30."

It might also be that I am more aware of the problem now and unconsciously avoid falling in to the trap of connecting/removing/re-connecting/closing/... the serial monitor. In all honesty I can't say.

Duplicated and unused COM ports does not always have to be an Arduino as you correctly say and observe.
It can on occasion manifest with other devices.

Here I don't really see that aspect but waaaay into the past some older cell phones and GPS devices that used USB as a COM enumeration could also do it.