IDE 2.3.2 can't upload code

I have been trying to upload a graphics test to a nano (Not sure if this is important, but the IDE doesn't recognize the board) and I am getting an error, avrdude: ser_open(): can't set com-state for "\.\COM8". I have researched and discovered that other people have had the same issue as I have and it is tied to the way you open the IDE, but the issue was on a older version. I have tried the old solution but it doesn't work. I was wondering if I could get some help?
I have found many forums but none of them clearly explain the problem,
there is this one; Project A: [SOLVED] avrdude: ser_open(): can't set com-state for "\\.\COM6" but it seems a bit extreme.

Hi @martycat111. 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:

  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.

I got "The best drivers are already installed", should I specify the location of the driver?

I have found that when the driver installation gets into this state, it can be solved by uninstalling and then reinstalling the drivers. After that, the "roll back" option should be enabled.

I'll provide 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 Device Manager menus.
  5. Open the "View" menu.
  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 (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.
  9. Select the "Driver" tab of the "USB-SERIAL CH340 (COMn) Properties" dialog.
  10. Click the "Uninstall Device" button.
    The "Uninstall Device" dialog will open.
  11. Check the box next to "☐ Attempt to remove the driver for this device.".
  12. Click the "Uninstall" button.
    The "Uninstall Device" and "USB-SERIAL CH340 (COMn) Properties" dialogs will close.
  13. Disconnect the USB cable of the Arduino board from your computer.
  14. Reconnect the USB cable of the Arduino board to your computer.
  15. Wait for the "USB-SERIAL CH340 (COMn)" device to appear under the "Ports (COM & LPT)" section of the Device Manager tree.
    :exclamation: This will take a couple of minutes as Windows must first automatically reinstall the driver.
    :exclamation: It might appear first as a "USB2.0-Serial" device under the "Other devices section of the tree. Just wait for a little longer and it will appear in its final place under the "Ports (COM & LPT)" section.
  16. 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
  17. Wait for the download to finish.
  18. Run the downloaded CH341SER.EXE file.
  19. 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.
  20. A "DriverSetup(X64)" dialog will open. Click the "INSTALL" button in the dialog.
  21. Wait for the driver installation to finish, as indicated by the appearance of a "Driver install success!" dialog.
  22. Click the "OK" button in the "Driver install success!" dialog.
    The dialog will close.
  23. Click the X icon at the top right of the "DriverSetup(X64)" dialog.
    The dialog will close.
  24. Switch back to the Windows "Device Manager".
  25. Double click on the "USB-SERIAL CH340 (COMn)" device under the "Ports (COM & LPT)" section.
    The "USB-SERIAL CH340 (COMn) Properties" dialog will open.
  26. Select the "Driver" tab of the "USB-SERIAL CH340 (COMn) Properties" dialog.
  27. Click the "Update driver" button.
    An "Update Drivers Device - USB-SERIAL CH340 (COMn)" dialog will open.
  28. Click on "Search automatically for drivers" in the "Update Drivers Device - USB-SERIAL CH340 (COMn)" dialog.
  29. 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.
  30. Click the "Close" button in the "Update Drivers Device - USB-SERIAL CH340 (COMn)" dialog.
    The dialog will close.
  31. Click the "Roll Back Driver" button in the "USB-SERIAL CH340 (COMn) Properties" dialog.
    The "Driver Package rollback" dialog will open.
  32. Click the radio button next to "My apps don't work with this driver" in the "Driver Package rollback" dialog .
  33. Click the "Yes" button.
    The "Driver Package rollback" dialog will close.
  34. 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.

Thank you! Drivers rolled back successfully but had syncing issues with avrdude, I rebooted my device and same problem occurred. Problem log is:

avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0xd7
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0xd7
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0xd7
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0xd7
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0xd7
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0xd7
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0xd7
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0xd7
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0xd7
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0xd7

But I found another thread (uploading - "avrdude: stk500_getsync(): not in sync: resp=0x00," aka Some Dude Named Avr Won't Let Me Upload My Program - Arduino Stack Exchange) with an answer, but I tried it and found that the fixes that did not include either buying a new microcontroller or reinstalling the IDE or drivers (which I believe I have already done) or burning the bootloader on the microcontroller did not work. Guidance?

I'm going to ask you to post the full verbose output from an upload attempt.


:exclamation: This procedure is not intended to solve the problem. The purpose is to gather more information.


Please do this:

  1. Select File > Preferences... (or Arduino IDE > Settings... for macOS users) from the Arduino IDE menus.
    The "Preferences" dialog will open.
  2. Uncheck the box next to Show verbose output during: compilation in the "Preferences" dialog.
  3. Check the box next to Show verbose output during: ☐ upload.
  4. Click the "OK" button.
    The "Preferences" dialog will close.
  5. Attempt an upload, as you did before.
  6. Wait for the upload to fail.
  7. You will see a "Upload error: ..." notification at the bottom right corner of the Arduino IDE window. Click the "COPY ERROR MESSAGES" button on that notification.
  8. Open a forum reply here by clicking the "Reply" button.
  9. Click the <CODE/> icon on the post composer toolbar.
    This will add the forum's code block markup (```) to your reply to make sure the error messages are correctly formatted.
    Code block icon on toolbar
  10. Press the Ctrl+V keyboard shortcut (Command+V for macOS users).
    This will paste the error output from the upload into the code block.
  11. Move the cursor outside of the code block markup before you add any additional text to your reply.
  12. Click the "Reply" button to post the output.

That topic is too old to cover all scenarios. It's very common for clone Nanos to use the old bootloader in the 328P.

There are three options under tools / processor. Try the 328P (old bootloader) first, if that fails try the other to options.

Can you provide a link to what you bought or a clear photo that shows the print on the main chip (on the top). I'm asking because there are clones that don't use an Atmel chip but a Logic Green Technologies chip (LGT8F328P).

It says "Amtel" on the chip on the nano, I can't read the rest.

Sketch uses 19170 bytes (62%) of program storage space. Maximum is 30720 bytes.
Global variables use 867 bytes (42%) of dynamic memory, leaving 1181 bytes for local variables. Maximum is 2048 bytes.
"C:\Users\user\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/bin/avrdude" "-CC:\Users\user\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf" -v -V -patmega328p -carduino "-PCOM8" -b115200 -D "-Uflash:w:C:\Users\user\userppData\Local\Temp\arduino\sketches\D3DFA7F668240193D1F7C6E4342FA8D1/graphicstest.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\user\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf"

         Using Port                    : COM8
         Using Programmer              : arduino
         Overriding Baud Rate          : 115200
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x1e
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x1e
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x1e
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x1e
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x1e
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x1e
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x1e
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x1e
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x1e
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x1e

avrdude done.  Thank you.

Failed uploading: uploading error: exit status 1

(I replaced the username with "user" for privacy)

This indicates that you have selected the 328P option under tools/processor. Try the other ones mentioned earlier; if it fails, provide the output that you did in the above post.

That worket me, "Nano"

That worket me, "Nano"

@wonderr

You can not base the "old bootloader" decision on the info on the ICs. All are 328P and it depends on what the clone manufacturer has programmed in them.

The ICs might reveal that it's not a 328P but something else (328PB, 168, LGT8F328P, ...).

But glad that the "old bootloader" worked for you.

I think the problem is with newer IDE platforms, older ones work without problems.

You will have a hard time to get a new official Arduino Nano that you buy today working with those older IDEs :slight_smile:

This is the history. The "first generation" Nanos came programmed with, what is now, the "old bootloader" and the AVR board package that came with the IDE in those days gave the options for 328P and 168. Somewhere along the line (not sure of the exact date) Arduino decided to use a different bootloader for their (let's call it "second generation") Nanos; so an option had to be added in the AVR board package to cater for this different bootloader.

Arduino opted to use name "328P" for the newer bootloader and the existing 328P option was renamed to "328P (old bootloader)".
They also could have chosen to keep the name "328P" for the existing option and use "328P (new)" for the new bootloader.

As a result

  1. Users that bought new official Nanos had to upgrade the AVR board package to be able to use those new official Nanos.
  2. Users that installed a newer version of the IDE that came bundled with an AVR board package that did support both bootloaders had to use the "old bootloader" option for their existing Nanos.