COM port error Uno R3 wont load program

Hello, I started Arduino with an Uno R3 and make several projects. I now use an Uno R4 wifi.

I wanted to mod an old sketch for my R3 and hooked it up to upload and am getting COM port errors. Here is the error message below. Can anyone advise? Thx Steven Lightfoot

Flashing with command:C:/Users/StevenGeiger/.arduino-create/arduino/avrdude/6.3.0-arduino17/bin/avrdude.exe -CC:/Users/StevenGeiger/.arduino-create/arduino/avrdude/6.3.0-arduino17/etc/avrdude.conf -v -patmega328p -carduino -PCOM5 -b115200 -D -Uflash:w:C:/Users/STEVEN~1/AppData/Local/Temp/arduino-create-agent3967895387/Office_Blower_20241212-basic-K.hex:i
avrdude: Version 6.3-20190619
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2014 Joerg Wunsch
System wide configuration file is "C:/Users/StevenGeiger/.arduino-create/arduino/avrdude/6.3.0-arduino17/etc/avrdude.conf"
Using Port : COM5
Using Programmer : arduino
Overriding Baud Rate : 115200
avrdude: ser_open(): can't set com-state for "\.\COM5"
avrdude done. Thank you.
Executing command: exit status 1

Hi @steven_lightfoot

This error occurs when uploading to the boards that use specific batches of the WCH CH340 USB chip. The problem only occurs when using the latest version of the CH340 driver.

The workaround for the problem is to perform a "roll back" to an older version of the driver that is compatible with these problematic "CH340" chips. I'll provide instructions you can follow to do that:

  1. Click the following link to download the previous version of the driver from the chip manufacturer's website:
    https://www.wch-ic.com/downloads/file/65.html?time=2023-03-16%2022:57:59
  2. Wait for the download to finish.
  3. Run the downloaded CH341SER.EXE file.
  4. A "User Account Control" dialog may now appear asking "Do you want to allow this app to make changes to your device?". Click the "Yes" button.
  5. A "DriverSetup(X64)" dialog will open. Click the "INSTALL" button in the dialog.
  6. Wait for the driver installation to finish, as indicated by the appearance of a "Driver install success!" dialog.
  7. Click the "OK" button in the "Driver install success!" dialog.
    The dialog will close.
  8. Click the X icon at the top right of the "DriverSetup(X64)" dialog
    The dialog will close.
  9. Close Arduino IDE if it is running.
  10. Connect the Arduino board to your computer with a USB cable.
  11. Open the Windows Device Manager.
  12. Select View > Devices by type from the Device Manager menus.
  13. Open the "View" menu.
  14. If there is a to the left of the "Show hidden devices" menu item, click on "Show hidden devices" to disable it.
  15. Open the "Ports (COM & LPT)" section of the Device Manager tree.
  16. You should see a port identified as "USB-SERIAL CH340 (COMn)" under the "Ports (COM & LPT)" section (where "COMn" is some serial port e.g., COM4). Double click on that item.
    The "USB-SERIAL CH340 (COMn) Properties" dialog will open.
  17. Select the "Driver" tab of the "USB-SERIAL CH340 (COMn) Properties" dialog.
  18. You will see a "Roll Back Driver" button in the dialog. If it is not clickable, perform the following instructions:
    1. Click the "Update driver" button.
      An "Update Drivers Device - USB-SERIAL CH340 (COMn)" dialog will open.
    2. Click on "Search automatically for drivers" in the "Update Drivers Device - USB-SERIAL CH340 (COMn)" dialog.
    3. You should now see the driver installation wizard update the driver. Wait for the update to finish, as indicated by the message "Windows has successfully updated your drivers" in the dialog.
      :red_exclamation_mark: It is possible you will instead see the message "The best drivers are already installed". If so, please stop following the instructions here and reply on this forum topic to let us know. I'll provide alternative instructions you can follow.
    4. Click the "Close" button in the "Update Drivers Device - USB-SERIAL CH340 (COMn)" dialog.
      The dialog will close.
  19. Click the "Roll Back Driver" button in the "USB-SERIAL CH340 (COMn) Properties" dialog.
    The "Driver Package rollback" dialog will open.
  20. Click the radio button next to "My apps don't work with this driver" in the "Driver Package rollback" dialog .
  21. Click the "Yes" button.
    The "Driver Package rollback" dialog will close.
  22. Click the "Close" button in the "USB-SERIAL CH340 (COMn) Properties" dialog.

