A device attached to the system is not functioning

Hi all, please help, I tried to connect nodemcu Lolin, but it show this error when I run it. Already tried to change the cable, the cable works fine with other boards (nodemcu amica), tried to install and uninstall the CH340 driver but still didn't work, also tried to change the board with a new one and still couldn't work. I always hold the flash button too every time I tried to compile the program but it didn't work. Tried to run the arduino ide as administrator still didn't work tho. Any suggestion or solution for this problem?

error message at terminal : Serial port COM3
A fatal esptool.py error occurred: Cannot configure port, something went wrong. Original message: PermissionError(13, 'A device attached to the system is not functioning.', None, 31)

the board I am using : http://www.jogjarobotika.com/wireless-gps-xbee-module/3771-nodemcu-lolin-v3-ch340g-esp8266-esp-12e-development-board.html

Hi @hazzard123. Please perform this experiment to verify that the port you have selected is your Arduino board:

You can positively identify the port using this procedure:

  1. Disconnect the USB cable of the Arduino board from your computer.
  2. Select Tools > Port from the Arduino IDE menus.
  3. Take note of the ports, if any, listed in the menu.
  4. Close the Tools menu.
    :exclamation: The ports list is only updated when the Tools menu is re-opened, so this step is essential.
  5. Connect the Arduino board to your computer with a USB cable.
  6. Select Tools > Port from the Arduino IDE menus. - If a new port is listed in the menu, that is the port of your Arduino board.

Select that port from the menu and try uploading again.

If the upload still fails, or if no new port appeared after you plugged the Arduino board into your computer, add a reply here to let us know and we'll investigate the problem further.

I tried the step 3 and there isn't any port detected after I unplug the cable. Also no new port appeared its only COM 3. My laptop has 2 ports for usb so i tried to change the port too but still failed to upload the code. Please help me I'm so frustrated.

I'm not sure I understood correctly what you mean by this. Please provide a more detailed description to help me to understand it.

These two statements seem contradictory to me:

Do you mean that the Tools > Port menu is empty/disabled after you unplug the cable?

Did COM3 disappear from the Tools > Port menu after you unplugged the USB cable from your computer, and then reappear after you plugged the USB cable back in to the computer?

Did COM3 disappear from the Tools > Port menu after you unplugged the USB cable from your computer, and then reappear after you plugged the USB cable back in to the computer?

yes it is. The board and the cable works fine at other laptop. Is there any way that I could do to make it work on my own laptop?

Recently we have seen many reports of a driver problem causing unexpected upload errors occurring specifically when uploading to the boards that use the WCH CH340 USB chip (and apparently only specific batches of those chips).

When uploading to a board with an AVR microcontroller using the AVRDUDE uploader tool, we see the distinctive "can't set com-state for ..." error message. I haven't determined what error message might be produced by the equivalent problem occurring while uploading using a different upload tool such as the esptool tool used to upload to your ESP8266 board. So I'm not 100% certain that your "the port doesn't exist" error has the same cause. The fact that you are able to upload on one computer but not another does indicate that the error is caused by a problem in the environment of the computer itself rather than in the board, which does fit with my hypothesis reasonably well.

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:

  1. Open this tutorial from SparkFun in your browser:
    https://learn.sparkfun.com/tutorials/how-to-install-ch340-drivers/all#drivers-if-you-need-them
    We are using this tutorial as a source for an older version of the CH340 drivers. Generally I recommend only obtaining drivers from the manufacturer of the device, but WCH does not provide older versions of their drivers and SparkFun is trustworthy.
  2. Click the "Windows (EXE)" link you see in red under the "Drivers (If You Need Them)" section of the tutorial.
  3. Wait for the download to finish.
  4. Run the downloaded CH341SER.EXE file.
  5. 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.
  6. A "DriverSetup(X64)" dialog will appear. Click the "INSTALL" button in the dialog.
  7. Wait for the driver installation to finish, as indicated by the appearance of a "Driver install success!" dialog.
  8. Click the "OK" button in the "Driver install success!" dialog.
  9. Click the X icon at the top right of the "DriverSetup(X64)" dialog to close it.
  10. Close Arduino IDE if it is running.
  11. Connect the Arduino board to your computer with a USB cable.
  12. Open the Windows Device Manager.
  13. Select View > Devices by type from the Device Manager menus.
  14. Open the "View" menu.
  15. If there is a to the left of the "Show hidden devices" menu item, click on "Show hidden devices" to disable it.
  16. Open the "Ports (COM & LPT)" section of the Device Manager tree.
  17. You should see a port identified as "USB-SERIAL CH340 (COM_n_)" under the "Ports (COM & LPT)" section (where "COM_n_" is some serial port e.g., COM4). Right click on that item.
    A context menu will open.
  18. Select the "Drivers" tab of the "USB-SERIAL CH340 (COM_n_) Properties" dialog.
  19. You will see a "Roll Back Driver" button in the dialog. If it is not clickable, perform the following instructions:
    1. Select "Update driver" from the context menu.
      An "Update Drivers Device - USB-SERIAL CH340 (COM_n_)" dialog will open.
    2. Click on "Search automatically for drivers" in the "Update Drivers Device - USB-SERIAL CH340 (COM_n_)" 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 (COM_n_)" dialog.
  20. Click the "Roll Back Driver" button in the "USB-SERIAL CH340 (COM_n_) Properties" dialog.
    The "Driver Package rollback" dialog will open.
  21. Click the radio button next to "My apps don't work with this driver" in the "Driver Package rollback" dialog .
  22. Click the "Yes" button.
  23. Click the "Close" button in the "USB-SERIAL CH340 (COM_n_) 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 "the port doesn't exist" error during the sketch upload.

