Sketch uses 3080 bytes (9%) of program storage space. Maximum is 32256 bytes.
Global variables use 200 bytes (9%) of dynamic memory, leaving 1848 bytes for local variables. Maximum is 2048 bytes.
"C:\Users\DrStone\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/bin/avrdude" "-CC:\Users\DrStone\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\DrStone\AppData\Local\Temp\arduino\sketches\8ABB6D4334F8B53AD0B0905CE508C16C/sketch_jun12a.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\DrStone\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"
I moved your topic to an appropriate forum category @drstoneluffy.
In the future, please take some time to pick the forum category that best suits the subject of your topic. There is an "About the _____ category" topic at the top of each category that explains its purpose.
There were some previous reports of this "can't set com-state for ..." error occurring specifically when using the cheap derivative boards like yours that have the CH340 USB chip. It seems that a driver upgrade included in a recent Windows update is the cause of this problem.
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:
Close Arduino IDE if it is running.
Connect the Arduino board to your computer with a USB cable.
Select View > Devices by type from the menus in the Device Manager window.
Open the "View" menu in Device Manager.
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.
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.
Are you still getting the exact same error message as before?:
I ask because sometimes there is a "problem stack", which means that fixing one problem only gets us to the next unrelated problem. Different error messages are associated with different causes of upload errors, so if the error message has changed, then there will be a different approach to solving the error.
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:
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.
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.
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. Please reply here to let us know whether the error still occurs.
Thanks a lot. I was getting irritated bcz we tried with 3 arduino cables, 2 arduinos and around 3-4 laptops but it just wasn't working......But this one worked....Thanks a ton!!
I was having this problem too. Driving me nuts. Totally messed up uploading with IDE 1.8.19 and 2.1.1 also BLOCKLY.
Only way to get around it on newer driver was to open serial monitor before uploading. that worked on IDE , MICROSOFT or CH340 chip vendor - You need to fix this.
I don't know who you mean by "you", but to be clear the source of the problem is not in any of the software maintained by the Arduino company. In addition, the Arduino company does not, and has never, manufactured any hardware that uses the CH340 USB chip the problem is specific to.
The problem is related to the latest version of the driver distributed by the manufacturer of the CH340 USB chip, WCH. So the ideal solution would be for WCH to release a new version of the driver with a fix for the problem. However, it seems the problem may be specific to certain batches of the CH340 chip, which raises speculation about whether the affected chips were even produced or authorized by WCH (it is common to receive counterfeit or defective/substandard parts intended for disposal when purchasing from untrusted sources of electronics). If this is true, then WCH would not have much motivation to make such a fix.
Another possibility is that the electronics community could produce some sort of fix or mitigation. We are already doing something of the sort by disseminating the instructions for a workaround. There is something along those lines here:
However, the problem with community solutions related to drivers is trust. It is wise to only install drivers obtained from trusted sources. This means that even if someone from the community produces a perfect fix with nothing but good intentions, it might only end up seeing widespread adoption if that community member can somehow establish trust (which could be through reputation or code signing).
Another interesting possibility might be for a workaround to be implemented in the AVRDUDE uploader tool. That wouldn't necessarily provide a universal solution since those working with affected hardware using other applications might still be affected (e.g., esptool is used instead of AVRDUDE when uploading to ESP32 and ESP8266 chips and those development boards frequently use the CH340), but it would at least provide a significant mitigation for the Arduino and related communities. It is not clear whether it would even be possible to implement a workaround for this driver level problem at the application level. There is a discussion about the problem in the AVRDUDE issue tracker:
but no indication of a possibility or intent to implement a workaround in that codebase.