Elusive -- Uno - upload error: Access is Denied

Need help please -> Out of things to check
I've read through the arduino forums and found similar questions asked. I followed their recommendations but the issue did not resolve.

Error:

avrdude: ser_open(): can't open device "\\.\COM3": Access is denied.

The script has only uploaded two times. It has failed on every upload attempt after that.
It fails with error "access denied error".

It seems odd that even after the error occurs the Serial Monitor is still showing data constantly updating on the screen.

Outstanding questions:

  • Is there a better way to find what ports are currently in use (I'm using Process Explorer; see below).
  • don't know how to tell a 3rd party software package or a device to disconnect from a COM port (I don't think another process is using the COM port; see below)
  • Do not understand if downloading FTDI Virtual COM Port Driver is required.
  • I didn't understand what a post meant by reinstalling the avrdude and avr-gcc compiler processes so I uninstalled everything and reinstalled.

Things I've checked and tried:

  • Only other things connected to PC over USB are the keyboard and mouse. These use different connector slots.
    link: arduino uno - Access denied when Uploading - Arduino Stack Exchange

  • checked cable connections and condition

  • visually double checked the Arduino IDE Board and COM port used and then confirmed it with the device manager Port (COM&LPT) setting

  • Pressed the Arduino Reset button:

    • Once
    • Twice
  • Changed the baud rate from 9600 to 115200
    When it did initially upload the baud rate was at 9600. After the error I changed it to 115200. It made no difference so I put it back to 9600

  • Downloaded "Process Explorer" to see if anything else is using the port. Went through the recommended instruction steps (link below). The Find -> Find Handle or DLL search on FTSER2K returned nothing.
    I assume nothing found means no other process is using the same COM port.

    DevMgr Port:
    USB Serial Port (COM3)
    Service: FTSER2K

  • Changing COM ports

    • Tried about 20 different COMs randomly from 3 to 255.
      using device mgr and then verifying the match in Arduino IDE tools->ports
      ..Tried both unplugging Arduino USB to computer and leaving it connected.
      ..Tried restarting and not restarting the Arduino IDE
      ..Tried both rebooting and not rebooting computer
      In all cases the Sketch failed to upload after every change
    • Reference: https://youtube.com/watch?v=MkPJD_6PjDc
  • manually updated drivers on DevMgr Ports -> USB Serial Port (COM3)
    Windows said they were up to date
    Sketch still would not upload

  • Uninstalled Arduino software and reinstalled software
    Sketch failed on upload

  • Rebooted machine; after the restart let it sit for about 15 minutes before launching Arduino
    Failed on upload

  • Rebooted machine; immediately started Arduino
    Failed on upload

  • FTDI Virtual COM Port Driver
    Do not understand if downloading FTDI Virtual COM Port Driver is required.
    The sketch did upload one time before beginning to fail upload so it must have a compatible driver
    Reference: VCP Drivers - FTDI

  • Windows Task Manager shows Multiple Arduino Processes
    11 arduino processes running:

    • arduino-cli.exe
    • arduino-language-server.exe
    • Arduino IDE.exe
    • Arduino IDE.exe
    • Arduino IDE.exe
    • Arduino IDE.exe
    • Arduino IDE.exe
    • Arduino IDE.exe
    • Arduino IDE.exe
    • Arduino IDE.exe
    • Arduino IDE.exe
  • Only have Windows Defender installed and running.
    Article says to turn off 3rd party anti-virus.
    Reference: Seeing the Arduino upload error? Fix it easily in 8 steps

  • On Device Manger top level shows 3 COM ports listed
    DevMgr Ports (COM&LPT)

    • communications Port (COM1)
    • Printer Port (LPT1)
    • USB Serial Port (COM3)

    digging down through COM3 port Settings > Advanced, COM Port Number lists 256 COM ports only COM1 says is "(in use)"
    Reference: Access Denied - #4 by DrAzzy

I don't see any other recommendations on the web or arduino forum and don't know what else to check. I must be missing something.

Please help.


Other Details

Upload Error:

Sketch uses 3410 bytes (10%) of program storage space. Maximum is 32256 bytes.
Global variables use 210 bytes (10%) of dynamic memory, leaving 1838 bytes for local variables. Maximum is 2048 bytes.
"C:\Users\alvin\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/bin/avrdude" "-CC:\Users\alvin\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf" -v  -patmega328p -carduino "-PCOM3" -b115200 -D "-Uflash:w:C:\Users\alvin\AppData\Local\Temp\arduino-sketch-7220689F9C89389A1651842C05EF6474/BasicTemperature.ino.hex:i"
avrdude: Version 6.3-20190619
         Copyright (c) 2000-2005 Brian Dean
         Copyright (c) 2007-2014 Joerg Wunsch
         System wide configuration file is "C:\Users\alvin\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf"
         Using Port                    : COM3
         Using Programmer              : arduino
         Overriding Baud Rate          : 115200
