Arduino IDE first upload after reboot ok but COM "access refused" afterwards, while manually uploading using avrdude still succeeds at the same time

Hello

I am using arduino IDE 2.3.6 with an serial to usb adapter, and I upload a sketch to an Atmega 8A via usb to serial, using minicore.

After a reboot, the very first upload from Arduino IDE works fine :

...
Sketch uses 498 bytes (6%) of program storage space. Maximum is 7808 bytes.
Global variables use 9 bytes (0%) of dynamic memory, leaving 1015 bytes for local variables. Maximum is 1024 bytes.
"C:\Users\xxxxx\AppData\Local\Arduino15\packages\MiniCore\tools\avrdude\8.0-arduino.1/bin/avrdude" "-CC:\Users\xxxxx\AppData\Local\Arduino15\packages\MiniCore\tools\avrdude\8.0-arduino.1/etc/avrdude.conf" -v -V -patmega8 -curclock -PCOM8 -b38400 -D -xnometadata "-Ueeprom:w:C:\Users\xxxxx\AppData\Local\arduino\sketches\F1FF9E2869FA78A714464DCEDC676C99/sketch_jun9a.ino.eep:i" "-Uflash:w:C:\Users\xxxxx\AppData\Local\arduino\sketches\F1FF9E2869FA78A714464DCEDC676C99/sketch_jun9a.ino.hex:i"
Avrdude version 8.0-arduino.1
Copyright see https://github.com/avrdudes/avrdude/blob/main/AUTHORS

System wide configuration file is C:\Users\xxxxx\AppData\Local\Arduino15\packages\MiniCore\tools\avrdude\8.0-arduino.1\etc\avrdude.conf

Using port            : COM8
Using programmer      : urclock
Setting baud rate     : 38400
AVR part              : ATmega8
Programming modes     : SPM, ISP, HVPP
Programmer type       : Urclock
Description           : Urboot bootloaders using urprotocol
Protocol              : Urprotocol

AVR device initialized and ready to accept instructions
Device signature = 1E 93 07 (ATmega8, ATmega8A)

Processing -U eeprom:w:C:\Users\xxxxx\AppData\Local\arduino\sketches\F1FF9E2869FA78A714464DCEDC676C99/sketch_jun9a.ino.eep:i
Warning: no eeprom data found in Intel Hex file C:\Users\xxxxx\AppData\Local\arduino\sketches\F1FF9E2869FA78A714464DCEDC676C99/sketch_jun9a.ino.eep
Reading 0 bytes for eeprom from input file sketch_jun9a.ino.eep
in 0 sections of [0, -1]: 0 pages and 0 pad bytes
Writing 0 bytes to eeprom
Writing | ################################################## | 100% 0.00s
0 bytes of eeprom written

Processing -U flash:w:C:\Users\xxxxx\AppData\Local\arduino\sketches\F1FF9E2869FA78A714464DCEDC676C99/sketch_jun9a.ino.hex:i
Reading 498 bytes for flash from input file sketch_jun9a.ino.hex
in 1 section [0, 0x1f1]: 8 pages and 14 pad bytes
Preparing flash input for device bootloader
576 bytes in 2 sections of [0, 0x1e7f]: 9 pages and 0 pad bytes
Writing 576 bytes to flash
Writing | ################################################## | 100% 0.29s
576 bytes of flash written
Avrdude done.  Thank you.

Afterwards, every later upload via Arduino IDE fails with a Access denied for the COM port :

...
Sketch uses 498 bytes (6%) of program storage space. Maximum is 7808 bytes.
Global variables use 9 bytes (0%) of dynamic memory, leaving 1015 bytes for local variables. Maximum is 1024 bytes.
"C:\Users\xxxxx\AppData\Local\Arduino15\packages\MiniCore\tools\avrdude\8.0-arduino.1/bin/avrdude" "-CC:\Users\xxxxx\AppData\Local\Arduino15\packages\MiniCore\tools\avrdude\8.0-arduino.1/etc/avrdude.conf" -v -V -patmega8 -curclock -PCOM8 -b38400 -D -xnometadata "-Ueeprom:w:C:\Users\xxxxx\AppData\Local\arduino\sketches\F1FF9E2869FA78A714464DCEDC676C99/sketch_jun9a.ino.eep:i" "-Uflash:w:C:\Users\xxxxx\AppData\Local\arduino\sketches\F1FF9E2869FA78A714464DCEDC676C99/sketch_jun9a.ino.hex:i"
Avrdude version 8.0-arduino.1
Copyright see https://github.com/avrdudes/avrdude/blob/main/AUTHORS

System wide configuration file is C:\Users\xxxxx\AppData\Local\Arduino15\packages\MiniCore\tools\avrdude\8.0-arduino.1\etc\avrdude.conf

Using port            : COM8
Using programmer      : urclock
Setting baud rate     : 38400
Error: cannot open port \\.\COM8: Acc�s refus�.


Error: unable to open port COM8 for programmer urclock

Avrdude done.  Thank you.
Failed uploading: uploading error: exit status 1

It keeps the same “failing” behaviour :

  • if i exit and reopen Ardnuio IDE
  • if i plug/unplug the FTDI adapter
  • if i do both

