Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WCH CH340 serial port issue under Windows: can't set com-state for "\\.\COMx #1328

Closed
mcuee opened this issue Mar 25, 2023 · 11 comments
Closed
Labels
invalid This doesn't seem right

Comments

@mcuee
Copy link
Collaborator

mcuee commented Mar 25, 2023

I think this is not an avrdude issue but an WCH CH340 driver issue.

Still it is good to put some info here so that people can reference to it, since there are quite some similar issues posted online.

I was playing with CH341A yesterday and install the latest CH341SER driver for CH340/CH341. Then I was encountering the above issue. Reverting to an old version sorted out the issue for me -- I am using version 3.5 (3.5.2019.1) and it is working fine.

Problematic driver version:
http://www.wch-ic.com/downloads/CH341SER_EXE.html (version 3.8, uploaded on 2023-03-16, size 642KB)

; CH341SER.INF
; Driver for CH340/CH341 (USB=>SERIAL chip) V3.8
; WDM&VXD for Windows 98/Me/2000/XP/Vista/7/8/8.1/10/11/SERVER 2003/2008/2012/2016/2019/2022
; Copyright (C) WCH 2001-2023
;

[Version]
Signature   = "$Chicago$"
Class       = Ports
ClassGuid   = {4D36E978-E325-11CE-BFC1-08002BE10318}
Provider    = %WinChipHead%
DriverVer   = 02/11/2023, 3.8.2023.02
CatalogFile =CH341SER.CAT

Working driver version:

; CH341SER.INF
; Driver for CH340/CH341 (USB=>SERIAL chip) V3.5
; WDM&VXD for Windows 98/Me/2000/XP/Vista/7/8/8.1/10/SERVER 2003/2008/2012/2016
; Copyright (C) W.ch 2001-2019
;

[Version]
Signature   = "$Chicago$"
Class       = Ports
ClassGuid   = {4D36E978-E325-11CE-BFC1-08002BE10318}
Provider    = %WinChipHead%
DriverVer   = 01/30/2019, 3.5.2019.1
CatalogFile = CH341SER.CAT

If you can not find the older driver version, here is one link for version 3.5.
https://github.com/wemos/ch340_driver

Good and bad run log for reference:

PS C:\work\avr\avrdude_test\avrdude_bin> .\avrdude_pr1215v1 -C .\avrdude_pr1215v1.conf -p m328pb -c urclock -P COM4 -xshowall -xbootsize=512

avrdude_pr1215v1: AVR device initialized and ready to accept instructions
0 0000-00-00 00.00  application 0 store 0 meta 0 boot 512 o8.0 -?s-?-r-- vector 0 (RESET) ATmega328PB
PS C:\work\avr\avrdude_test\avrdude_bin> .\avrdude_pr1215v1 -C .\avrdude_pr1215v1.conf -p m328pb -c arduino -P COM4

avrdude_pr1215v1: AVR device initialized and ready to accept instructions
avrdude_pr1215v1: device signature = 0x1e9516 (probably m328pb)

avrdude_pr1215v1 done.  Thank you.

PS C:\work\avr\avrdude_test\avrdude_bin> .\avrdude_pr1215v1 -C .\avrdude_pr1215v1.conf -p m328pb -c arduino -P COM4
avrdude_pr1215v1 error: cannot set com-state for \\.\COM4
avrdude_pr1215v1 error: unable to open programmer arduino on port COM4

avrdude_pr1215v1 done.  Thank you.

PS C:\work\avr\avrdude_test\avrdude_bin> .\avrdude_pr1215v1 -C .\avrdude_pr1215v1.conf -p m328pb -c urclock -P COM4 -xshowall -xbootsize=512
avrdude_pr1215v1 error: cannot set com-state for \\.\COM4
avrdude_pr1215v1 error: unable to open programmer urclock on port COM4

avrdude_pr1215v1 done.  Thank you.

@mcuee mcuee added unconfirmed Maybe a bug, needs to be reproduced by someone else invalid This doesn't seem right and removed unconfirmed Maybe a bug, needs to be reproduced by someone else labels Mar 25, 2023
@mcuee
Copy link
Collaborator Author

mcuee commented Mar 25, 2023

@mcuee
Copy link
Collaborator Author

mcuee commented Mar 25, 2023