2 Likes

I got this message.

I had the same issue on Windows 11 x64 and can confirm that removing drivers and installing them manually from the zip archive from the link below solved it for me:

1 Like

I decided to explain how I did it. Hopefully, this may help someone.

Here's how to change the driver back and how to stop Windows 11 updating driver silently:

  1. Insert your CH340 device and make sure the COM port is not working.
  2. Open Device Manager, open Properties dialog for this device and make sure that driver's version is 3.8.2023.2 (if not, this solutions probably won't work).
  3. Download ZIP packed drivers from https://learn.sparkfun.com/tutorials/how-to-install-ch340-drivers/all#drivers-if-you-need-them and unpack to a folder.
  4. Right-Click the device in Device Manager, click Uninstall Device, in the pop-up tick checkbox "Attempt to remove the driver for this device", then click "Uninstall" button.
    (Do not reconnect the device physically!)
  5. In Device Manager go to the menu: Action -> Add drivers, choose a location where you unpacked the drivers from step 3, click Next and install them.
  6. After installation, click Action -> Scan for hardware changes. You device should be re-discovered by Windows now.
  7. Right-click your CH340 device, go to Properties and check driver's version, it should be 3.4.2014.8.

Your device is working now, congrats!

If you'd like to prevent Windows from silently updating the driver back to 3.8.2023.2, do the following:


EDIT: After a few days I have to add that the following procedure seems to has no effect and in my case Windows keeps reverting the driver back to non-functioning version 3.8.2023.2 during the next night and without asking. I'm still trying to solve it... Nevertheless, the procedure above works well for me as a temporary workaround.


  1. Go to Settings -> System -> About, then under the “Device specifications” section, click the “Advanced system settings” option, click the Hardware tab, then click the “Device Installation Settings” button.
  2. Select the “No (your device might not work as expected)” option.
  3. Click "Save Changes".

Enjoy!

And, just for the record, here's the Microsoft update that caused all the trouble:
https://www.catalog.update.microsoft.com/ScopedViewInline.aspx?updateid=6faa33ef-5b78-469c-abac-10f990667c5f

wch.cn - Ports - 3.8.2023.2
Last Modified: 2/11/2023
Size: 199 KB
UpdateID: 6faa33ef-5b78-469c-abac-10f990667c5f

Thanks for sharing your solution @amnn314!

Did you experience such an update after performing the "roll-back" procedure I described in the post you quoted above? I ask because I haven't seen reports of such an update from any of the many users who used that procedure to fix the problem with their CH340 boards. From this, I got the impression that Windows is smart enough to understand that if a user does a "roll-back", they don't want it to be later reverted back to the problematic version they had before the roll-back.

I don't own one of the sketchy CH340 boards that is affected by this problem so I don't have direct experience. I performed the "roll-back" procedure several times while developing those instructions, but I always updated the driver again after because I don't have any need to use the old version. So I don't have direct experience either way. I just did another roll-back and will leave the old driver in place to see what happens.

Thanks for asking, ptillisch. Unfortunately, I cannot use the procedure you described, because the "Roll Back Driver" button is not clickable and when I do i. 19.1-19.3 I get "The best drivers are already installed", because, I guess, Windows thinks that "the best" driver is that awful 3.8.2023.2.

Hi @amnn314.