But when Arduino IDE is closed, if i try to upload using the provided avrdude command in a simple powershell interpreter, it "always" succeeds (i.e. i haven't had a failure so far) :

PS C:\Users\xxxxx> C:\Users\xxxxx\AppData\Local\Arduino15\packages\MiniCore\tools\avrdude\8.0-arduino.1\bin\avrdude.exe "-CC:\Users\xxxxx\AppData\Local\Arduino15\packages\MiniCore\tools\avrdude\8.0-arduino.1/etc/avrdude.conf" -v -V -patmega8 -curclock -PCOM8 -b38400 -D -xnometadata "-Ueeprom:w:C:\Users\xxxxx\AppData\Local\arduino\sketches\F1FF9E2869FA78A714464DCEDC676C99/sketch_jun9a.ino.eep:i" "-Uflash:w:C:\Users\xxxxx\AppData\Local\arduino\sketches\F1FF9E2869FA78A714464DCEDC676C99/sketch_jun9a.ino.hex:i"
Avrdude version 8.0-arduino.1
Copyright see https://github.com/avrdudes/avrdude/blob/main/AUTHORS

System wide configuration file is C:\Users\xxxxx\AppData\Local\Arduino15\packages\MiniCore\tools\avrdude\8.0-arduino.1\etc\avrdude.conf

Using port            : COM8
Using programmer      : urclock
Setting baud rate     : 38400
AVR part              : ATmega8
Programming modes     : SPM, ISP, HVPP
Programmer type       : Urclock
Description           : Urboot bootloaders using urprotocol
Protocol              : Urprotocol

AVR device initialized and ready to accept instructions
Device signature = 1E 93 07 (ATmega8, ATmega8A)

Processing -U eeprom:w:C:\Users\xxxxx\AppData\Local\arduino\sketches\F1FF9E2869FA78A714464DCEDC676C99/sketch_jun9a.ino.eep:i
Warning: no eeprom data found in Intel Hex file C:\Users\xxxxx\AppData\Local\arduino\sketches\F1FF9E2869FA78A714464DCEDC676C99/sketch_jun9a.ino.eep
Reading 0 bytes for eeprom from input file sketch_jun9a.ino.eep
in 0 sections of [0, -1]: 0 pages and 0 pad bytes
Writing 0 bytes to eeprom
Writing | ################################################## | 100% 0.00 s
0 bytes of eeprom written

Processing -U flash:w:C:\Users\xxxxx\AppData\Local\arduino\sketches\F1FF9E2869FA78A714464DCEDC676C99/sketch_jun9a.ino.hex:i
Reading 498 bytes for flash from input file sketch_jun9a.ino.hex
in 1 section [0, 0x1f1]: 8 pages and 14 pad bytes
Preparing flash input for device bootloader
576 bytes in 2 sections of [0, 0x1e7f]: 9 pages and 0 pad bytes
Writing 576 bytes to flash
Writing | ################################################## | 100% 0.27 s
576 bytes of flash written
Avrdude done.  Thank you.

Yet, if i reopen Arduino IDE, and try re-uploading again, i get the same failures :

vrdude version 8.0-arduino.1
Copyright see https://github.com/avrdudes/avrdude/blob/main/AUTHORS

System wide configuration file is C:\Users\xxxxx\AppData\Local\Arduino15\packages\MiniCore\tools\avrdude\8.0-arduino.1\etc\avrdude.conf

Using port            : COM8
Using programmer      : urclock
Setting baud rate     : 38400
Error: cannot open port \\.\COM8: Acc�s refus�.

Error: unable to open port COM8 for programmer urclock

Avrdude done.  Thank you.
Failed uploading: uploading error: exit status 1

The only thing that solved the issue in Arduino IDE is when i perform a reboot

After rebooting, it works again in Arduino IDE, but just 1 single time, after it fails again (in IDE)

My computer and hardware setup :

  • Windows
    • 11 Familly
    • version 24H2 build 26100.6584
    • Windows pack 1000.26100.234.0
  • FTDI device
    • FT232RL
    • version 2.12.36.20 from 28/10/2024
    • service FTSER2K

It seems to me that Arduino IDE is internally keeping an opened "something" to the COM port after the first upload, and is not releasing it (except on exit).

What could be the problem and what steps should i take to either help diagnose, or solve it ?

Thanks in advance

Hi @nipil. There is a known bug in Arduino IDE 2.x that can cause uploads to fail with this "Access is denied" error if you try uploading to a board like the official Nano that uses an FTDI FT232R USB chip while the Arduino IDE Serial Monitor or Serial Plotter is open.

A port can only be used by one process at a time, so Arduino IDE must automatically close the port in Serial Monitor and Serial Plotter during an upload, automatically opening it again after. For some reason, that juggling of the port control is not working with boards that have the FTDI USB chip.

If that bug is the cause of the problem you are having, the workaround will be to manually close the port in Serial Monitor/Serial Plotter before doing an upload. Please give that a try and then let me know if you still have the error while uploading:

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:
  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

If you have the "Serial Plotter" window open, the procedure is a bit different from closing the Serial Monitor connection:

  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:
  4. Upload the sketch.
  5. Open Serial Monitor and/or Serial Plotter again if needed after the upload is finished.

Please let me know if you have any questions or problems while following those instructions.

I just did what was explained (and even tried to stop the serial plotter)

  • At first, nothing changed.
  • Serial monitor and Serial plotter turned off, i still got the same failure.
  • Then i proceeded to reboot.
  • This i could make a few consecutive uploads in Arduino IDE (no more error !)

Your advice solved my problem, but FYI an additional reboot was necessary after the changes.

Thanks for your quick help, and have a nice day :+1:

You are welcome. Thanks for taking the time to post an update with your findings!

Regards, Per