Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PermissionError(13, 'Access is denied.', None, 5) (ESPTOOL-334) #682

Closed
a4004 opened this issue Oct 22, 2021 · 10 comments
Closed

PermissionError(13, 'Access is denied.', None, 5) (ESPTOOL-334) #682

a4004 opened this issue Oct 22, 2021 · 10 comments

Comments

@a4004
Copy link

a4004 commented Oct 22, 2021

Operating system

Microsoft Windows® 10 Version 21H1 Build 19043.1288

Python version

Python 3.9.7

What Chip

ESP8266

What development board or other hardware is the chip attached to

NodeMCU 1.0 ESP-12E

Is anything else attached to the development board, except for the serial flasher connections?

No

Are you running esptool.py from an IDE such as Arduino or Eclipse?

No IDE, Windows command prompt

Full esptool.py command line that was run:

py -m esptool --port COM5 read_mac

Full output from esptool.py

esptool.py v3.1
Serial port COM5
Traceback (most recent call last):
  File "C:\Program Files\Python39\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Program Files\Python39\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Program Files\Python39\lib\site-packages\esptool.py", line 4582, in <module>
    _main()
  File "C:\Program Files\Python39\lib\site-packages\esptool.py", line 4575, in _main
    main()
  File "C:\Program Files\Python39\lib\site-packages\esptool.py", line 4074, in main
    esp = esp or get_default_connected_device(ser_list, port=args.port, connect_attempts=args.connect_attempts,
  File "C:\Program Files\Python39\lib\site-packages\esptool.py", line 116, in get_default_connected_device
    _esp = ESPLoader.detect_chip(each_port, initial_baud, before, trace,
  File "C:\Program Files\Python39\lib\site-packages\esptool.py", line 354, in detect_chip
    detect_port = ESPLoader(port, baud, trace_enabled=trace_enabled)
  File "C:\Program Files\Python39\lib\site-packages\esptool.py", line 313, in __init__
    self._port = serial.serial_for_url(port)
  File "C:\Users\Alex\AppData\Roaming\Python\Python39\site-packages\serial\__init__.py", line 90, in serial_for_url
    instance.open()
  File "C:\Users\Alex\AppData\Roaming\Python\Python39\site-packages\serial\serialwin32.py", line 64, in open
    raise SerialException("could not open port {!r}: {!r}".format(self.portstr, ctypes.WinError()))
serial.serialutil.SerialException: could not open port 'COM5': PermissionError(13, 'Access is denied.', None, 5)

Do you have any other information from investigating this?

This problem is not present in esptool.py v3.0 (a compiled binary was used)
The problem is not present when not specifying the COM port i.e. py -m esptool read_mac. esptool.py successfully identifies the NodeMCU on COM5 and reads the MAC address successfully.

@github-actions github-actions bot changed the title PermissionError(13, 'Access is denied.', None, 5) PermissionError(13, 'Access is denied.', None, 5) (ESPTOOL-334) Oct 22, 2021
@radimkarnis
Copy link
Collaborator

Hi @a4004,
This error usually means that the serial port is being used by another program (like a serial terminal or in the Arduino IDE). Double-check that you’ve closed all the programs that might be establishing a serial communication with your ESP board. Then, unplug and plug back your ESP board and try again.

@a4004
Copy link
Author

a4004 commented Oct 22, 2021

Hi @a4004, This error usually means that the serial port is being used by another program (like a serial terminal or in the Arduino IDE). Double-check that you’ve closed all the programs that might be establishing a serial communication with your ESP board. Then, unplug and plug back your ESP board and try again.

Hello @radimkarnis
I have made sure any conflicting applications that I'm aware of are closed and have tried it again. Still not working under version 3.1. I can run version 3.0 multiple times edit: (using a compiled binary) with no problems but version 3.1 will not work unless --port COM5 is omitted from the command.

@a4004
Copy link
Author

a4004 commented Oct 22, 2021

I have just downgraded the version to 3.0 through pip and it seems the problem is persistent in Python while not affecting the compiled version.

@a4004
Copy link
Author

a4004 commented Oct 22, 2021

It appears I might've resolved this issue now. It turns out Malwarebytes might have been interfering with the program 😂

@a4004 a4004 closed this as completed Oct 22, 2021
@ErikRust
Copy link

In my case I reinstalled drivers from https://sparks.gogo.co.nz/assets/_site_/downloads/CH34x_Install_Windows_v3_4.zip with Admin Rights, seeing as permission access is in question. This is on a windows system, so right click run as admin seem to have solved issue.

@Sawadee2u
Copy link

This worked for me (ErikRust) updated CH34x driver.
USB-Serial CH340 Version 3.4.2014.8 (8/8/2014) Did not work and caused this error.
USB-Serial CH340 Version 3.5.2019.1 (1/30/2019) Worked with no errors.
Device used : n/dchart's USB-C to UPDI Key with CH340N chip 3 pogo pin flashlight programmer

@eagl1
Copy link

eagl1 commented Jun 8, 2024

ErikRust, thank you so much my ESP32-8048S043C was struggling to connect to the serial port. Following your solution solved the problem.

@alain110
Copy link

Thank you very much, it works well now for me too.

@t0mkee
Copy link

t0mkee commented Sep 4, 2024

In my case I reinstalled drivers from https://sparks.gogo.co.nz/assets/_site_/downloads/CH34x_Install_Windows_v3_4.zip with Admin Rights, seeing as permission access is in question. This is on a windows system, so right click run as admin seem to have solved issue.

i have been trying for 4 hours trying to get my chip to work, THANK YOU

@eagl1
Copy link

eagl1 commented Sep 14, 2024

Other settings I recommend:

  1. Try installing newer or older CH340 drivers.
  2. Enable --> Erase all flash before sketch upload.
  3. Press the boot button before plugging in the board or with pressing the rst button.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants