I am new to Arduino Uno and have been trying to upload a code it compiles all good but does not upload due to com error. I tried lot of troubleshooting step after reading many threads regarding this issue but no help. Also tried connecting the board to another PC and got the same issue. Any help would be appreciated!
Which version of Windows do you use (10/11/...)?
Do you know what the TTL-to-USB converter on the board is? Check in Windows Device Manager; possibly CH340.
We do not know what you tried. If you have indeed the CH340, did you try to roll back the driver?
My bad I did not mention more details.
I have a windows 11 although I tried it on a Windows 10 laptop as well but had the same issue.
The TTL to USB converter is the CH340 And I tried updating the Ch340 drivers, no luck.
When I try to roll back the drivers from the device manager I get another error which says:
avrdude: stk500_recv(): programmer is not responding
avrdude: initialization failed, rc=-1
I checked all connections.
Hi @coldfire23. I'm going to ask you to post the full output from an upload attempt when in verbose mode.
NOTE: These instructions will not solve the problem. They are only intended to gather more information which might provide a clue that eventually leads to a solution.
Please do this:
- Select File > Preferences from the Arduino IDE menus.
- Uncheck the box next to "Show verbose output during:
☑
compilation". - Check the box next to "Show verbose output during: ☐ upload".
- Click the OK button.
- Attempt an upload, as you did before.
- After the upload fails, you'll see a button on the right side of the orange bar in Arduino IDE: Copy error messages. Click that button.
This copies the full output to the clipboard. - Open a forum reply here by clicking the Reply button.
- Click the
<CODE/>
icon on the post composer toolbar.
This will add the forum's code block markup (```
) to your reply to make sure the error messages are correctly formatted.
- Press Ctrl+V.
This will paste the error output from the upload into the code block. - Move the cursor outside of the code tags before you add any additional text to your reply.
- Click the Reply button to post the output.
I have been battling the same issue by trying the following (Win 11 Arduino 1.x):
- unplug, plugin
- POPO
- Update boards
- different USB port
- Run in compatibility mode
- Run as administrator
Nothing worked I KNEW the board was good as Ubuntu flashed it fine.
I then opened the serial console as the loaded script on the Nano was outputting data. This worked! I could see data in the console. I hit upload and away it went.
Hope this helps someone else.
Sketch uses 7708 bytes (23%) of program storage space. Maximum is 32256 bytes.
Global variables use 496 bytes (24%) of dynamic memory, leaving 1552 bytes for local variables. Maximum is 2048 bytes.
"C:\Users\coldfire\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/bin/avrdude" "-CC:\Users\coldfire\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf" -v -V -patmega328p -carduino "-PCOM3" -b115200 -D "-Uflash:w:C:\Users\coldfire\AppData\Local\Temp\arduino\sketches\D20F289404B7EA2FE53C55B9838D1A8F/clg.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\coldfire\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf"
Using Port : COM3
Using Programmer : arduino
Overriding Baud Rate : 115200
avrdude: ser_open(): can't set com-state for "\\.\COM3"
avrdude done. Thank you.
Failed uploading: uploading error: exit status 1
Sketch uses 7708 bytes (23%) of program storage space. Maximum is 32256 bytes.
Global variables use 496 bytes (24%) of dynamic memory, leaving 1552 bytes for local variables. Maximum is 2048 bytes.
"C:\Users\coldfire\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/bin/avrdude" "-CC:\Users\coldfire\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf" -v -V -patmega328p -carduino "-PCOM3" -b115200 -D "-Uflash:w:C:\Users\coldfire\AppData\Local\Temp\arduino\sketches\D20F289404B7EA2FE53C55B9838D1A8F/clg.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\coldfire\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf"
Using Port : COM3
Using Programmer : arduino
Overriding Baud Rate : 115200
AVR Part : ATmega328P
Chip Erase delay : 9000 us
PAGEL : PD7
BS2 : PC2
RESET disposition : dedicated
RETRY pulse : SCK
serial program mode : yes
parallel program mode : yes
Timeout : 200
StabDelay : 100
CmdexeDelay : 25
SyncLoops : 32
ByteDelay : 0
PollIndex : 3
PollValue : 0x53
Memory Detail :
Block Poll Page Polled
Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack
----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
eeprom 65 20 4 0 no 1024 4 0 3600 3600 0xff 0xff
flash 65 6 128 0 yes 32768 128 256 4500 4500 0xff 0xff
lfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
hfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
efuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
lock 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
calibration 0 0 0 0 no 1 0 0 0 0 0x00 0x00
signature 0 0 0 0 no 3 0 0 0 0 0x00 0x00
Programmer Type : Arduino
Description : Arduino
Hardware Version: 3
Firmware Version: 4.4
avrdude: stk500_recv(): programmer is not responding
Vtarget : 0.3 V
Varef : 0.3 V
Oscillator : 0.017 Hz
SCK period : 3.3 us
avrdude: stk500_recv(): programmer is not responding
avrdude: AVR device initialized and ready to accept instructions
Reading | avrdude: error reading signature data for part "ATmega328P", rc=-1
avrdude: error reading signature data, rc=-1
avrdude done. Thank you.
Failed uploading: uploading error: exit status 1
uploaded again and got this output
This is an issue in IDE 2.0.0 rc2 (may or may not apply to you). If you have more than one window open, ensure the serial monitor is not open in any other window. This is a simple mistake: if you have the serial monitor open in the window you are working in, then inadvertently open another window (e.g. you open an example script to compare codes), the serial monitor will automatically open in the new window as well. It appears that 2.0.0 rc2 has an issue with not being able to focus on one window.
@timinelmira, this topic was posted in the IDE 1.x category so we assume that OP uses IDE 1.x
Further IDE 2.0.0 rc2 is so old that it would be advisable to upgraded to IDE 2.1 (in case you haven't done so yet.
From this path in the output @coldfire23 shared I could see they are using Arduino IDE 2.x. The topic has been moved to the appropriate "IDE 2.x" forum category.
There were some previous reports of this "can't set com-state ...
" error occurring specifically when using 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.
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.
- 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 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.
Once the port has reappeared in Device Manager, start Arduino IDE again and try uploading again. Reply here to let us know whether the error still occurs.
Sketch uses 7708 bytes (23%) of program storage space. Maximum is 32256 bytes.
Global variables use 496 bytes (24%) of dynamic memory, leaving 1552 bytes for local variables. Maximum is 2048 bytes.
"C:\Users\coldfire\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/bin/avrdude" "-CC:\Users\coldfire\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf" -v -V -patmega328p -carduino "-PCOM3" -b115200 -D "-Uflash:w:C:\Users\coldfire\AppData\Local\Temp\arduino\sketches\D20F289404B7EA2FE53C55B9838D1A8F/clg.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\coldfire\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf"
Using Port : COM3
Using Programmer : arduino
Overriding Baud Rate : 115200
AVR Part : ATmega328P
Chip Erase delay : 9000 us
PAGEL : PD7
BS2 : PC2
RESET disposition : dedicated
RETRY pulse : SCK
serial program mode : yes
parallel program mode : yes
Timeout : 200
StabDelay : 100
CmdexeDelay : 25
SyncLoops : 32
ByteDelay : 0
PollIndex : 3
PollValue : 0x53
Memory Detail :
Block Poll Page Polled
Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack
----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
eeprom 65 20 4 0 no 1024 4 0 3600 3600 0xff 0xff
flash 65 6 128 0 yes 32768 128 256 4500 4500 0xff 0xff
lfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
hfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
efuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
lock 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
calibration 0 0 0 0 no 1 0 0 0 0 0x00 0x00
signature 0 0 0 0 no 3 0 0 0 0 0x00 0x00
Programmer Type : Arduino
Description : Arduino
Hardware Version: 3
Firmware Version: 4.4
Vtarget : 0.3 V
Varef : 0.3 V
Oscillator : 28.800 kHz
SCK period : 3.3 us
avrdude: stk500_recv(): programmer is not responding
avrdude: initialization failed, rc=-1
Double check connections and try again, or use -F to override
this check.
avrdude done. Thank you.
Failed uploading: uploading error: exit status 1
I followed your steps and tried uploading again and got this error.
A post was merged into an existing topic: Avrdude: ser_open(): can't set com-state for "\.\COM5" Failed uploading: uploading error: exit status 1
FQBN: arduino:avr:nano
Using board 'nano' from platform in folder: C:\Users\gazev\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6
Using core 'arduino' from platform in folder: C:\Users\gazev\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6
Detecting libraries used...
"C:\\Users\\gazev\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR "-IC:\\Users\\gazev\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.6\\cores\\arduino" "-IC:\\Users\\gazev\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.6\\variants\\eightanaloginputs" "C:\\Users\\gazev\\AppData\\Local\\Temp\\arduino\\sketches\\5AA1475716E404D81CF2646631659A96\\sketch\\sensor.ino.cpp" -o nul
Generating function prototypes...
"C:\\Users\\gazev\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR "-IC:\\Users\\gazev\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.6\\cores\\arduino" "-IC:\\Users\\gazev\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.6\\variants\\eightanaloginputs" "C:\\Users\\gazev\\AppData\\Local\\Temp\\arduino\\sketches\\5AA1475716E404D81CF2646631659A96\\sketch\\sensor.ino.cpp" -o "C:\\Users\\gazev\\AppData\\Local\\Temp\\arduino\\sketches\\5AA1475716E404D81CF2646631659A96\\preproc\\ctags_target_for_gcc_minus_e.cpp"
"C:\\Users\\gazev\\AppData\\Local\\Arduino15\\packages\\builtin\\tools\\ctags\\5.8-arduino11/ctags" -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives "C:\\Users\\gazev\\AppData\\Local\\Temp\\arduino\\sketches\\5AA1475716E404D81CF2646631659A96\\preproc\\ctags_target_for_gcc_minus_e.cpp"
Compiling sketch...
"C:\\Users\\gazev\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR "-IC:\\Users\\gazev\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.6\\cores\\arduino" "-IC:\\Users\\gazev\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.6\\variants\\eightanaloginputs" "C:\\Users\\gazev\\AppData\\Local\\Temp\\arduino\\sketches\\5AA1475716E404D81CF2646631659A96\\sketch\\sensor.ino.cpp" -o "C:\\Users\\gazev\\AppData\\Local\\Temp\\arduino\\sketches\\5AA1475716E404D81CF2646631659A96\\sketch\\sensor.ino.cpp.o"
Compiling libraries...
Compiling core...
Using precompiled core: C:\Users\gazev\AppData\Local\Temp\arduino\cores\arduino_avr_nano_cpu_atmega328_a5dd524945e26afede5edaa0691a6b66\core.a
Linking everything together...
"C:\\Users\\gazev\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-gcc" -w -Os -g -flto -fuse-linker-plugin -Wl,--gc-sections -mmcu=atmega328p -o "C:\\Users\\gazev\\AppData\\Local\\Temp\\arduino\\sketches\\5AA1475716E404D81CF2646631659A96/sensor.ino.elf" "C:\\Users\\gazev\\AppData\\Local\\Temp\\arduino\\sketches\\5AA1475716E404D81CF2646631659A96\\sketch\\sensor.ino.cpp.o" "C:\\Users\\gazev\\AppData\\Local\\Temp\\arduino\\sketches\\5AA1475716E404D81CF2646631659A96/..\\..\\cores\\arduino_avr_nano_cpu_atmega328_a5dd524945e26afede5edaa0691a6b66\\core.a" "-LC:\\Users\\gazev\\AppData\\Local\\Temp\\arduino\\sketches\\5AA1475716E404D81CF2646631659A96" -lm
"C:\\Users\\gazev\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-objcopy" -O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 "C:\\Users\\gazev\\AppData\\Local\\Temp\\arduino\\sketches\\5AA1475716E404D81CF2646631659A96/sensor.ino.elf" "C:\\Users\\gazev\\AppData\\Local\\Temp\\arduino\\sketches\\5AA1475716E404D81CF2646631659A96/sensor.ino.eep"
"C:\\Users\\gazev\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-objcopy" -O ihex -R .eeprom "C:\\Users\\gazev\\AppData\\Local\\Temp\\arduino\\sketches\\5AA1475716E404D81CF2646631659A96/sensor.ino.elf" "C:\\Users\\gazev\\AppData\\Local\\Temp\\arduino\\sketches\\5AA1475716E404D81CF2646631659A96/sensor.ino.hex"
"C:\\Users\\gazev\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-size" -A "C:\\Users\\gazev\\AppData\\Local\\Temp\\arduino\\sketches\\5AA1475716E404D81CF2646631659A96/sensor.ino.elf"
Sketch uses 2508 bytes (8%) of program storage space. Maximum is 30720 bytes.
Global variables use 190 bytes (9%) of dynamic memory, leaving 1858 bytes for local variables. Maximum is 2048 bytes.
avrdude: ser_open(): can't set com-state for "\\.\COM30"
Failed uploading: uploading error: exit status 1
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.
The 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. Please reply here to let us know whether the error still occurs.
ptillisch i got the pop up saying the best driver are already installed
pls guide me further i have an important project to create
Hi @ihateavrdude. Please follow these instructions and then reply here on the forum thread to let us know what you found:
- 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.
Do you see "3.4.2014.8" after the "Driver Version" in that "USB-SERIAL CH340 (COM_n_) Properties" dialog?
If it is important, I recommend you buy a replacement board. This error seems to be specific to the very cheap Chinese boards of questionable provenance. Most of the affected users have managed to get the boards working eventually, but you are taking a very big risk if you are depending on low quality hardware for an important project. It would be wise to source your hardware for an important project from a reputable supplier.
i agree i ordered one now thanks for the heads up
from now on i wont rely on these cheap chinese boards thanks