Hi,
I cant upload a code to my Arduino Nano with CH340 chip with IDE 2.0. It keeps printing this error and I have already tried everything like restarting the borad, restarting a PC and even burning a new bootloader with Arduino Uno over ISP. Nothing helped and even if I try to acces serial monitor from IDE 2.0, the board just keeps restarting. Everything works fine with IDE 1.8 so I dont know where is the problem. Any ideas? Thanks for your replies.

Hi @vasik006. This "can't set com-state for ..." error occurs when uploading to the boards that use specific batches of the WCH CH340 USB chip. The problem only occurs when using the latest version of the CH340 driver.
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 you can follow to do that:
- Click the following link to download the previous version of the driver from the chip manufacturer's website:
https://www.wch-ic.com/downloads/file/65.html?time=2023-03-16%2022:57:59 - Wait for the download to finish.
- Run the downloaded
CH341SER.EXEfile. - 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 open. 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 (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 "Driver" tab of the "USB-SERIAL CH340 (COMn) Properties" dialog.
- You will see a "Roll Back Driver" button in the dialog. If it is not clickable, perform the following instructions:
- Click the "Update driver" button.
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.
The dialog will close.
- Click the "Update driver" button.
- 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.
The "Driver Package rollback" dialog will close. - 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 can't remember to have seen the scenario where, on the same computer, IDE 2.x has the problem and IDE 1.8.x doesn't.
If this is indeed on the same computer, I think it will be interesting to see the differences between the two setups. Please enable verbose output during compilation and enable verbose output during upload for both IDEs, compile a simple sketch in both of them and post the results for each.
That way those in the know may be able to find some possible useful information.
To my knowledge, this is the latest solution: Port monitor error: command 'open' failed: Invalid serial port. Could not connect to COM serial port - #49 by ptillisch
Any explanation why IDE 1.8.x works fine and IDE 2.x doesn't. If this is on the same PC, the driver should not make a difference ??
IDE 1.8 (it sometimes gives the same error but after opneing and closing serial monitor, it works)
C:\Program Files (x86)\Arduino\arduino-builder -dump-prefs -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -hardware C:\Users\Vaclav\AppData\Local\Arduino15\packages -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -tools C:\Users\Vaclav\AppData\Local\Arduino15\packages -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\Vaclav\Documents\Arduino\libraries -fqbn=arduino:avr:nano:cpu=atmega328 -vid-pid=1A86_7523 -ide-version=10819 -build-path C:\Users\Vaclav\AppData\Local\Temp\arduino_build_496396 -warnings=none -build-cache C:\Users\Vaclav\AppData\Local\Temp\arduino_cache_769565 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.arduinoOTA.path=C:\Users\Vaclav\AppData\Local\Arduino15\packages\arduino\tools\arduinoOTA\1.3.0 -prefs=runtime.tools.arduinoOTA-1.3.0.path=C:\Users\Vaclav\AppData\Local\Arduino15\packages\arduino\tools\arduinoOTA\1.3.0 -prefs=runtime.tools.avr-gcc.path=C:\Users\Vaclav\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7 -prefs=runtime.tools.avr-gcc-7.3.0-atmel3.6.1-arduino7.path=C:\Users\Vaclav\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7 -prefs=runtime.tools.avrdude.path=C:\Users\Vaclav\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17 -prefs=runtime.tools.avrdude-6.3.0-arduino17.path=C:\Users\Vaclav\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17 -verbose C:\Program Files (x86)\Arduino\examples\01.Basics\Blink\Blink.ino
C:\Program Files (x86)\Arduino\arduino-builder -compile -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -hardware C:\Users\Vaclav\AppData\Local\Arduino15\packages -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -tools C:\Users\Vaclav\AppData\Local\Arduino15\packages -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\Vaclav\Documents\Arduino\libraries -fqbn=arduino:avr:nano:cpu=atmega328 -vid-pid=1A86_7523 -ide-version=10819 -build-path C:\Users\Vaclav\AppData\Local\Temp\arduino_build_496396 -warnings=none -build-cache C:\Users\Vaclav\AppData\Local\Temp\arduino_cache_769565 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.arduinoOTA.path=C:\Users\Vaclav\AppData\Local\Arduino15\packages\arduino\tools\arduinoOTA\1.3.0 -prefs=runtime.tools.arduinoOTA-1.3.0.path=C:\Users\Vaclav\AppData\Local\Arduino15\packages\arduino\tools\arduinoOTA\1.3.0 -prefs=runtime.tools.avr-gcc.path=C:\Users\Vaclav\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7 -prefs=runtime.tools.avr-gcc-7.3.0-atmel3.6.1-arduino7.path=C:\Users\Vaclav\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7 -prefs=runtime.tools.avrdude.path=C:\Users\Vaclav\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17 -prefs=runtime.tools.avrdude-6.3.0-arduino17.path=C:\Users\Vaclav\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17 -verbose C:\Program Files (x86)\Arduino\examples\01.Basics\Blink\Blink.ino
Using board 'nano' from platform in folder: C:\Users\Vaclav\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6
Using core 'arduino' from platform in folder: C:\Users\Vaclav\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6
Detecting libraries used...
"C:\\Users\\Vaclav\\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=10819 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR "-IC:\\Users\\Vaclav\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.6\\cores\\arduino" "-IC:\\Users\\Vaclav\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.6\\variants\\eightanaloginputs" "C:\\Users\\Vaclav\\AppData\\Local\\Temp\\arduino_build_496396\\sketch\\Blink.ino.cpp" -o nul
Generating function prototypes...
"C:\\Users\\Vaclav\\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=10819 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR "-IC:\\Users\\Vaclav\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.6\\cores\\arduino" "-IC:\\Users\\Vaclav\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.6\\variants\\eightanaloginputs" "C:\\Users\\Vaclav\\AppData\\Local\\Temp\\arduino_build_496396\\sketch\\Blink.ino.cpp" -o "C:\\Users\\Vaclav\\AppData\\Local\\Temp\\arduino_build_496396\\preproc\\ctags_target_for_gcc_minus_e.cpp"
"C:\\Program Files (x86)\\Arduino\\tools-builder\\ctags\\5.8-arduino11/ctags" -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives "C:\\Users\\Vaclav\\AppData\\Local\\Temp\\arduino_build_496396\\preproc\\ctags_target_for_gcc_minus_e.cpp"
Kompiluji projekt...
"C:\\Users\\Vaclav\\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=10819 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR "-IC:\\Users\\Vaclav\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.6\\cores\\arduino" "-IC:\\Users\\Vaclav\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.6\\variants\\eightanaloginputs" "C:\\Users\\Vaclav\\AppData\\Local\\Temp\\arduino_build_496396\\sketch\\Blink.ino.cpp" -o "C:\\Users\\Vaclav\\AppData\\Local\\Temp\\arduino_build_496396\\sketch\\Blink.ino.cpp.o"
Compiling libraries...
Compiling core...
Using precompiled core: C:\Users\Vaclav\AppData\Local\Temp\arduino_cache_769565\core\core_arduino_avr_nano_cpu_atmega328_6f81b9d45f1476286c4bb2802862803f.a
Linking everything together...
"C:\\Users\\Vaclav\\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\\Vaclav\\AppData\\Local\\Temp\\arduino_build_496396/Blink.ino.elf" "C:\\Users\\Vaclav\\AppData\\Local\\Temp\\arduino_build_496396\\sketch\\Blink.ino.cpp.o" "C:\\Users\\Vaclav\\AppData\\Local\\Temp\\arduino_build_496396/..\\arduino_cache_769565\\core\\core_arduino_avr_nano_cpu_atmega328_6f81b9d45f1476286c4bb2802862803f.a" "-LC:\\Users\\Vaclav\\AppData\\Local\\Temp\\arduino_build_496396" -lm
"C:\\Users\\Vaclav\\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\\Vaclav\\AppData\\Local\\Temp\\arduino_build_496396/Blink.ino.elf" "C:\\Users\\Vaclav\\AppData\\Local\\Temp\\arduino_build_496396/Blink.ino.eep"
"C:\\Users\\Vaclav\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-objcopy" -O ihex -R .eeprom "C:\\Users\\Vaclav\\AppData\\Local\\Temp\\arduino_build_496396/Blink.ino.elf" "C:\\Users\\Vaclav\\AppData\\Local\\Temp\\arduino_build_496396/Blink.ino.hex"
"C:\\Users\\Vaclav\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-size" -A "C:\\Users\\Vaclav\\AppData\\Local\\Temp\\arduino_build_496396/Blink.ino.elf"
Projekt zabírá 924 bytů (3%) úložného místa pro program. Maximum je 30720 bytů.
Globální proměnné zabírají 9 bytů (0%) dynamické paměti, 2039 bytů zůstává pro lokální proměnné. Maximum je 2048 bytů.
C:\Users\Vaclav\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/bin/avrdude -CC:\Users\Vaclav\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf -v -patmega328p -carduino -PCOM5 -b115200 -D -Uflash:w:C:\Users\Vaclav\AppData\Local\Temp\arduino_build_496396/Blink.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\Vaclav\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf"
Using Port : COM5
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: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.00s
avrdude: Device signature = 0x1e950f (probably m328p)
avrdude: reading input file "C:\Users\Vaclav\AppData\Local\Temp\arduino_build_496396/Blink.ino.hex"
avrdude: writing flash (924 bytes):
Writing | ################################################## | 100% 0.18s
avrdude: 924 bytes of flash written
avrdude: verifying flash memory against C:\Users\Vaclav\AppData\Local\Temp\arduino_build_496396/Blink.ino.hex:
avrdude: load data flash data from input file C:\Users\Vaclav\AppData\Local\Temp\arduino_build_496396/Blink.ino.hex:
avrdude: input file C:\Users\Vaclav\AppData\Local\Temp\arduino_build_496396/Blink.ino.hex contains 924 bytes
avrdude: reading on-chip flash data:
Reading | ################################################## | 100% 0.14s
avrdude: verifying ...
avrdude: 924 bytes of flash verified
avrdude done. Thank you.
Now the IDE 2.0 which dosent work and serial monitor cant be opened.
FQBN: arduino:avr:nano
Using board 'nano' from platform in folder: C:\Users\Vaclav\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6
Using core 'arduino' from platform in folder: C:\Users\Vaclav\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6
Detecting libraries used...
C:\Users\Vaclav\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\Vaclav\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino -IC:\Users\Vaclav\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\variants\eightanaloginputs C:\Users\Vaclav\AppData\Local\Temp\arduino\sketches\72064AC982FC85D9CC401976F5DCADD1\sketch\Blink.ino.cpp -o nul
Generating function prototypes...
C:\Users\Vaclav\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\Vaclav\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino -IC:\Users\Vaclav\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\variants\eightanaloginputs C:\Users\Vaclav\AppData\Local\Temp\arduino\sketches\72064AC982FC85D9CC401976F5DCADD1\sketch\Blink.ino.cpp -o C:\Users\Vaclav\AppData\Local\Temp\1890688633\sketch_merged.cpp
C:\Users\Vaclav\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\Vaclav\AppData\Local\Temp\1890688633\sketch_merged.cpp
Compiling sketch...
"C:\\Users\\Vaclav\\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\\Vaclav\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.6\\cores\\arduino" "-IC:\\Users\\Vaclav\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.6\\variants\\eightanaloginputs" "C:\\Users\\Vaclav\\AppData\\Local\\Temp\\arduino\\sketches\\72064AC982FC85D9CC401976F5DCADD1\\sketch\\Blink.ino.cpp" -o "C:\\Users\\Vaclav\\AppData\\Local\\Temp\\arduino\\sketches\\72064AC982FC85D9CC401976F5DCADD1\\sketch\\Blink.ino.cpp.o"
Compiling libraries...
Compiling core...
Using precompiled core: C:\Users\Vaclav\AppData\Local\Temp\arduino\cores\arduino_avr_nano_cpu_atmega328_6f81b9d45f1476286c4bb2802862803f\core.a
Linking everything together...
"C:\\Users\\Vaclav\\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\\Vaclav\\AppData\\Local\\Temp\\arduino\\sketches\\72064AC982FC85D9CC401976F5DCADD1/Blink.ino.elf" "C:\\Users\\Vaclav\\AppData\\Local\\Temp\\arduino\\sketches\\72064AC982FC85D9CC401976F5DCADD1\\sketch\\Blink.ino.cpp.o" "C:\\Users\\Vaclav\\AppData\\Local\\Temp\\arduino\\sketches\\72064AC982FC85D9CC401976F5DCADD1/..\\..\\cores\\arduino_avr_nano_cpu_atmega328_6f81b9d45f1476286c4bb2802862803f\\core.a" "-LC:\\Users\\Vaclav\\AppData\\Local\\Temp\\arduino\\sketches\\72064AC982FC85D9CC401976F5DCADD1" -lm
"C:\\Users\\Vaclav\\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\\Vaclav\\AppData\\Local\\Temp\\arduino\\sketches\\72064AC982FC85D9CC401976F5DCADD1/Blink.ino.elf" "C:\\Users\\Vaclav\\AppData\\Local\\Temp\\arduino\\sketches\\72064AC982FC85D9CC401976F5DCADD1/Blink.ino.eep"
"C:\\Users\\Vaclav\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-objcopy" -O ihex -R .eeprom "C:\\Users\\Vaclav\\AppData\\Local\\Temp\\arduino\\sketches\\72064AC982FC85D9CC401976F5DCADD1/Blink.ino.elf" "C:\\Users\\Vaclav\\AppData\\Local\\Temp\\arduino\\sketches\\72064AC982FC85D9CC401976F5DCADD1/Blink.ino.hex"
"C:\\Users\\Vaclav\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-size" -A "C:\\Users\\Vaclav\\AppData\\Local\\Temp\\arduino\\sketches\\72064AC982FC85D9CC401976F5DCADD1/Blink.ino.elf"
Sketch uses 924 bytes (3%) 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\Vaclav\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/bin/avrdude" "-CC:\Users\Vaclav\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf" -v -V -patmega328p -carduino "-PCOM5" -b115200 -D "-Uflash:w:C:\Users\Vaclav\AppData\Local\Temp\arduino\sketches\72064AC982FC85D9CC401976F5DCADD1/Blink.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\Vaclav\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf"
Using Port : COM5
Using Programmer : arduino
Overriding Baud Rate : 115200
avrdude: ser_open(): can't set com-state for "\\.\COM5"
avrdude done. Thank you.
Failed uploading: uploading error: exit status 1
Thanks for a tutorial. Im stuck on a point 18.3. Im getting a message that I have already the best drivers installed and I cant click on "Roll Back Driver".
Hey, I think I just fixed it! I have downloaded CH340 driver from this site How to Install CH340 Drivers - SparkFun Learn and it is most probably older version of the driver. Thank you for your help and here is an output from IDE 2.0 where everything is OK.
FQBN: arduino:avr:nano
Using board 'nano' from platform in folder: C:\Users\Vaclav\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6
Using core 'arduino' from platform in folder: C:\Users\Vaclav\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6
Detecting libraries used...
C:\Users\Vaclav\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\Vaclav\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino -IC:\Users\Vaclav\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\variants\eightanaloginputs C:\Users\Vaclav\AppData\Local\Temp\arduino\sketches\D6AFFA0AD4FEBAC147241D54F0CE3141\sketch\Blink.ino.cpp -o nul
Generating function prototypes...
C:\Users\Vaclav\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\Vaclav\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino -IC:\Users\Vaclav\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\variants\eightanaloginputs C:\Users\Vaclav\AppData\Local\Temp\arduino\sketches\D6AFFA0AD4FEBAC147241D54F0CE3141\sketch\Blink.ino.cpp -o C:\Users\Vaclav\AppData\Local\Temp\2782780530\sketch_merged.cpp
C:\Users\Vaclav\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\Vaclav\AppData\Local\Temp\2782780530\sketch_merged.cpp
Compiling sketch...
"C:\\Users\\Vaclav\\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\\Vaclav\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.6\\cores\\arduino" "-IC:\\Users\\Vaclav\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.6\\variants\\eightanaloginputs" "C:\\Users\\Vaclav\\AppData\\Local\\Temp\\arduino\\sketches\\D6AFFA0AD4FEBAC147241D54F0CE3141\\sketch\\Blink.ino.cpp" -o "C:\\Users\\Vaclav\\AppData\\Local\\Temp\\arduino\\sketches\\D6AFFA0AD4FEBAC147241D54F0CE3141\\sketch\\Blink.ino.cpp.o"
Compiling libraries...
Compiling core...
Using precompiled core: C:\Users\Vaclav\AppData\Local\Temp\arduino\cores\arduino_avr_nano_cpu_atmega328_6f81b9d45f1476286c4bb2802862803f\core.a
Linking everything together...
"C:\\Users\\Vaclav\\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\\Vaclav\\AppData\\Local\\Temp\\arduino\\sketches\\D6AFFA0AD4FEBAC147241D54F0CE3141/Blink.ino.elf" "C:\\Users\\Vaclav\\AppData\\Local\\Temp\\arduino\\sketches\\D6AFFA0AD4FEBAC147241D54F0CE3141\\sketch\\Blink.ino.cpp.o" "C:\\Users\\Vaclav\\AppData\\Local\\Temp\\arduino\\sketches\\D6AFFA0AD4FEBAC147241D54F0CE3141/..\\..\\cores\\arduino_avr_nano_cpu_atmega328_6f81b9d45f1476286c4bb2802862803f\\core.a" "-LC:\\Users\\Vaclav\\AppData\\Local\\Temp\\arduino\\sketches\\D6AFFA0AD4FEBAC147241D54F0CE3141" -lm
"C:\\Users\\Vaclav\\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\\Vaclav\\AppData\\Local\\Temp\\arduino\\sketches\\D6AFFA0AD4FEBAC147241D54F0CE3141/Blink.ino.elf" "C:\\Users\\Vaclav\\AppData\\Local\\Temp\\arduino\\sketches\\D6AFFA0AD4FEBAC147241D54F0CE3141/Blink.ino.eep"
"C:\\Users\\Vaclav\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-objcopy" -O ihex -R .eeprom "C:\\Users\\Vaclav\\AppData\\Local\\Temp\\arduino\\sketches\\D6AFFA0AD4FEBAC147241D54F0CE3141/Blink.ino.elf" "C:\\Users\\Vaclav\\AppData\\Local\\Temp\\arduino\\sketches\\D6AFFA0AD4FEBAC147241D54F0CE3141/Blink.ino.hex"
"C:\\Users\\Vaclav\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-size" -A "C:\\Users\\Vaclav\\AppData\\Local\\Temp\\arduino\\sketches\\D6AFFA0AD4FEBAC147241D54F0CE3141/Blink.ino.elf"
Sketch uses 924 bytes (3%) 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\Vaclav\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/bin/avrdude" "-CC:\Users\Vaclav\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf" -v -V -patmega328p -carduino "-PCOM5" -b115200 -D "-Uflash:w:C:\Users\Vaclav\AppData\Local\Temp\arduino\sketches\D6AFFA0AD4FEBAC147241D54F0CE3141/Blink.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\Vaclav\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf"
Using Port : COM5
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: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.00s
avrdude: Device signature = 0x1e950f (probably m328p)
avrdude: reading input file "C:\Users\Vaclav\AppData\Local\Temp\arduino\sketches\D6AFFA0AD4FEBAC147241D54F0CE3141/Blink.ino.hex"
avrdude: writing flash (924 bytes):
Writing | ################################################## | 100% 0.18s
avrdude: 924 bytes of flash written
avrdude done. Thank you.
Unfortunately, no. I don't have any real understanding of the problem, or of how virtual COM ports work at a low level in general.
I can't reproduce the problem because I don't own a board with the sketchy CH340 chip so everything I know about the problem comes from the user reports.
I am interested in learning more about the subject since this is impacting a lot of users and increasing the burden on the forum helpers (some of the less distinctive mysterious upload errors reported by ESP32/ESP8266 board users are also surely caused by this problem), but it is also not something I can put a significant amount of effort towards since it is a self-inflicted problem caused by people buying low quality hardware from unreliable sources.
It is very interesting. There was a previous report of something similar here:
I also remember another report that the Arduino IDE 1.x Serial Monitor can connect to these boards even though the IDE 2.x Serial Monitor can not:
So it seems that there is something about the way the Arduino IDE 1.x Serial Monitor connects to the port that puts it in a state where AVRDUDE can work with the port even when the latest driver is in use. This points to the possibility of fixing the problem through a patch in the AVRDUDE codebase as well as the Arduino Serial Monitor codebase.
Congratulations on finding a solution! I'm glad it is working now. Thank you for taking the time to post an update.
Yeah, it is. I was previously using that SparkFun tutorial as the driver source in my instructions but later found a way to get the newer version directly from the chip manufacturer's website so I switched to that one since it is a more official driver source and because I figure it is generally better to use the newest possible version of a driver. But I never heard any reports of problems with the version of the driver from the SparkFun tutorial so you will probably be fine with that one.
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.