A fatal esptool.py error occurred: Cannot configure port, something went wrong

Hey there,i currently doing a project using nodemcu esp8266, when i upload the code, it shows this output telling some fatal error. Anyone know what is this error and how to fix it? This project is important to me as it is my fyp. Thanks yall

. Variables and constants in RAM (global, static), used 40368 / 80192 bytes (50%)
║   SEGMENT  BYTES    DESCRIPTION
╠══ DATA     1684     initialized variables
╠══ RODATA   8324     constants       
╚══ BSS      30360    zeroed variables
. Instruction RAM (IRAM_ATTR, ICACHE_RAM_ATTR), used 62811 / 65536 bytes (95%)
║   SEGMENT  BYTES    DESCRIPTION
╠══ ICACHE   32768    reserved space for flash instruction cache
╚══ IRAM     30043    code in IRAM    
. Code in flash (default, ICACHE_FLASH_ATTR), used 452128 / 1048576 bytes (43%)
║   SEGMENT  BYTES    DESCRIPTION
╚══ IROM     452128   code in flash   
esptool.py v3.0

Serial port COM5
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)

Hi @johnweak1998. Please tell us which USB to serial bridge chip your Arduino board has. This is a black chip near the USB socket.

The chip will usually be identified by writing on the top. This might say something like "WCH CH340G" or "SILABS CP2102".

Examples:

WCH CH340

CH340

📷

SparkFun - CC BY-SA 4.0 (cropped)

Silicon Labs CP2102

CP2102

📷

SparkFun - CC BY-SA 4.0 (cropped)


If it isn't clear, alternatively you can provide the link to where you bought the board from and we'll see if we can determine the chip from the product listing.

Hi there, this is the image of my nodemcu, its ch340g if not mistaken.


OK, great. This "PermissionError(13, 'A device attached to the system is not functioning.', None, 31)" error can occur when uploading to the boards that use specific batches of the WCH CH340 USB chip. We have noticed a characteristic of those sketchy CH340 chips is the lack of labeling (normally "WCH CH340G" is written on them), as is the case with your 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:

  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 appear. 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.
  8. Click the X icon at the top right of the "DriverSetup(X64)" dialog to close it.
  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 error during the sketch upload.

16 Likes

I moved your topic to an appropriate forum category @johnweak1998.

In the future, please take some time to pick the forum category that best suits the subject of your topic. There is an "About the _____ category" topic at the top of each category that explains its purpose.

This is an important part of responsible forum usage, as explained in the "How to get the best out of this forum" guide. The guide contains a lot of other useful information. Please read it.

Thanks in advance for your cooperation.

Hey @ptillisch, in the step 18.3, it shows 'the best drivers are already installed'. I had stopped here for further instructions. Thanks

Best
John

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:

  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 appear. 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.
  23. Click the X icon at the top right of the "DriverSetup(X64)" dialog to close it.
  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 error during the sketch upload.

3 Likes

Thx my master :pray:

Hello,
I followed all the steps you mentioned, and initially, everything worked fine. However, after some time, I encountered the same issue again. To troubleshoot, I repeated the steps, and surprisingly, it started working again. This happened yesterday, and today, it worked consistently for about 5-6 times. However, on the 7th attempt, I encountered the same error once more.
I'm not sure why this inconsistency is happening. Could you please provide guidance on what I should do next to address this issue?
Thank you.

Hi @prakruti_b. I'm going to ask you to post the full verbose output from an upload attempt when the failure occurs.


: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. If the upload is successful, continue uploading until a failure occurs.
  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.
"C:\Users\hbhav\AppData\Local\Arduino15\packages\esp8266\tools\python3\3.7.2-post1/python3" -I "C:\Users\hbhav\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2/tools/upload.py" --chip esp8266 --port "COM3" --baud "115200" ""  --before default_reset --after hard_reset write_flash 0x0 "C:\Users\hbhav\AppData\Local\Temp\arduino\sketches\0C9043DF09502880EA2A8A78785DD822/ir.ino.bin"
esptool.py v3.0
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)

I've included the detailed output as you requested. Is this the information you were looking for?

I'm going to ask you to provide some additional information that might help us to understand how to proceed.

Please do this:

  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 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.
  8. Select the "Drivers" tab of the "USB-SERIAL CH340 (COMn) Properties" dialog.

Now please reply here on the forum thread to tell us the version number you saw after "Driver Version" field in that "USB-SERIAL CH340 (COMn) Properties" dialog.

2 Likes

I also have problems with my esp8266 boards on my windows 11 stationary PC. Sometimes the upload stops after 16% sometimes it stops immediatedly (during connect).
My CH340 driver is version 3.7.2022.1 (i downgraded)
On my windows 10 laptop i have no problems...
Hope this can help :slight_smile:

This works like a charm

1 Like

thanks a lot. that solved my problem!

Realizei a desinstalação e instalei novamente o mesmo arquivo baixado e resolveu meu problema, obrigado!!!!

1 Like

Este procedimiento funciono para mi ESP8266(12E-Module) en Arduino 2.3.2 en Windows 11.
Muchas gracias

1 Like

I tried to roll back the driver but that option doesn't appear for me even after folling your steps. Do you know what could be wrong and how to fix this?

Hi @gred317. Please try following the additional instructions I provided in post #7:

https://forum.arduino.cc/t/a-fatal-esptool-py-error-occurred-cannot-configure-port-something-went-wrong/1225308/7

6 posts were split to a new topic: Upload to ESP8266 fails: "PermissionError(13, 'A device attached to the system is not functioning.'"