avrdude: ser_open(): can't open device "\\.\COM3": Access is denied.
avrdude done.  Thank you.
Failed uploading: uploading error: exit status 1

Script (basic temperature)

int lm35Pin = A0;
void setup() {
  Serial.begin(115200);
}
void loop() {
  int analogValue;
  float temperature;
  analogValue = analogRead(lm35Pin);
  temperature = float(analogValue) / 1023;
  temperature = temperature * 500;
  Serial.print("Temp: ");
  Serial.print(temperature);
  Serial.println(" C");
  delay(1000);
}

Arduino IDE
Version: 2.0.3
Date: 2022-12-05T09:30:25.331Z
CLI Version: 0.29.0 [76251df9]
Copyright © 2022 Arduino SA

Arduino Uno Board Info
From Arduino IDE:
BN: Arduino Uno
VID: 0x2341
PID: 0x0043

From Board:
OSEPP Uno R3 Plus
Rev 3.8

PC
Processor Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz 3.70 GHz
Installed RAM 16.0 GB
System type 64-bit operating system, x64-based processor

OS (current: no updates pending)
Edition Windows 11 Pro
Version 22H2
Installed on ‎10/‎5/‎2022
OS build 22621.963
Experience Windows Feature Experience Pack 1000.22638.1000.0

Arduino Port Used
-- COM3
Device Mgr Ports (COM &LPT)
-- USB Serial Port (COM3)

Only if your board uses a FTDI TTL-to-USB chip; that is the chip closest to USB connector. You can find the VID and PID of the TTL-to-USB chip in Windows device manager. In Win10 it is in the details tab, Hardware IDs; I'm not familiar with Win11. You can look those numbers up on the web; e.g. All USB Vendors | Device Hunt

Does COM3 disappear from Windows device manager when you disconnect the board? If yes, the correct driver is installed (if there are no yellow exclamation marks).

From memory, there might be a conflict with bluetooth. If you PC has bleutooth, see if disabling it solves the problem. I might be mistaken but it's worth a try.

sterretje,
)) Yes; the board does have an FTDI chip.

2 quick follow-up questions


Question 1
It sounds like if I just get a different Arduino board then the FTDI driver issue is avoided.

Q1) Is the FTDI chip older technology that is going away or is it the new incoming technology?


Question 2
I don't think I see an FTDI chip on the following two boards in the Arduino store.

Q2) Would you look at them and confirm they don't have an FDTI chip?

Arduino Uno Rev3

Arduino Mega 2560 Rev3


@sterretje
Thank you for responding. The information you've provided is very helpful.

You asdume it's a driver issue. I have a SparkFun RedBoard with FTDI and don't have problems in Win10. I lostvthe port once which wad fixed by installing the latest driver.

No, the FTDI is not older technology. However, there were counterfeit FTDI chips a couple of yours ago.

Both boards are official Arduinos with 16U2 so no FTDI driver needed. To my knowledge, there is only one official Arduino with FTDI chip and that is the Nano.

I will take a SWAG say you may have a serial flood. Try this:

  1. Power off the board completely
  2. Remove the USB cable
  3. Hold down the Reset button
  4. keep it held down (or, run a jumper wire from the RESET pin to the GND pin).
  5. Still holding down Reset reconnect the USB cable.
  6. Start uploading a sketch that does not have this problem (I use the Blink sketch).
  7. When you see the Receive light blink, release the Reset button
    Note: I have seen this happen several times when I flood the serial output. An indication is the tx light is stuck on.

If this does not work you may have to program the boot loader.

I always put a delay(5000); or thereabouts at the beginning of my Setup function, this allows the system to gain control even if the serial output is flooded. It has saved me many times when I print debug messages.

Not sure if this is going to help, but I ran into several 'access is denied' occasions both with IED v1.8 and 2.03, and I eventually found the source of the problem and resolved it (peacefully).

The error message happened, in my case, during compilation only, not uploading. If you are not sure about it, please try compiling your code, and see if this is the case in your hand.