Now start Arduino IDE again and repeat whatever you were doing before when you encountered that error before. Hopefully this time everything will work as expected.

Wow, thanks, I really appreciate to know the basis of the problem. I did this re-load of code to my R3 (its a 2023 version) maybe 4 months ago and while I got this same error, somehow I kept trying and got it yo upload at one point, as if my magic. I didnt realize there was a deeper issue.

In principle I get what you suggest to do, even it looks like a lot of effort. Can you explain the fundamental issue? Why is this happening now only using the cloud editor and only after I started using my R4? I never had this issue when using my R3, it only started once I retired the R3 and started using the R4. Why would that be? Thx

And I am using an original Arduino R3 with the normal ATmega main chip, does it even have a CH340?

I'm not sure I understand what you mean by that. When you encountered this error, did you have the R3 connected to your computer, or was it instead the R4 that was connected to your computer.

Are you certain it is an original UNO R3? Even the derivative boards have an ATmega328P chip, and that is not the relevant factor anyway. The relevant factor is the USB chip.

The UNO R3 boards made by Arduino have an ATmega16U2 as the USB chip:

📷

MakeMagazinDE - CC BY-SA 4.0 (cropped)

The cheap Chinese derivative boards frequently have the CH340 USB chip:

📷

SparkFun - CC BY-SA 4.0 (cropped)

But some unscrupulous people are making boards that have a chip which has the same SOIC-16 IC package as the CH340, and identifies itself as a CH340, but doesn't have the labeling on the chip that we would expect from a genuine CH340:

📷

NodeMCU Lua Lol1n V3.jpg by Popolon - CC BY-SA 4.0 (cropped)

The boards with those unlabeled "CH340" chips are incompatible with the recent versions of the CH340 Windows driver. Attempting to upload to boards that have that chip when the latest driver version is installed results in this distinctive "can't set com-state for ..." message.

So please tell us which of those USB chips is present on your R3. I am referring to the largest chip that is near the USB socket on the board, not to the larger ATmega328P chip on the board.

OK thanks, I will check for the chips I see and report back. It is def an original Arduino EOM R3.

As for when it happens, basically I switched over to using an R4 wifi maybe six months ago and before that I only used my R3. I have only ever used the web/cloud editor. When I got my R4 I stopped using my R3 and only connected to the R4 and used that. The R3 has been used in a project but I wanted to update the software slightly and so a few months ago hooked up the R3 to update and it was then I first these COM port issues. When I only used the R3 it auto selected COM3. When I have been using my R4 is auto selects COM3 also, but now when I try to hook up the R3 it seems to default to COM5, and this it seems is the issue. When I first re-hooked up the R3 a few months ago and managed after many tries and reboots etc to get it to connect and upload, but this time it wont cooperate and gives me the error I provided (it did that last time also).

I checked and it definitely has the ATMEL USB chip, and it is 100% an original Made in Italy Arduino Uno R3 OEM board.

OK, then it doesn't have the "CH340" chip and the instructions I provided in post #2 are not relevant and you should not perform them as they won't help.

Unfortunately I don't have a good idea about how to solve the problem for boards with an ATmega16U2 chip. Over the two years since the incompatible version of the CH340 driver was released, we have received many reports of this distinctive error message from the users unfortunate enough to have obtained one of those bad cheap derivative boards, but before that time the reports were much more rare, and even those were often about the CH340 driver.

I did find some reports of solutions the affected users had found. Maybe they will be useful to you:

Thanks, I will do more testing.

So I made an attempt today and it worked the first time, complied and uploaded no issue, on COM 5. So I really dont know what the issue is, but its intermittent.