Unable to Upload to Arduino Nano

Hi,
I am having trouble uploading to my trusty Arduino Nano, which has worked flawlessly in the past.
Upon uploading a sketch the Arduino Nano, I get this error:

avrdude: ser_open(): can't set com-state for "\\.\COM15"
Failed uploading: uploading error: exit status 1

I am not sure what this is supposed to mean. I have tried on multiple Arduino Nanos, and they all have the same problem. It works on my other computer though. All my machines run Windows 10/11. If anyone knows what is going on, I would appreciate some help!

Thank you in advance!

Windows update could have goofed something up. Try disabling the firewall then re-installing drivers if it's not a firewall issue. Check the windows logs as well for additional info.

I tried disabling the firewall, re-installing drivers and IDE, and still nothing. Where are the windows logs located?

Windows key (or start menu) and type "computer management". Open the "Event Viewer / Windows Logs / System" on the left hand tree. It's normal for it to respond slowly BTW. See if you get any hits plugging/unplugging your board. Check the other logs if you don't see anything.

Also check under device manager to see if there are any error codes for the driver. While you're there, go through the tabs and uncheck the box to allow Windows to turn off power for that device if enabled.

Hmmm. So when I plug/unplug the board, this message is logged:

Check the remaining resource budget. Module exceeds resource budget, failed to AllocateFwCps, STATUS = Insufficient system resources exist to complete the API..

It could be my CPU. In task manager, it sits pretty high. I just tried closing everything else, and my CPU spikes pretty high when uploading. Could that be the cause?

Under task manager go to your system interrupts and let us know what percentage those go up to. You could have a hardware issue.

Edit: Sort by name under "Processes" and scroll down in the windows processes for the system interrupts.

@transistor_man sometimes depending on which nano you have they require different programmers, so maybe try with a different programmer from the options such as AVRISP mkII or AVRISP if you are already using mkII.

Not sure if it will work but I have had this work for me before.

If you do think your CPU is at the limit try closing all non used applications and see if this helps. Maybe even do a hard restart of the computer. Failing that if you have a spare nano I would see if that one works

Hi @transistor_man

There were some previous reports of this "can't set com-state for ..." error occurring specifically when using cheap derivative boards that have the CH340 USB chip. It seems that a driver upgrade included in a recent Windows update is the cause of this problem.

Some of the affected users have found that uninstalling and reinstalling the CH340 device fixed the problem. I'll share the instructions you can follow to do that:

  1. Close Arduino IDE if it is running.
  2. Connect the Arduino board to your computer with a USB cable.
  3. Open the Windows Device Manager.
  4. Select View > Devices by type from the menus in the Device Manager window.
  5. Open the "View" menu in Device Manager.
  6. If there is a to the left of the "Show hidden devices" menu item, click on "Show hidden devices" to disable it.
  7. Open the "Ports (COM & LPT)" section of the Device Manager tree.
  8. You should see a port identified as "USB-SERIAL CH340 (COM_n_)" under the "Ports (COM & LPT)" section (where "COM_n_" is some serial port e.g., COM4). Right click on that item.
    A context menu will open.
  9. Select "Uninstall device" from the context menu.
    An "Uninstall Device" dialog will open.
  10. Check the box next to "☐ Attempt to remove the driver for this device" in the "Uninstall Device" dialog.
  11. Click the "Uninstall" button.
  12. Wait for the uninstallation process to finish.
  13. Unplug the USB cable of the Arduino board from your computer.
  14. Wait for the Device Manager tree to reload.
  15. Connect the USB cable of the Arduino board to your computer.
  16. Wait for the "USB-SERIAL CH340 (COM_n_)" port to reappear under the "Ports (COM & LPT)" section of the Device Manager tree.
  17. Select File > Exit from the Device Manager menus.

My experience is that the device will be reinstalled automatically by Windows after you plug the board back into the computer, as indicated by the "USB-SERIAL CH340 (COM_n_)" port reappearing in the last step of those instructions. However, it is maybe possible that the complete driver removal will actually have been accomplished by the above instructions, in which case it would be necessary to reinstall the driver. If this happens to you, please let me know and I'll provide instructions you can follow to install the driver.

Now start Arduino IDE again and repeat whatever you were doing before when you encountered that error. Please reply here to let us know whether the error still occurs.