The following is a different issue but with the same symptom. It is not using CH340 but the original ATmega16U2 USB to Serial FW.
https://forum.arduino.cc/t/ser_open-can-t-set-com-state-for-com4-changes-uno-not-detected-solved/659323/8

@mcuee mcuee closed this as completed Mar 25, 2023
@mcuee
Copy link
Collaborator Author

mcuee commented Mar 25, 2023

I found a solution for using the latest version 3.8 driver (CH341SER 3.8 version). I need to click the check box in the advanced settings --> Enabling the Serial Port Enumerator (SerEnum). There are no checkboxes for the version 3.5 driver.

Screenshot 2023-03-25 182254

Capture_serenum

Before enabling the option and after enabling the option. I have no idea why WCH does not make this option default.

PS C:\work\avr\avrdude_test\avrdude_bin> .\avrdude_pr1215v1 -C .\avrdude_pr1215v1.conf -p m328pb -c arduino -P COM4
avrdude_pr1215v1 error: cannot set com-state for \\.\COM4
avrdude_pr1215v1 error: unable to open programmer arduino on port COM4

avrdude_pr1215v1 done.  Thank you.

PS C:\work\avr\avrdude_test\avrdude_bin> .\avrdude_pr1215v1 -C .\avrdude_pr1215v1.conf -p m328pb -c arduino -P COM4

avrdude_pr1215v1: AVR device initialized and ready to accept instructions
avrdude_pr1215v1: device signature = 0x1e9516 (probably m328pb)

avrdude_pr1215v1 done.  Thank you.

@mcuee
Copy link
Collaborator Author

mcuee commented Mar 27, 2023

Somehow this is dependent on the PC.
I do not need to enable serenum to get the thing working on my other laptop running Windows 10.

C:\work\avr\avrdude_test\avrdude_bin> .\avrdude -c urclock -P COM4 -p m328p -xshowall

avrdude: AVR device initialized and ready to accept instructions
0 0000-00-00 00.00  application 0 store 0 meta 0 boot 512 o4.4 --s-h-r-- vector 0 (RESET) ATmega328P

Capture_Driver_No_SerEnum

@mcuee
Copy link
Collaborator Author

mcuee commented Jul 18, 2023

I have to use older version of the driver to work reliably in the end. The new version just does not work properly.

@MCUdude
Copy link
Collaborator

MCUdude commented Jul 19, 2023

In case someone else are having the same issue, what driver version are you using (that works), and where did you download it from?

@per1234
Copy link
Contributor

per1234 commented Jul 19, 2023

Since I was not able to find a way to source an older version of the driver directly from the WCH website, I am recommending sourcing it from a SparkFun tutorial since I consider SparkFun to be a trustworthy source. The instructions are here:

https://forum.arduino.cc/t/arduino-nano-upload-error/1146296/14

@mcuee
Copy link
Collaborator Author

mcuee commented Jul 19, 2023

Yes, SparkFun version (WCH driver version 3.4) works fine.

@mcuee
Copy link
Collaborator Author

mcuee commented Jul 19, 2023

I will carry out a bit more tests to see which version does not work and which versions work. I believe all the older versions (3.7 and earlier) work fine except latest version 3.8 but I need to double check.

Version 3.8 does not work reliably (my test shows problem only in Windows 11 but not Windows 10).
https://wch-ic.com/downloads/CH341SER_ZIP.html
https://wch-ic.com/downloads/CH341SER_EXE.html

The scope of application version upload time size
CH340G,CH340T,CH340C,CH340E,CH340B,CH341A,CH341T,CH341B,CH341C,CH341U 3.8 2023-03-16 642KB

CH341SER_v38.ZIP

@mcuee
Copy link
Collaborator Author

mcuee commented Jul 19, 2023

Another reliable place to download is from Microsoft. They have version 3.8.2023.2 (problem version), version 3.5.2019.1 and version 3.4.2014.08 (both are working). There is no driver installer included but you can use Windows Device Manager to install the driver.
https://www.catalog.update.microsoft.com/Search.aspx?q=CH340
wch340_v34.zip
wch340_v35.zip
wch340_v38.zip

@mcuee
Copy link
Collaborator Author

mcuee commented Oct 29, 2023

Interestingly I do not seem to have issues using serialupdi with latest driver.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

3 participants