Skip to content

"Access is denied" error when uploading to board w/ FT232 USB chip with Serial Monitor/Plotter open #1783

Open
@maciejmiklas

Description

@maciejmiklas

Describe the problem

In order to upload to an Arduino board via a serial port, the upload tool (e.g., AVRDUDE) must be able to open the port. This is not possible if another process already has control of the port.

Arduino IDE's "Serial Monitor" and and "Serial Plotter" components also use the serial port of the board. Arduino IDE handles this potential conflict of port usage automagically by closing the port in Serial Monitor/Plotter when an upload process is triggered, then opening it again after the upload is finished. This means no special action is needed from the user to upload while Serial Monitor/Plotter is open.

🐛 The upload fails with an "Access is denied" error under the following conditions:

  • The board uses an FTDI FT232R USB chip
  • Arduino IDE is running on a Windows machine
  • Serial Monitor or Serial Plotter is open

I've been using Arduino IDE 2.0.3 with Nano without issues when uploading on Ubuntu. Now I've tried it on Windows 11, and most of the time, it gives me this error:

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\macie\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf"

         Using Port                    : COM5
         Using Programmer              : arduino
         Overriding Baud Rate          : 115200
avrdude: ser_open(): can't open device "\\.\COM5": Access is denied.

But I can see logs from the serial monitor in Arduino IDE -> serial monitor.

To reproduce

Equipment

A board or other device that has an FTDI FT232R USB chip

The classic Arduino Nano is a common board that uses this chip.

FT232R modules (example) or cables (example) are also often used to upload to boards such as the Arduino Pro Mini that don't have an integrated USB chip.

The fault can be reproduced even if the FT232R-based device is not an Arduino board. In this case, the upload is expected to fail, but it would fail with a "not in sync" error instead of "Access is denied".

Steps

  1. Select File > New Sketch from the Arduino IDE menus.
  2. Connect the Arduino board to your computer.
  3. Select the board and port from the Arduino IDE menus.
  4. If the Serial Monitor view is not already open, select Tools > Serial Monitor from the Arduino IDE menus to open it.
  5. Select Sketch > Upload from the Arduino IDE menus.
  6. Wait for the upload process to finish.
    🐛 The upload fails:
    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\macie\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf"
    
             Using Port                    : COM5
             Using Programmer              : arduino
             Overriding Baud Rate          : 115200
    avrdude: ser_open(): can't open device "\\.\COM5": Access is denied.
    
  7. Click the X icon on the "Serial Monitor" view tab in the bottom panel.
  8. Select Sketch > Upload from the Arduino IDE menus.
  9. Wait for the upload process to finish.
    🙂 The upload is successful.
  10. Select Tools > Serial Plotter from the Arduino IDE menus.
  11. Select Sketch > Upload from the Arduino IDE menus.
  12. Wait for the upload process to finish.
    🐛 The upload fails:
    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\macie\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf"
    
             Using Port                    : COM5
             Using Programmer              : arduino
             Overriding Baud Rate          : 115200
    avrdude: ser_open(): can't open device "\\.\COM5": Access is denied.
    
  13. Close the "Serial Plotter" window.
  14. Select Sketch > Upload from the Arduino IDE menus.
  15. Wait for the upload process to finish.
    🐛 The upload fails:
    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\macie\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf"
    
             Using Port                    : COM5
             Using Programmer              : arduino
             Overriding Baud Rate          : 115200
    avrdude: ser_open(): can't open device "\\.\COM5": Access is denied.
    
    This unexpected result is caused by a separate bug: Port left open after closing Serial Plotter #1423

Expected behavior

Serial Monitor and Serial Plotter do not interfere with upload process.

Arduino IDE version

Original report

2.0.3

Last verified with

2.3.3

Operating system

Windows

Operating system version

Edition Windows 11 Pro
Version 22H2
Installed on 07/11/2022
OS build 22621.963
Experience Windows Feature Experience Pack 1000.22638.1000.0

Additional context

I bisected the introduction of the fault to df8658e


Logs generated from an upload that fails with this fault using the build for 053574b with the arduino.cli.daemon.debug advanced setting set to true:

2023-08-16_log.log


I have no problems uploading sketches on Arduino IDE 1.8.19 from Microsoft Store on the same system. I can quit 2.0.3, start 1.8.19, and it's working immediately.


I cannot reproduce the fault on Linux (Ubuntu 22.04) or macOS (Ventura).


I cannot reproduce the fault when using native USB boards (e.g., Leonardo, MKR) or boards that use other models of dedicated USB chip (e.g., ATmega16U2 on Uno and Mega, WCH CH340 on derivative boards).

Workaround

Serial Monitor
  1. Click the X icon on the "Serial Monitor" tab in the bottom panel of the Arduino IDE window to close the tab:
    image
  2. Upload the sketch.
  3. Open Serial Monitor again if needed (by clicking the icon on the IDE toolbar or the Tools > Serial Monitor menu item) after the upload is finished.

Serial Plotter
  1. Close the "Serial Plotter" window.
  2. If the "Serial Monitor" view is not already open, select Tools > Serial Monitor from the Arduino IDE menus to open it.
    We must do an open/close cycle on Serial Monitor as a workaround for a bug in Serial Plotter
  3. Click the X icon on the "Serial Monitor" tab in the bottom panel of the Arduino IDE window to close the tab:
    image
  4. Upload the sketch.
  5. Open Serial Monitor and/or Serial Plotter again if needed after the upload is finished.

Additional reports

Related

Issue checklist

  • I searched for previous reports in the issue tracker
  • I verified the problem still occurs when using the latest nightly build
  • My report contains all necessary details

Metadata

Metadata

Labels

topic: codeRelated to content of the project itselftype: imperfectionPerceived defect in any part of project

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions