Upload fails: 'avrdude: ser_open(): can't set com-state for "\\.\COM6"'

type or paste code hereFQBN: arduino:avr:uno
Using board 'uno' from platform in folder: C:\Users\Anusha Mahesh\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6
Using core 'arduino' from platform in folder: C:\Users\Anusha Mahesh\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6

Detecting libraries used...
"C:\\Users\\Anusha Mahesh\\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_UNO -DARDUINO_ARCH_AVR "-IC:\\Users\\Anusha Mahesh\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.6\\cores\\arduino" "-IC:\\Users\\Anusha Mahesh\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.6\\variants\\standard" "C:\\Users\\Anusha Mahesh\\AppData\\Local\\Temp\\arduino\\sketches\\D79AFB82C4614E9E966FCD51B62180A8\\sketch\\coin.ino.cpp" -o nul
Alternatives for LiquidCrystal.h: [LiquidCrystal@1.0.7]
ResolveLibrary(LiquidCrystal.h)
  -> candidates: [LiquidCrystal@1.0.7]
"C:\\Users\\Anusha Mahesh\\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_UNO -DARDUINO_ARCH_AVR "-IC:\\Users\\Anusha Mahesh\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.6\\cores\\arduino" "-IC:\\Users\\Anusha Mahesh\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.6\\variants\\standard" "-IC:\\Users\\Anusha Mahesh\\AppData\\Local\\Arduino15\\libraries\\LiquidCrystal\\src" "C:\\Users\\Anusha Mahesh\\AppData\\Local\\Temp\\arduino\\sketches\\D79AFB82C4614E9E966FCD51B62180A8\\sketch\\coin.ino.cpp" -o nul
Using cached library dependencies for file: C:\Users\Anusha Mahesh\AppData\Local\Arduino15\libraries\LiquidCrystal\src\LiquidCrystal.cpp
Generating function prototypes...
"C:\\Users\\Anusha Mahesh\\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_UNO -DARDUINO_ARCH_AVR "-IC:\\Users\\Anusha Mahesh\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.6\\cores\\arduino" "-IC:\\Users\\Anusha Mahesh\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.6\\variants\\standard" "-IC:\\Users\\Anusha Mahesh\\AppData\\Local\\Arduino15\\libraries\\LiquidCrystal\\src" "C:\\Users\\Anusha Mahesh\\AppData\\Local\\Temp\\arduino\\sketches\\D79AFB82C4614E9E966FCD51B62180A8\\sketch\\coin.ino.cpp" -o "C:\\Users\\Anusha Mahesh\\AppData\\Local\\Temp\\arduino\\sketches\\D79AFB82C4614E9E966FCD51B62180A8\\preproc\\ctags_target_for_gcc_minus_e.cpp"
"C:\\Users\\Anusha Mahesh\\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\\Anusha Mahesh\\AppData\\Local\\Temp\\arduino\\sketches\\D79AFB82C4614E9E966FCD51B62180A8\\preproc\\ctags_target_for_gcc_minus_e.cpp"
Compiling sketch...
"C:\\Users\\Anusha Mahesh\\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_UNO -DARDUINO_ARCH_AVR "-IC:\\Users\\Anusha Mahesh\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.6\\cores\\arduino" "-IC:\\Users\\Anusha Mahesh\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.6\\variants\\standard" "-IC:\\Users\\Anusha Mahesh\\AppData\\Local\\Arduino15\\libraries\\LiquidCrystal\\src" "C:\\Users\\Anusha Mahesh\\AppData\\Local\\Temp\\arduino\\sketches\\D79AFB82C4614E9E966FCD51B62180A8\\sketch\\coin.ino.cpp" -o "C:\\Users\\Anusha Mahesh\\AppData\\Local\\Temp\\arduino\\sketches\\D79AFB82C4614E9E966FCD51B62180A8\\sketch\\coin.ino.cpp.o"
Compiling libraries...
Compiling library "LiquidCrystal"
Using previously compiled file: C:\Users\Anusha Mahesh\AppData\Local\Temp\arduino\sketches\D79AFB82C4614E9E966FCD51B62180A8\libraries\LiquidCrystal\LiquidCrystal.cpp.o
Compiling core...
Using precompiled core: C:\Users\Anusha Mahesh\AppData\Local\Temp\arduino\cores\arduino_avr_uno_f7f0c9e8ece0c7400ab8f1c954e910cb\core.a
Linking everything together...
"C:\\Users\\Anusha Mahesh\\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\\Anusha Mahesh\\AppData\\Local\\Temp\\arduino\\sketches\\D79AFB82C4614E9E966FCD51B62180A8/coin.ino.elf" "C:\\Users\\Anusha Mahesh\\AppData\\Local\\Temp\\arduino\\sketches\\D79AFB82C4614E9E966FCD51B62180A8\\sketch\\coin.ino.cpp.o" "C:\\Users\\Anusha Mahesh\\AppData\\Local\\Temp\\arduino\\sketches\\D79AFB82C4614E9E966FCD51B62180A8\\libraries\\LiquidCrystal\\LiquidCrystal.cpp.o" "C:\\Users\\Anusha Mahesh\\AppData\\Local\\Temp\\arduino\\sketches\\D79AFB82C4614E9E966FCD51B62180A8/..\\..\\cores\\arduino_avr_uno_f7f0c9e8ece0c7400ab8f1c954e910cb\\core.a" "-LC:\\Users\\Anusha Mahesh\\AppData\\Local\\Temp\\arduino\\sketches\\D79AFB82C4614E9E966FCD51B62180A8" -lm
"C:\\Users\\Anusha Mahesh\\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\\Anusha Mahesh\\AppData\\Local\\Temp\\arduino\\sketches\\D79AFB82C4614E9E966FCD51B62180A8/coin.ino.elf" "C:\\Users\\Anusha Mahesh\\AppData\\Local\\Temp\\arduino\\sketches\\D79AFB82C4614E9E966FCD51B62180A8/coin.ino.eep"
"C:\\Users\\Anusha Mahesh\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-objcopy" -O ihex -R .eeprom "C:\\Users\\Anusha Mahesh\\AppData\\Local\\Temp\\arduino\\sketches\\D79AFB82C4614E9E966FCD51B62180A8/coin.ino.elf" "C:\\Users\\Anusha Mahesh\\AppData\\Local\\Temp\\arduino\\sketches\\D79AFB82C4614E9E966FCD51B62180A8/coin.ino.hex"

