Arduino Nano clone unable to receive new code

I've got an Arduino Nano clone, which I've so far been able to make work on several different pieces of code (including displaying text on an LCD display and hooking it up to a trimpot to display values on Serial monitor). If it matters, I've been using Arduino IDE on a Lenovo Thinkpad laptop running Windows 11. A slight oddity I've had to deal with so far is that I've almost always had to have both the Serial monitor open in order to get it to successfully upload code.
The last sketch I uploaded had the following code:

char TestMsg[]="Test message";
int sizeMsg = sizeof(TestMsg);
void setup() {
  Serial.begin(19200);
}

void loop(){
  for(int i=0; i<sizeMsg; i++){
      Serial.print(TestMsg[i]);
  }
  Serial.println(" ");
  delay(500);
}

It worked about once or twice while connected to the Serial monitor, but after that, the board was unable to hook up to the Serial monitor. Here's what I've tried:

  1. Connecting the board to either one of the computer's two USB ports (which show up as COM5 and COM6)
  2. Uninstalling the device from Device Manager, then uninstalling the CH340 driver, and reinstalling it
  3. Modifying the baud rate for the CH340 driver from 9600 bps to 19200 bps
  4. Trying to upload a blank sketch, and repeating steps 1-3
  5. Trying to upload a blank sketch with the reset button held pressed down
  6. Same as no. 5, but with the reset button released just as soon as "Uploading" appears on screen
  7. Same as no. 5, but with the Serial monitor closed
  8. Clicking on "Burn bootloader" and then going through each one of the programmers, testing with both the Serial monitor closed and open.
    So far, the only difference I've noticed between leaving the Serial monitor tab open and closing it is that it takes longer for the upload/bootloader error to pop up if the Serial monitor is open.
    The only thing I can tell about the Arduino itself is that the TX LED is still blinking, which indicates to me that it's still "transmitting" the test message.
    Here's the upload error message for the blank sketch, in case anyone's interested:
Sketch uses 444 bytes (1%) 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\spepsus\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/bin/avrdude" "-CC:\Users\spepsus\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf" -v -V -patmega328p -carduino "-PCOM5" -b57600 -D "-Uflash:w:C:\Users\spepsus\AppData\Local\arduino\sketches\5DDB10730713322A8B847611E649B867/sketch_feb27a.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\spepsus\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf"

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

avrdude done.  Thank you.

Failed uploading: uploading error: exit status 1

Hi @spepsus.

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 workaround for the problem is to perform a "roll back" to an older version of the driver that is compatible with these problematic "CH340" chips. I'll provide instructions you can follow to do that:

  1. 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
  2. Wait for the download to finish.
  3. Run the downloaded CH341SER.EXE file.
  4. 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.
  5. A "DriverSetup(X64)" dialog will open. Click the "INSTALL" button in the dialog.
  6. Wait for the driver installation to finish, as indicated by the appearance of a "Driver install success!" dialog.
  7. Click the "OK" button in the "Driver install success!" dialog.
    The dialog will close.
  8. Click the X icon at the top right of the "DriverSetup(X64)" dialog
    The dialog will close.
  9. Close Arduino IDE if it is running.
  10. Connect the Arduino board to your computer with a USB cable.
  11. Open the Windows Device Manager.
  12. Select View > Devices by type from the Device Manager menus.
  13. Open the "View" menu.
  14. If there is a to the left of the "Show hidden devices" menu item, click on "Show hidden devices" to disable it.
  15. Open the "Ports (COM & LPT)" section of the Device Manager tree.
  16. 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.
  17. Select the "Driver" tab of the "USB-SERIAL CH340 (COMn) Properties" dialog.
  18. You will see a "Roll Back Driver" button in the dialog. If it is not clickable, perform the following instructions:
    1. Click the "Update driver" button.
      An "Update Drivers Device - USB-SERIAL CH340 (COMn)" dialog will open.
    2. Click on "Search automatically for drivers" in the "Update Drivers Device - USB-SERIAL CH340 (COMn)" dialog.
    3. 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.
      :exclamation: 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.
    4. Click the "Close" button in the "Update Drivers Device - USB-SERIAL CH340 (COMn)" dialog.
      The dialog will close.
  19. Click the "Roll Back Driver" button in the "USB-SERIAL CH340 (COMn) Properties" dialog.
    The "Driver Package rollback" dialog will open.
  20. Click the radio button next to "My apps don't work with this driver" in the "Driver Package rollback" dialog .
  21. Click the "Yes" button.
    The "Driver Package rollback" dialog will close.
  22. 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.

Try selecting the "Old bootloader" option in the "Tools/Processor" submenu.

Praise the Lord. Hallelujah! My Arduino Nano-like board finally worked again after installing the CH340 driver from the link you gave.

You are welcome. I'm glad it is working now.

Regards, Per