If this is the case for you, then the question is 'who is denying the file access during compilation"? In my case, it is Microsoft Windows (forget to mention that I am running Windows 11). To simplify and replicate the problem, just open a blank sketch and compile it, with whatever board/port you have chosen (it actually does not matter as it is not uploading). The IDE will try to create and compile the almost empty code to its default location which it may have full access to.

If this is successful, try to save the save sketch into your 'usual' location and compile it again. And if it is 'denied' this time, it simply means that your IDE was denied access to that particular folder (completely the fault of Microsoft Windows). Then try to save your code into a very 'unsecured' location, such as your temp folder or your USB jump drive. Windows usually do not safeguard such file locations. And if you are successful this time, congratulation! you have found the source of the problem. It is Windows denying the IDE access to your file system.

The next step is to fix the problem.

Go to the following location:
Settings --> Windows Security --> Ransomware protection --> Controlled folder access --> Allow an app through Controlled folder access --> Add an allowed app

From here, browse and add both "Program Files (x86)\Arduino\Arduino" and "arduino_debug" (for Arduino IED v1.8), or "Program Files\Arduino IDE\Arduino IDE" (for Arduino IDE 2.03) to the allowed app list.

If you have multiple computers, you may have to do this on every one of them. What a pain Microsoft has created for us! Security against malware is a good idea, but its implementation is too cumbersome. Microsoft needs to find a brighter developer to fix this mess.

I have to add a note here: IDE v2.03 is doing a horrible job detailing the underlying errors. It just showed 'access is denied, status 1' or something like that. This is no help in troubleshooting at all. With IDE 1.8 however, even though it ran into the same problem, it actually listed all the steps it was doing, and it showed that it was a file copy step being denied, which is much more useful in troubleshooting this problem.

That's all. I think this will fix most of the 'access denied' errors running in Windows 11.

.

.

1 Like

Thanks for your input; without it I wouldn't have made it this far. Some good news, some
not so good.

The "OSEPP Uno Rev 3 Plus" board uses an FTDI driver and a USB Type A 2.0 to a USB Mini cable.
The issue seems to be with the IDE "Serial Monitor" being active (open and previously had recieved data from the board) during subsequent sketch uploads. If the "Serial Monitor" is closed before a sketch upload (initial or subsequent) then the upload works successfully every time. Not sure why this is a happening but it's consistent and reliably repeatable.

I bought a real Arduino Uno and it does not have this issue. All uploads work just fine; even if the "Serial Monitor" is opened and had already received data from the board. This board uses a Microsoft USB Serial driver and a different cable; USB Type A 2.0 to a USB Type B 2.0.

Question:

I'd like to be able to use the OSEPP Uno Rev 3 board without having to close the "Serial Monitor" each time before uploading a sketch.
Any ideas?

The information you provided about the USB vendors and FTDI was enough to get me looking in that direction and to keep digging.
I went to the FTDI website to download the latest driver. When double-checking before installing it I discovered my system was already using the latest FTDI driver. So I did not install it again and continued to look elsewhere for the cause.

I did the reset button/upload/RX light trick and it produced 10 of the following error. But then, if I immediately uploaded again it allowed one successful upload of the program.
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x00
However; After the sketch began sending data to display on the 'Serial Monitor' all subsequent uploads failed again.

As you suggested; if I added a setup() delay(5000) or delay(60000) and uploaded subsequent times before the program began printing data to the 'Serial Monitor' the sketch uploaded without error everytime.
After the sketch began printing data to the 'Serial Monitor' the subsequent uploads all failed.

Q)) Would you call this type of behaviour a 'flooded serial output'?

Q)) Does this sound like a boot loader issue?

Q)) Both the real Arduino and the OSEPP board use the same upload settings. Might the OSEPP board be using the wrong 'programmer'?

         Using Port                    : COM100
         Using Programmer              : arduino
         Overriding Baud Rate          : 115200
         AVR Part                      : ATmega328P
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PC2
         RESET disposition             : dedicated
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         ByteDelay                     : 0
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

I went and checked the sketch file permissions, access to libraries, temporary output files, and the compiled code; all was ok.

Hi @alvinb123. Thanks for your report. I am able to reproduce the bug. It seems to be specific to boards using the FTDI USB chip.

I believe we already have a formal report about it here:

I have requested verification that the fault reported there only occurs when Serial Monitor is open while uploading. If it turns out to occur under different conditions then I will submit a dedicated report about the Serial Monitor/Serial Plotter interfering with the upload.

If you have a GitHub account, you can subscribe to that issue to get notifications of any new developments related to this subject.

7 posts were split to a new topic: Upload to board w/ CH340 fails due to denied port access when using IDE 2.x

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