Program Upload issue on MKRZERO

Arduino: 1.8.16 (Windows 8.1), Board: "Arduino MKRZERO"

The sketch compiles ok with no displayed errors.

Initially with the board connected get the expected Board: Arduino MKRZERO, Port: COM3 “Arduino MKRZERO”

Get Board Info: BN : Arduino MKRZERO VID: 2341, PID 804F, SN ******

The previously loaded sketch will communicate various print program print statements onto the Serial Monitor screen.

Thus this indicates there is communications initially across the USB bus.

However when I try to upload a new sketch onto the MKRZERO it ends up with the serial port being ‘lost’.

Verbose upload messages:

Arduino: 1.8.16 (Windows 8.1), Board: "Arduino MKRZERO"

Sketch uses 34764 bytes (13%) of program storage space. Maximum is 262144 bytes.

Global variables use 3676 bytes (11%) of dynamic memory, leaving 29092 bytes for local variables. Maximum is 32768 bytes.

PORTS {} / {} => {}

PORTS repeated x40

Couldn't find a Board on the selected port. Check that you have the correct port selected. If it is correct, try pressing the board's reset button after initiating the upload.

processing.app.SerialException: Error opening serial port 'COM3'.

at processing.app.Serial.(Serial.java:152)

at processing.app.Serial.(Serial.java:82)

at processing.app.SerialMonitor$2.(SerialMonitor.java:132)

at processing.app.SerialMonitor.open(SerialMonitor.java:132)

at processing.app.AbstractMonitor.resume(AbstractMonitor.java:132)

at processing.app.Editor.resumeOrCloseSerialMonitor(Editor.java:2126)

at processing.app.Editor.access$1300(Editor.java:116)

at processing.app.Editor$UploadHandler.run(Editor.java:2095)

at java.lang.Thread.run(Thread.java:748)

Caused by: jssc.SerialPortException: Port name - COM3; Method name - openPort(); Exception type - Port not found.

at jssc.SerialPort.openPort(SerialPort.java:167)

at processing.app.Serial.(Serial.java:141)

... 8 more

Error opening serial port 'COM3'.

Tools / Port indicates also indicates no PORT has been found, but if I press the reset button on the MKRZERO board, the Port information returns and I can interrogate the Board info.

I tried to do an upload with 2secs of pressing the reset button, but still won’t upload.

The tricky thing about the boards with native USB functionality like your MKR Zero is that the USB code that creates the CDC serial port is running on the same microcontroller as your sketch. This means your sketch code can break the USB code, or stop it from running. When that happens, it no longer presents a port.

This can be unexpected to those who previously mainly worked with the boards like Uno and Mega that have a dedicated USB chip that can never be affected by the sketch code.

The missing port makes it so you can't upload normally any more. However, the situation is really not so bad because there is an independent program called the bootloader in a separate section of memory from your sketch, and that program has its own USB CDC code. So even if the sketch is completely broken, you only need to activate the bootloader and you will get a port back and be able to upload.

Fortunately, there is an easy way to recover from this situation:

  1. Press and release the reset button on your board quickly twice. You should now see the LED on the board pulsing, which means the bootloader is running. The double press causes the bootloader to run indefinitely (until the board is reset, powered off, or an upload is done), which means you don't need to get the timing of the reset just right.
  2. Select the port of your board from the Tools > Port menu. The port number may be different when the bootloader is running so don't assume you already have the correct port selected.
  3. Start an upload in the Arduino IDE.

The upload should now finish successfully. After this, you should be able to go back to doing normal uploads without needing to press the reset button. If you still need to do the reset trick to do uploads after this, the problem may be caused by your code. You can verify this by uploading a simple sketch like File > Examples > 01.Basics > BareMinimum.

Doing the double reset button to run the bootloader did the trick - now able to successfully upload the sketches.
I already had minimised most of the procedures within the sketches, but with no success - but at least when I go back to the full code, gradually, I'll be able to see if it is my code that is causing the issue.
Thank you for your excellent help.

You are welcome. I'm glad to hear you are able to upload now!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.