Arduino MKR1000 Switching COM ports

During Christmas I received the Arduino Engineering Kit which includes a MKR1000, MKR Motor Carrier, and an IMU shield. Also it used Matlab to deploy code to the arduino to be used over wifi. However, I have been recently running with these issues where I deploy the code on the MKR1000; during the building process, I can visibly see the COM port switch from 4,5 or 6,7. I know some people have an issue with the bootloader getting stuck but I do not think this is the problem... is it a faulty board?

This is a well known thing and fully documented. You will find posts in this section that detail what you are seeing.

Moved your topic to it's current location as it is more suitable.

Could you take a few moments to Learn How To Use The Forum. Other general help and troubleshooting advice can be found here. It will help you get the best out of the forum in the future.

No, it's not the sign of a faulty board. It's completely normal to see the port change and then change back during an upload. The reason is that the virtual COM port is created by the USB CDC code running on the MKR1000's primary SAMD21 microcontroller. This is different from Arduino boards like the Uno, Mega, and Nano, which have a separate dedicated USB chip. The USB code runs in the background of your sketch code. When you start an upload, the SAMD21 microcontroller must reset so that the bootloader code will run. The bootloader code also has its own USB CDC code. This causes Windows to enumerate a COM port for the bootloader, which will be a different COM port number than that assigned to the MKR1000 while the sketch is running. So when you start the upload the board is using the sketch COM port. Then it resets the board and switches to using the bootloader COM port. Once the upload finishes, the bootloader exits, the sketch runs and it switches back to the sketch COM port.

There have been reports of Arduino boards switching to a different COM port after the upload, rather than going back to the original sketch COM port. That means you need to change the Tool > Port menu selection after an upload. This happens often to me with my Nano 33 BLE, but I don't remember having this problem with the MKR1000 or my other MKR boards. I don't remember which boards the other reports were about and I can't find them now.

Are you having that problem of the COM port being different from the one you started with after an upload (e.g., start with COM2, switch to COM3 during upload, end up at COM4 after the upload finishes), or are you just getting unnecessarily concerned after seeing the switch from the sketch to the bootloader and then back to the original sketch port (e.g., start with COM2, switch to COM3 during upload, end up back at COM2 after the upload finishes)?

Just to be clear, even if you’re having the problem I described above, that’s not caused by a bad board. It’s purely a software problem.

Whew, okay. I was like 80 percent sure that it was not a board problem rather than a software issue. Could the COM switching be also caused by USB 3.0 drivers? I have also heard people have had that issue using 3.0 instead of 2.0.

USB 3.0 can be an issue although not all USB 3.0 is bad.

USB 3.0 issues

As far as the USB side of things there is more than enough documented evidence if you take time to search a little. The reason this aspect seems random is because there are so many factors involved all of which you can find with a little reading.

Quick outline is

  1. "Chipset used" There are a lot of vendors of USB 3.0 chipsets.

  2. "Ages of chipset" As chipsets are developed and updated even slight changes from the vendor could result in working chipsets not working on some peripherals.

  3. "USB 3.0 speeds" not all chipsets and vendors are created equal in this respect and some rely on other components sub systems on a motherboard to make up the differences.

  4. Arduinos are not designed as such to work at or on USB 3.0 speeds but depend more on the supposed compatibility of USB which is supposed to have "backward compatibility to USB 2.0 (see 1. 2. 3. above) USB 3.0 is known to cause issues quite quite a few boards including the 101 depending on its implementation and chipset.

  5. AVOID "Microsoft driver updates" at all cost and not just for USB related items. Video cards especially Nvidia are often changed by MS and may result in some unstable aspects. ALWAYS get your latest drivers from the manufacturers web site..

Mine will not work at all with USB 3.0 yet if I place a USB 2.0 powered hub between the board and the computer it works fine.

I would presume you have also tried another cable just to be sure. If you look in the USB port USB 3.0 usually have a BLUE plastic tab compared to USB 2.0 which can be white or black.

Check the specifications for your model of computer, motherboard or laptop is the most reliable method

Other method which is to check in Device Manager under windows and expand the section for "Universal Serial Bus Controllers" and see if there is anything for USB 3.0 ROOT or HUB.

Please don’t say anything along the lines of “but all these should be standard and backward compatible” or ”I have read the specifications” Those are simply recommendation’s and not everyone follows them to the letter.

Above is a stock USB3.0 answer. Most fixes just use the powered USB 2.0 hub.

Okay. Also, to answer your earlier question, the issue I have been having is I upload a sketch, it switches to the bootloader COM, which is completely normal, but then once returning back to the sketch COM it is a different port number than before. Does that make sense?

Yes, it makes sense and that is annoying when that happens. I've never seen an explanation of what causes this, or a solution other than to just change the Tools > Port menu selection as needed.

Sounds like you may have the creeping COM port issue.

Lets see if I can describe it.

  1. Board presents on COM 3
  2. You Upload and the COM changes to a bootloader COM port lets say COM 5
  3. Board should revert to COM 3 after upload but moves to a completely new COM port lets say COM 4
  4. Next upload Starts at COM 4 and swaps to the bootloader on COM 6. 5 This carries on for subsequent uploads etc.

Does that describe it better ?

If that's what you are seeing it is what I term "creeping com ports" Some of the early MKR1000 boards did that. It can also happen if you have a lot of different board types and use them a lot (I test so it is an issue that can affect me).

Another cause are other programs that also use COM ports which don't release them properly. This could be some bluetooth devices, cell phones (but not all), and a few other devices.

Windows in theory supports up to 254 COM ports but has been noticed to start having odd issues past COM 30-40.

There is an interim method to rectify that and reset the COM stack. I will add the link here for the most reliable method

  • Start by disconnecting as many USB devices as possible including HUBS.
  • Restart the computer.
  • Use the method linked to.
  • If offered to remove drivers you may say no otherwise you may need drivers again at some point.
  • When ALL the com ports have been removed restart the computer.
  • Optional but worth doing is to the use such as the free "Wise Registry cleaner"
  • Re-insert one device at a time and do not move on until that device has fully re-installed. That resets the COM stack. It may not cure the issue for everyone but has proved to be useful to others.

Bob.

That's exactly what's happening, I'll try those methods to see if that fixes the issue; however, is this only a temporary fix?

I don't know the specifics of why but for some it is a longer term fix. Too many variables / versions of windows and additional software/hardware permutations.

For me and my situations its about 2 - 3 times a year. That said I do run up to 14 boards at a time and up to 3 Arduino based CNC devices also.

Additionally you may want to make sure you are on the lastest firmware. The issue did ease off ( mostly ) after a firmware update. I have the BETA and very early production models here along with a more current version.

Sweet, I will try those methods tomorrow at work, thanks so much for the help and if anything else comes up I will be right back here lol.