Using library LiquidCrystal at version 1.0.7 in folder: C:\Users\Anusha Mahesh\AppData\Local\Arduino15\libraries\LiquidCrystal 
"C:\\Users\\Anusha Mahesh\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-size" -A "C:\\Users\\Anusha Mahesh\\AppData\\Local\\Temp\\arduino\\sketches\\D79AFB82C4614E9E966FCD51B62180A8/coin.ino.elf"
Sketch uses 2720 bytes (8%) of program storage space. Maximum is 32256 bytes.
Global variables use 185 bytes (9%) of dynamic memory, leaving 1863 bytes for local variables. Maximum is 2048 bytes.
"C:\Users\Anusha Mahesh\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/bin/avrdude" "-CC:\Users\Anusha Mahesh\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf" -v -V -patmega328p -carduino "-PCOM6" -b115200 -D "-Uflash:w:C:\Users\Anusha Mahesh\AppData\Local\Temp\arduino\sketches\D79AFB82C4614E9E966FCD51B62180A8/coin.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\Anusha Mahesh\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf"

         Using Port                    : COM6
         Using Programmer              : arduino
         Overriding Baud Rate          : 115200
avrdude: ser_open(): can't set com-state for "\\.\COM6"

avrdude done.  Thank you.

Failed uploading: uploading error: exit status 1
2 Likes

Hi @elecenggstu.

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:

  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.

2 Likes

yes, thank you. That worked. The code was uploaded to board. The driver was the problem. But the laptop wire I have is too small, so I'm buying a supply wire(?) for it, so there's no output yet

You are welcome. I'm glad if I was able to be of assistance.

Regards,
Per

A post was split to a new topic: LCD is showing the error and not the messages I want it to

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