Uploading sketches to the Arduino Zero (and other related boards) trough the native port is a pain in the ass. It happens quite often that the Arduino board doesn't respond anymore and that the following error messages are displayed:

  • Couldn't find a Board on the selected port
  • Board at COM4 is not available
  • Caused by: processing.app.SerialException: Error touching serial port 'COM4'
  • Caused by: jssc.SerialPortException: Port name - COM4; Method name - openPort(); Exception type - Port busy.

 The reason is that the sketch disrupts the native port, which will be grayed out as you can see here: 

SAMD21 Arduino bootloader virus
SAMD21 Arduino bootloader virus

There are two major problems with the native USB port:

  • The serial port number changes randomly.
  • The native port cannot be detected.

Because these problems get on your nerves after a while, I have several solutions that will help.

If the serial com port number changes randomly

This problem drives you crazy easily; it has to be solved in Windows. For example, if the com port has initially the number 9 and changes spontaneously into number 10, we have to do the following (in Windows 10):

Control panel > Device Manager > Ports > Arduino Zero > RMB >  Properties > Port settings > Advanced > Com Port Number set to 10 > OK
If Ports is not listed in the Device Manager than open the View menu and select “Show hidden devices”.
Port 10 may be selected already, ignore any message about that. Note that you must use always use the same USB connector on your laptop now.

If the native com port can’t be detected

This can happen among others when a sketch is continuously printing to the serial monitor. Since the port is busy, it can’t be respond anymore. To fix this do:

  • Double-tap the reset button, or
  • Unplug and plug in the USB connector when there is no reset button. Sometimes this doesn’t work, so always use a reset button.

Note that the Arduino Zero bootloader has a double-tap on reset button function. By quickly pressing this button two times, the board will reset and stay in bootloader mode, waiting for communication on either USB or USART.

The port should now be available and visible again. Because it is time consuming and annoying to repeat this every time, it is better to avoid it:

Add a delay at start-up

In fact, a reset button is only needed in emergency situations: if an Arduino board no longer responds to the serial port if a new sketch has to be uploaded. However, there are situations where no reset button can be used, here we have to restart the Arduino by unplug and plug in the USB connector (that also powers the Arduino Board). But sometimes this doesn’t work and without a reset button there is a serious problem. I have found out that adding a delay ensures that the Arduino waits some time for communication after start-up:

void setup()
{ delay(5000); // wait for upload after power-up

To carry this out, upload the sketch en while the compiler is running (see the green bar), plug in the USB cable. If the upload fails, try it again.

Avoid continuously printing

When Serial.print() is used inside the main loop(), there will be printed continuously at high speed. This disturbs the uploading of new sketches. To avoid this, print with a time interval, here is an example of how to do this:

#include <Metro.h> 

Metro printInterval(250);     

void setup() 
{ 
}

void loop()
{ if(printInterval.check()) Serial.print("blabla");
}

If nothing works

If the above solutions still doesn’t bring the port to life, try one of the following solutions:

  • Click on the save button first.
  • Tools > Port and select the COM port again.
  • Often there are duplicate ports, for instance COM5 and COM7, of which only one is the right one.
  • Restart the computer.
  • Tools > Board > select your board again even if it is clearly already selected.

It would be nice if the above problems can be solved in the Arduino IDE…

Links

Do you have any comments? Please let me know.
Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.