An “avrdude: ser_open(): can't set com-state for COMn
” error can occur 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, and can be solved by installing a previous release.
Download and install version 3.7.2022.01 of the driver
Follow these steps:
-
Download version 3.7.2022.01 of the driver.
-
Run the downloaded
CH341SER.EXE
file. -
A User Account Control dialog may now appear. Click the
Yes
button. -
A DriverSetup(X64) dialog will appear. Click the
Install
button. -
Restart Arduino IDE and try to upload the sketch again.
To prevent Windows from automatically updating back to an incompatible version of the driver, use the Roll back driver feature in Device Manager.
Roll back the driver to stop automatic updates
Follow these steps:
-
Close the DriverSetup(X64) dialog and Arduino IDE if they are running.
-
Connect the Arduino board to your computer with a USB cable.
-
Open Device Manager from the Windows Start Menu.
-
Check your View settings:
-
View > Devices By Type should be selected.
-
Show Hidden Devices should be not be selected.
-
-
Open the
Ports (COM & LPT)
section. You should see a port identified asUSB-SERIAL CH340 (COM_n_)
Right-click on it and select Properties.
-
Select the
Driver
tab and confirm that 3.7.2022.1 is the installed driver version. -
To enable rolling back to version 3.7.2022.1, we need to switch to a different driver. Select Update Driver > Search automatically for drivers. You should now see the driver installation wizard update the driver to a more recent version.
Warning
It is possible you will instead see the message “The best drivers are already installed”. If so, follow these steps:
- Close the Driver update dialog.
- Download and install version 3.8.2023.2 of the driver
- Go back to device properties and select Update Driver > Browse my computer for drivers > Let me pick from a list of available drivers on my computer and install version 3.7.2022.1 again.
- Finally, try Update Driver > Search automatically for drivers again.
-
Confirm that the installed version is now 3.8.2023.2 (or later) and click the
Roll Back Driver
button. -
Now that the Driver Package rollback dialog is open, click the radio button next to My apps don’t work with this driver and press the
Yes
button to roll back the driver.