System interrupts is using 0% on everything.
img

My CPU is around 30-40%, and goes up to close to 90% when uploading the sketch (and receiving the error)

SI is pretty low. If it was high, especially 100% I'd be concerned.

What ptillisch said sounds promising though so I'd focus on that for the moment.

Yes, you are correct. I do have a knock-off brand board. It never occured to me that the cheap boards may be using different USB chips.

I followed your instructions, and the installation was automatic. I opened the Arduino IDE, and it still throws the same error upon uploading.

Thank you all for your time so far, I appreciate it!

I'm sorry to hear that. Some of the users who experienced these errors reported that doing a "roll back" to an older version of the driver was an effective workaround. You can give that a try.

I'll provide instructions:

  1. Open this tutorial from SparkFun in your browser:
    https://learn.sparkfun.com/tutorials/how-to-install-ch340-drivers/all#drivers-if-you-need-them
    We are using this tutorial as a source for an older version of the CH340 drivers. Generally I recommend only obtaining drivers from the manufacturer of the device, but WCH does not provide older versions of their drivers and SparkFun is trustworthy.
  2. Click the "Windows (EXE)" link you see in red under the "Drivers (If You Need Them)" section of the tutorial.
  3. Wait for the download to finish.
  4. Run the downloaded CH341SER.EXE file.
  5. 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.
  6. A "DriverSetup(X64)" dialog will appear. Click the "INSTALL" button in the dialog.
  7. Wait for the driver installation to finish, as indicated by the appearance of a "Driver install success!" dialog.
  8. Click the "OK" button in the "Driver install success!" dialog.
  9. Click the X icon at the top right of the "DriverSetup(X64)" dialog to close it.
  10. Close Arduino IDE if it is running.
  11. Connect the Arduino board to your computer with a USB cable.
  12. Open the Windows Device Manager.
  13. Select View > Devices by type from the Device Manager menus.
  14. Open the "View" menu.
  15. If there is a to the left of the "Show hidden devices" menu item, click on "Show hidden devices" to disable it.
  16. Open the "Ports (COM & LPT)" section of the Device Manager tree.
  17. You should see a port identified as "USB-SERIAL CH340 (COM_n_)" under the "Ports (COM & LPT)" section (where "COM_n_" is some serial port e.g., COM4). Right click on that item.
    A context menu will open.
  18. Select the "Drivers" tab of the "USB-SERIAL CH340 (COM_n_) Properties" dialog.
  19. You will see a "Roll Back Driver" button in the dialog. If it is not clickable, perform the following instructions:
    1. Select "Update driver" from the context menu.
      An "Update Drivers Device - USB-SERIAL CH340 (COM_n_)" dialog will open.
    2. Click on "Search automatically for drivers" in the "Update Drivers Device - USB-SERIAL CH340 (COM_n_)" 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.
      :exclamation: 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 the forum thread to let me know. I'll provide alternative instructions you can follow.
    4. Click the "Close" button in the "Update Drivers Device - USB-SERIAL CH340 (COM_n_)" dialog.
  20. Click the "Roll Back Driver" button in the "USB-SERIAL CH340 (COM_n_) Properties" dialog.
    The "Driver Package rollback" dialog will open.
  21. Click the radio button next to "My apps don't work with this driver" in the "Driver Package rollback" dialog .
  22. Click the "Yes" button.
  23. Click the "Close" button in the "USB-SERIAL CH340 (COM_n_) Properties" dialog.

Now start Arduino IDE again and repeat whatever you were doing before when you encountered that error. Please reply here to let us know whether the error still occurs.

Hi,

Thank you for the instructions. I followed them up to step 19. The message "The best drivers are already installed" appears whem attempting to update the drivers.

OK, so I found a solution for anyone who may be having a similar problem to this.
Check out this link: https://github.com/SHWotever/FakeCH340DriverFixer/

I'm glad you were able to find a solution. Thanks for taking the time to share your findings!

All the other users were able to solve the problem by following one of the procedures I provided above (unfortunately it seems most end up having to perform the second procedure). The information in the link you shared is very interesting. I had a suspicion that the problem was specific to certain hardware since I have not been able to reproduce it with the CH340-based boards I have on hand

I tried, and... it works!
Thanks, thanks, and thanks again

Ugo

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