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

Espressif-IDE is not clearing serial port before trying to upload (IEP-1398) #1115

Open
jessecheu opened this issue Jan 12, 2025 · 3 comments
Assignees

Comments

@jessecheu
Copy link

Describe the bug
A clear and concise description of what the bug is.

When trying to upload any program to a ESP32 MCU. I get the error message:

�[0;33m--- esp-idf-monitor 1.5.0 on \\.\COM4 115200�[0m --- Warning: ELF file 'C:/Users/../build/udemy_esp32_iot_app.elf' does not exist --- Quit: Ctrl+] | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H could not open port '\\\\.\\COM4': PermissionError(13, 'Access is denied.', None, 5) --- Connection to \\.\COM4 failed. Available ports: COM4

I tried it on different ESP32 target devices so it seems the problem is with uploading using the espressif-IDE.

To Reproduce
Steps to reproduce the behavior:

  1. Trying to upload code.

Expected behavior
A clear and concise description of what you expected to happen.
Code is able to successfully upload code.

Screenshots
If applicable, add screenshots to help explain your problem.

Espressif-IDE Product Information:
Espressif > Product Information (Copy content from the console and attach as a file)
CDT Build environment variables.txt

Eclipse Error log:
Window > Show View > Other > Search for "Error Log" (Attach as a file)

Please attach the error log as described here !SESSION 2025-01-09 205241.515 ----.txt

I found that the fix is going to task manager and ending all python process related to espressif-ide.
It seems that the file that isn't being closed properly before trying to upload the code to the target is.
"C:\Espressif\python_env\idf5.3_py3.11_env\Scripts" and "C:\Espressif\tools\idf-python\3.11.2"
I believe that pySerial isn't being closed properly.
Another fix was to restart my computer which properly closed the serial port.

@github-actions github-actions bot changed the title Espressif-IDE is not clearing serial port before trying to upload Espressif-IDE is not clearing serial port before trying to upload (IEP-1398) Jan 12, 2025
@DerValdemar
Copy link

DerValdemar commented Jan 21, 2025

I have same problem. Did you found any solutions for this? I also noticed that if I close COM monitor with Ctrl+] next flashing is succesful

@sigmaaa
Copy link
Collaborator

sigmaaa commented Jan 21, 2025

Hi @jessecheu, @DerValdemar

Thank you for reporting this issue!

I’m unable to reproduce it on my end, but it seems the issue might occur because the serial monitor opens automatically after flashing.

When this happens, could you try switching to the terminal tab and disconnecting the terminal connection using this button?
Image

Additionally, if opening the serial monitor after flashing is not essential, you can disable this behavior by editing the configuration and turning off the "Open Serial Monitor After Flashing" option.

Image

However, even without this option, the serial monitor can be launched manually by using this icon:

Image
and then selecting "ESP-IDF Serial Monitor"

@sigmaaa sigmaaa self-assigned this Jan 21, 2025
@PeDaLa42
Copy link

PeDaLa42 commented Feb 11, 2025

Some weeks ago, my Espressif IDE version 3.0.0 installation worked as expected:
Pressing 'Run' button in the IDE closed the COM port in the terminal view (i.e., in ESP-IDF Serial Monitor aka esp-idf-monitor), uploaded the firmware via UART (esptool.py) and re-opend the COM port in the Terminal view.

However, this doesn't work anymore and I have exactly the same issue as described by jessecheu:

  1. The terminal view (esp-idf-monitor) reports "could not open port '\\.\COM5': PermissionError(13, 'Zugriff verweigert', None, 5)" and
  2. esptool.py reports "A fatal error occurred: Could not open COM5, the port is busy or doesn't exist. (could not open port 'COM5': PermissionError(13, 'Zugriff verweigert', None, 5))"

My solution is not restarting the computer.
Logging off and on is enough to completely close the somehow still opened COM port.
After this, i.e., logging off and on, firmware upload with Espressif IDE works again (with NOT opened terminal view)

I investigated the issue further and my findings are:

  1. The same result (non-closed COM port) happens with the following steps:
    a) Start Espressif IDE.
    b) In Espressif IDE: open terminal view.
    c) In the terminal view: Connect with ESP-IDF Serial Monitor to COM5 (this the port where my ESP32S3 is connected to).
    This opens COM5 successful and prints out some lines from my ESP32.
    d) Press 'Disconnect Terminal Connection' button (N-shaped button) to close COM5 in the terminal view.
    With this, '<Closed>' appears in the COM5 window tab.
    e) Open COM5 with another terminal emulation, e.g., Tera Term.
    With this, at least Tera Term reports "Cannot open COM5. Access denied".
    I.e., COM5 is still opened, although ESP-IDF Serial Monitor should have closed it (see step d).
    By logging off and on, the steps a) to e) can be re-done with the same result ;-)

  2. The same result (non-closed COM port) happens with Espressif IDE version 3.1.0.

  3. Modify step e) by NOT opening COM5 in another terminal but re-open COM5 in the terminal view of Espressif IDE (press 'Open a Terminal' button in the terminal view).
    In the terminal view, ESP-IDF Serial Monitor aka esp-idf-monitor reports "could not open port '\\.\COM5': PermissionError(13, 'Zugriff verweigert', None, 5)".

  4. Modify step d) by NOT pressing 'Disconnect Terminal Connection' button but by pressing on the keyboard 'CTRL+T' and 'CTRL+E'.
    This closes the ESP-IDF Serial Monitor. With this, COM5 is completely closed and can be re-opened by any terminal program, e.g., Tera Term or ESP-IDF Serial Monitor aka esp-idf-monitor.

Before updating to Windows 11 version 24H2, my Espressif IDE version 3.0.0 worked as expected (see my first lines above).
So, I believe this could be a version 24H2 issue.
And, it seams that this issue has something to do with controlling esp-idf-monitor in eclipse/Espressif IDE (see my findings 4):

  • GUI button 'Disconnect Terminal Connection' in the terminal view does NOT work (does NOT close COM port).
  • Keyboard buttons 'CTRL+T' and 'CTRL+E' do work (close COM port).

As I believe that controlling esp-idf-monitor in eclipse/Espressif IDE is broken, uploading firmware in combination with a running esp-idf-monitor is also broken (as described by the initial comment).

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

4 participants