Error code when uploading Nano Every (worked in the beginning)

In the beginning I was able to upload my Nano Every a few times. Then suddenly now it has stopped being able to receive uploads. This error pops up on the Output window in IDE (2.3.6).
For background: my Nano Every VIN is powered by 12V on on a board. Then I connect USB cable to Nano Every and then upload the code. It wrked a few times but now it cannot anymore. After remove the 12V, now it still does not work and seems to be permanently "dead".
Did I somehow inadvertently damaged the Nano Every because I was uploading to Nano Every when it was also powered by 12V?
Or what could have caused my Nano Every to now be "dead" and not able to receive anymore uploads?
Note: I have tried another Nano Every and upload the same exact code (but this Nano Every is not connected on the board and not powered by 12V) and no problem at all, multiple times.

Error message:
Cannot perform port reset: 1200-bps touch: opening port at 1200bps: Invalid serial port
avrdude: ser_open(): can't set com-state for "\.\COM14"
Failed uploading: uploading error: exit status 1

Hi @ghariman. Is this an official Arduino Nano Every board:

Or is it instead a 3rd party derivative board?

We are always happy to provide assistance regardless of the manufacturer of the board, but it is important for us to understand what hardware you are using in this case in order to be able to provide effective assistance.

The thing of interest is the USB interface chip on the board. The official Arduino Nano Every has an ATSAMD11 chip:

đź“·

ABX00028_03.front_643x483.jpg by Arduino - CC BY-SA 4.0 (cropped, annotated)

Does your board have that chip marked "Atmel SAMD11U"

I ask because most often when we receive reports of upload failing with this "avrdude: ser_open(): can't set com-state for ..." error message, it occurs when using sketchy Chinese derivative boards that have a different USB chip. However, it is possible that there are causes of the error message other than a dodgy USB chip.

Hi @ptillisch : yes I bought a real Arduino brand on Digikey. Below are some photos (this is after it was desoldered from the big board. And it still shows the same behavior of not being able to upload). It shows the correct Atmel SAMD11U.
SO what could be going on? It used to upload properly in the beginning. Could having 12V on VIN while also uploading via USB cause such problem?

Error message:
Cannot perform port reset: 1200-bps touch: opening port at 1200bps: Invalid serial port
avrdude: ser_open(): can't set com-state for ".\COM14"
Failed uploading: uploading error: exit status 1




Typically no.

After remove the 12V, now it still does not work and seems to be permanently "dead".

What voltage do you read on the 3,3v pin of the the NanoEvery when connected to usb?

Are you certain that you had the 12V on the Vin pin and not the 5v pin?

Hi @cattledog : 3.3V is there and 5V is there. The nano seems to be acting "normal" except that it just does not want to receive anymore uploads....

BTW the schematic connection of the Nano Every on the big board is like this. I don't think anything there can cause the Nano Every to get into this state, can it?

Now I try to upload again (after Nano Every has been removed from big board). Only 1 line error comes up:
Cannot perform port reset: 1200-bps touch: opening port at 1200bps: Invalid serial port
ANd then uploading window is just stuck trying over and over again.

@ptillisch: UPDATE: I just tried something: I held the white reset button and then tried to upload. Of course many errors showed up. But then after that point on, now the original problem seems to have been cured.....I can upload correctly......
But then I unplugged the USB cable and reinsert and try upload again, but original problem came back........
And this is repeatable. I can press reset at the same time as uploading and it "seems" to cure the problem. But if I unplug and plug back in, the problem comes back.

Does this tell something? Is my Nano Every board broken? Defective?

What is going on????? This is super confusing..........

Any chance that there is a solder bridge between the reset pin and ground?

What OS are you using?

Hi @cattledog : no bridge because if I press reset the amber LED stops and when I let go it does something (from previous program upload). That tells me the reset button works. BTW see my Update post above yours. Strange behavior going on. I am sure this Nano Every is now "broken". But I just don't know how it got into this state...

Forgive me if I not understand things correctly.
Your board is running the code. And you able to upload to it while pressing the Reset. What is the problem finally?

@b707 : sorry if I was not clear. If the Nano Every has power, I can "temporarily" heal it by pressing reset long while trying to upload and then try upload again will be okay. But as soon as it looses power then the behavior comes back permanently and trying to upload it will give the same error message as before (until I do the same reset long while uploading). So thus I consider it still broken as it is not suppose to behave like this. So does anyone know why this particular Nano Every got into this strange behavior?

What had you soldered onto it?

@xfpd : when the problem first started to occur, I had the Nano Every connected on a PCB where the VIN of Nano Every was powered from 12V, and then also the Nano Every was sending TX/RX to another chip.

One suggestion I have is for you to try using MegaCoreX as the core for this board instead of the Arduino Core megaavr.

Installation instructions using the board manager are found in the MegaCoreX readme
https://github.com/MCUdude/MegaCoreX?tab=readme-ov-file#how-to-install

MegaCoreX uses an different and more recent version of avrdude(8.0) which has different handling of the updi interface than the version(6.3) used by the arduino core.

Your issue is still very strange to me, and why the power on reset behaves differently from the external reset is very unclear. Acccording to the data sheet for the At4809, they handle the reset of UPDI differently.

Ok all, I think I figured it out (maybe). It seems that a program that I uploaded before had a lot of commands that uses Serial.pritnln() for debugging purposes and I think what is going on is the IDE cannot upload as there was non-stop Serial.println() in the main loop which conflicts with the serial port uploading of program.
Now I managed to upload a program that does not have this continous Serial.println in the main loop. And now I can upload programs correctly to the same Nano Every.
Thank you everyone for trying to solve this.

Write a condition to check serial communication before each serial print. This document says to use the following... https://docs.arduino.cc/language-reference/en/functions/communication/serial/ifSerial/

void setup() {
  Serial.begin(115200);
  while (!Serial) { } // do nothing until Serial is available
}

void loop() {}

Unfortunately this is only meaningful on the boards with native USB. Serial always evaluates as true when the program is running on the Nano Every:

The exact nature of the proposal is not clear to me, but if you want to throttle serial output, perhaps you can make use of Serial.availableForWrite():

https://docs.arduino.cc/language-reference/en/functions/communication/serial/availableForWrite/

or if a blocking function is acceptable for the application, Serial.flush():

https://docs.arduino.cc/language-reference/en/functions/communication/serial/flush/

But I would start by evaluating whether the code that produces all the output is actually necessary.

For example, if you are doing something like this:

void loop() {
  Serial.println("I'm alive!");
}

then the best solution would be to add some "blink without delay" code to only print that output periodically instead of on every execution of loop.

Although the 12V connection of the VIN pin of Arduino Nano Every is within the specification range, if there is no good isolation between the external power supply and the USB power supply, it may cause current backflow or overheating of the voltage regulator, thereby damaging the MCU or USB interface. You can try to check if there is voltage at the 5V and 3.3V pins of the development board and observe whether the computer recognizes the device when the USB is inserted. If there is no response at all, it can basically be determined that the hardware is damaged.
In the future, when uploading code, be sure to disconnect the external power supply and only use USB power to avoid similar problems.

The supply line of the Nano Every is vulnerable. A reverse current in the 5V regulator is possible, and may damage it if strong enough, followed by blowing up the 4809 the next time VIN is applied.

One diode may solve this problem.