By "best", Windows actually means "newest". So this result is expected when "3.8.2023.2" is in use. What is not expected is that Windows doesn't recognize that it is possible to roll back to "3.4.2014.8", even though you installed it via the installer at step (6) of my "roll-back" instructions.

Unfortunately I have not been able to determine the conditions that cause this behavior.

In some cases where the user reports encountering the "The best drivers are already installed it turns out that the driver version in use is "3.4.2014.8" and for some reason Windows doesn't want to update back to "3.8.2023.2". In that case it seems the intended result has already been achieved somehow and probably no further action is needed.

I did experience this problem where the "Roll Back Driver" button to be disabled when the installed version is "3.8.2023.2" a couple of times, but I haven't been able to reproduce it consistently and I found that the behavior seems to be somewhat random while I am performing the procedures to get Windows into the state where I can do the "roll-back". So I'm not as clear about the procedure as I would like to be.

This is the procedure that worked for me when I experienced that problem:

  1. Connect the Arduino board to your computer with a USB cable.
  2. Open the Windows Device Manager.
  3. Select View > Devices by type from the Device Manager menus.
  4. Open the "View" menu.
  5. If there is a to the left of the "Show hidden devices" menu item, click on "Show hidden devices" to disable it.
  6. Open the "Ports (COM & LPT)" section of the Device Manager tree.
  7. You should see a device identified as "USB-SERIAL CH340 (COMn)" under the "Ports (COM & LPT)" section (where "COMn" is some serial port e.g., COM4). Right click on that item.
    A context menu will open.
  8. Select "Uninstall device" from the menu.
    The "Uninstall Device" dialog will open.
  9. Check the box next to "☐ Attempt to remove the driver for this device" in the "Uninstall Device" dialog.
  10. Click the "Uninstall" button.
    The driver will be uninstalled, the "Uninstall Device" dialog will close, and the "USB-SERIAL CH340 (COMn)" device will disappear from the Windows Device Manager tree.
  11. Unplug the USB cable of the Arduino board from your computer.
  12. Connect the Arduino board to your computer with a USB cable.
  13. If a port identified as "USB-SERIAL CH340 (COMn)" appears under the "Ports (COM & LPT)" section, repeat steps 7-12 above again until the device appears as "USB2.0-Serial" under the "Other devices" section at step 12.
  14. Open this tutorial from SparkFun in your browser:
    https://learn.sparkfun.com/tutorials/how-to-install-ch340-drivers/all#drivers-if-you-need-them
    We are using this tutorial as a source for an older version of the CH340 drivers. Generally I recommend only obtaining drivers from the manufacturer of the device, but WCH does not provide older versions of their drivers and SparkFun is trustworthy.
  15. Click the "Windows (EXE)" link you see in red under the "Drivers (If You Need Them)" section of the tutorial.
  16. Wait for the download to finish.
  17. Run the downloaded CH341SER.EXE file.
  18. 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.
  19. A "DriverSetup(X64)" dialog will appear. Click the "INSTALL" button in the dialog.
  20. Wait for the driver installation to finish, as indicated by the appearance of a "Driver install success!" dialog.
  21. Click the "OK" button in the "Driver install success!" dialog.
  22. Click the X icon at the top right of the "DriverSetup(X64)" dialog to close it.
  23. Open the Windows Device Manager.
  24. Open the "Ports (COM & LPT)" section of the Device Manager tree.
  25. You should see a device identified as "USB-SERIAL CH340 (COMn)" 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.
    The version shown in the "Driver Version" field of the dialog is expected to be "3.4.2014.8".
  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.
    The version shown in the "Driver Version" field of the "USB-SERIAL CH340 (COMn) Properties" dialog is now expected to be "3.8.2023.2" and the "Roll Back Driver" button is expected to be enabled.
  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.
    The version shown in the "Driver Version" field of the "USB-SERIAL CH340 (COMn) Properties" dialog is now expected to be "3.4.2014.8".
  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.

Please let me know whether this procedure works for you, and if so whether you find that it results in a persistent activation of the "3.4.2014.8" driver.

An update on this: after six days the "3.4.2014.8" version of the driver installed via the "roll-back" procedure I described above is still installed. A significant Windows update occurred during the course of the six days, and I have plugged and unplugged a CH340-based board quite a few times over those days. Perhaps six days isn't long enough to be conclusive, but this does indicate to me that the "roll-back" is persistent and that we should not expect that Windows will automatically update the driver back to the problematic new version after we perform a "roll-back".

Hey @amnn314 , created this account specifically to thank you for the detailed instructions. I was banging my head with this problem but all is well now after following what you outlined. Many thanks again!

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.