Sketch uses 444 bytes (1%) of program storage space. Maximum is 30720 bytes.
Global variables use 9 bytes (0%) of dynamic memory, leaving 2039 bytes for local variables. Maximum is 2048 bytes.
"C:\Users\debji\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/bin/avrdude" "-CC:\Users\debji\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf" -v -V -patmega328p -carduino "-PCOM7" -b115200 -D "-Uflash:w:C:\Users\debji\AppData\Local\Temp\arduino\sketches\585F128512DA0BDA7A3EA8E8488514AB/sketch_apr24a.ino.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\debji\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf"
Using Port : COM7
Using Programmer : arduino
Overriding Baud Rate : 115200
avrdude: ser_open(): can't set com-state for "\\.\COM7"
avrdude done. Thank you.
Failed uploading: uploading error: exit status 1
Without additional information I would assume that there is no Arduino connected to COM7.
im having the same problem but im so very sure that i connected to the right port!! its stressing me out..it wasnt the arduino's problem because i tested on my lecturer's laptop and they worked fine..so smtg is wrong with my laptop somehow??idk
Have you seen/read this recent discussion:
It seems that reinstalling the driver for your particular Serial-USB chip might help resolve the issue.
I'll share some instructions you can follow for uninstalling and reinstalling the CH340 device. Other users experiencing this "can't set com-state
" error reported doing so fixed the problem, as mentioned by markd833.
- Close Arduino IDE if it is running.
- Connect the Arduino board to your computer with a USB cable.
- Open the Windows Device Manager.
- Select View > Devices by type from the Device Manager menus.
- Open the "View" menu.
- If there is a ✓ to the left of the "Show hidden devices" menu item, click on "Show hidden devices" to disable it.
- Open the "Ports (COM & LPT)" section of the Device Manager tree.
- 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. - Select "Uninstall device" from the context menu.
An "Uninstall Device" dialog will open. - Check the box next to "☐ Attempt to remove the driver for this device" in the "Uninstall Device" dialog.
- Click the "Uninstall" button.
- Wait for the uninstallation process to finish.
- Unplug the USB cable of the Arduino board from your computer.
- Wait for the Device Manager tree to reload.
- Connect the USB cable of the Arduino board to your computer.
- Wait for the "USB-SERIAL CH340 (COM_n_)" port to reappear under the "Ports (COM & LPT)" section of the Device Manager tree.
My experience is that the device will be reinstalled automatically by Windows. However, it is maybe possible that the complete driver removal will actually have been accomplished by the above instructions, in which case it will be necessary to reinstall the driver. If this happens to you, please let me know and I'll provide instructions for installing the driver.
Once the port has reappeared in Device Manager, start Arduino IDE again and check to see whether the problem still occurs.
I had same problem with arduino nano. When I try to upload I get (ser_open(): can't set com-state for "\.\COM3" ) error message. I can upload same code to Arduino uno with same configuration. Your instruction perfectly solve my problem. Thank you very much
Great. Can tell us which windows version you are using?
I got this issue with clone Arduno Nano board after updating to Windows 11 and Arduino IDE 2.2.0. This problem seems to appear on CH340 based clone boards.
Steps to fix.
- Download CH341PAR.exe. https://www.wch.cn/downloads/CH341PAR_EXE.html
- Plug in Nano. Open Device manager and find the "USB-SERIAL CH340" under 'Ports (COM & LPT).
- Right click and Uninstall Device.
- Open CH341PAR.exe and install the driver.
- Arduino Nano should be programmable again with Arduino IDE.
I tried these steps but I am still getting the same error
"avrdude: ser_open(): can't set com-state for "\.\COM7"
Failed uploading: uploading error: exit status 1"
Hi @tanuhc. Other affected users have 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:
- 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. - Click the "Windows (EXE)" link you see in red under the "Drivers (If You Need Them)" section of the tutorial.
- Wait for the download to finish.
- Run the downloaded
CH341SER.EXE
file. - 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.
- A "DriverSetup(X64)" dialog will appear. Click the "INSTALL" button in the dialog.
- Wait for the driver installation to finish, as indicated by the appearance of a "Driver install success!" dialog.
- Click the "OK" button in the "Driver install success!" dialog.
- Click the X icon at the top right of the "DriverSetup(X64)" dialog to close it.
- Close Arduino IDE if it is running.
- Connect the Arduino board to your computer with a USB cable.
- Open the Windows Device Manager.
- Select View > Devices by type from the Device Manager menus.
- Open the "View" menu.
- If there is a ✓ to the left of the "Show hidden devices" menu item, click on "Show hidden devices" to disable it.
- Open the "Ports (COM & LPT)" section of the Device Manager tree.
- 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. - Select the "Drivers" tab of the "USB-SERIAL CH340 (COM_n_) Properties" dialog.
- You will see a "Roll Back Driver" button in the dialog. If it is not clickable, perform the following instructions:
- Select "Update driver" from the context menu.
An "Update Drivers Device - USB-SERIAL CH340 (COM_n_)" dialog will open. - Click on "Search automatically for drivers" in the "Update Drivers Device - USB-SERIAL CH340 (COM_n_)" dialog.
- 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.
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.
- Click the "Close" button in the "Update Drivers Device - USB-SERIAL CH340 (COM_n_)" dialog.
- Select "Update driver" from the context menu.
- Click the "Roll Back Driver" button in the "USB-SERIAL CH340 (COM_n_) Properties" dialog.
The "Driver Package rollback" dialog will open. - Click the radio button next to "My apps don't work with this driver" in the "Driver Package rollback" dialog .
- Click the "Yes" button.
- 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 before. Hopefully this time you will not encounter that "can't set com-state
" error during the sketch upload.
Hello, I can't click on "Roll back driver", it's greyed out. I updated windows to see if that would fix it, but no luck. Please help, thank you!
Hi @fisheee1230.
Please try this:
I'll provide instructions:
- Connect the Arduino board to your computer with a USB cable.
- Open the Windows Device Manager.
- Select View > Devices by type from the Device Manager menus.
- Open the "View" menu.
- If there is a ✓ to the left of the "Show hidden devices" menu item, click on "Show hidden devices" to disable it.
- Open the "Ports (COM & LPT)" section of the Device Manager tree.
- 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. - Select the "Drivers" tab of the "USB-SERIAL CH340 (COMn) Properties" dialog.
- Select "Update driver" from the context menu.
An "Update Drivers Device - USB-SERIAL CH340 (COMn)" dialog will open. - Click on "Search automatically for drivers" in the "Update Drivers Device - USB-SERIAL CH340 (COMn)" dialog.
- 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.
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.
- Click the "Close" button in the "Update Drivers Device - USB-SERIAL CH340 (COMn)" dialog.
- Click the "Roll Back Driver" button in the "USB-SERIAL CH340 (COMn) Properties" dialog.
The "Driver Package rollback" dialog will open. - Click the radio button next to "My apps don't work with this driver" in the "Driver Package rollback" dialog .
- Click the "Yes" button.
- 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 you will not encounter that "can't set com-state
" error during the sketch upload.
I get "The best drivers are already installed" message. I am using windows 11.
After starting the IDE again I get
avrdude: ser_open(): can't set com-state for "\.\COM3"
Failed uploading: uploading error: exit status 1
Would appreciate alternate instructions please.
Possible instructions to solve the issue: Can't set com-state on a cheap nano clone - #6 by ptillisch
Nope, that didn't do it. Any other suggestions?
No idea. You can dig through these search results: https://forum.arduino.cc/search?expanded=true&q=com-state%20%40ptillisch
Good news. Got the sketch complied and uploaded using the default in IDE 2.2.1. I uninstalled and reinstalled drivers. Was perplexed that it did not give the usual diagnostic output from AVRDude but the lights did their thing. Will hard wire in to application and test.
Better news, it does work in the hardwired application. Despite the differences it behaves the same.
Which drivers did you reinstall?
I used the drivers pointed to in the SparkFun tutorial below.