Cannot upload to arduino

I built a new pc, installed arduino v2.1.0, installed the necesssary libraries to support my sketch but when I go to upload get:

Sketch uses 8430 bytes (29%) of program storage space. Maximum is 28672 bytes.
Global variables use 384 bytes (15%) of dynamic memory, leaving 2176 bytes for local variables. Maximum is 2560 bytes.
avrdude: ser_open(): can't open device "\\.\COM6": Access is denied.

The arduino is connected to a small hub which is connected to a motherboard usb 3.2 port (red). The arduino is in a box next to a teensy and they are both connected to this small hub. I can program the teensy fine using the teensyduino library. Both show up in device manager. Nothing else is using com 6 as seen in device manager and usbtreeview. A different pc can program both devices without difficulty so I am stumped.

if you pull out teensy, which port has arduino?

  • Is there maybe something in the device manager? Open it and see if there is something strange...
  • You have assembled the PC. I believe that you can do that easily, but maybe something is connected wrong?
  • When you plug the board into the PC, do you get any error messages?

Have you tried bypassing the hub and plugging the Arduino directly into your computer?

Kindly check that you have selected the same port in IDE software you have connected too.

1 Like

Device manager showed no abnormalities. Connected arduino directly to motherboard USB with only keyboard and mouse: same issue

Built new arduino pro micro: same issue

SOLVED: Installed arduino 1.8.19. upload works fine. Prob some issue with 2.1.0 being installed on 'virgin' OS.

Does anyone know if this has been/will be resolved in an upcoming IDE version? I have the same trouble.. Everything works fine on v1.8.20, but I can't connect using v2.1. Cheers,

Hi @jmoondog. 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 certain boards while Serial Monitor or Serial Plotter is open. A port can only be used by one process at a time, so Arduino IDE automatically closes 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 for certain boards.

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

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

Hi @ptillisch , thanks for reply! Alas, I can't even get that far.. I'm using an Adafruit trinket.. All the appropriate drivers are there and I can select it under tools->board.. However, the port is not selectable at all. At the bottom right of the IDE I'd expect to see 'pro trinket(USB) connected on Port (whatever), but it simply shows 'not connected'. The computer recognizes the device though. If I use IDE 1.8.20 on the same computer, everything works fine.. my sketch has no serial statements, neither am I using serial monitor or plotter.. Any thoughts are appreciated! CHeers, Jeffrey

This is normal and expected when using the Adafruit Trinket. That board does not produce a serial port.

When using Arduino IDE 2.x, you must select Sketch > Upload Using Programmer to upload to the Trinket instead of clicking the Upload button as you can do with Arduino IDE 1.x. Please give that a try and then let me know whether you are now able to successfully upload to your Trinket.

I'll be darned! It worked! Thank you very much @ptillisch ! I was looking forward to using the new IDE and now I can! Cheers!

You are welcome. I'm glad it is working now.

The Arduino IDE developers are tracking the need to implement an "Upload Using Programmer by default" feature equivalent to the behavior of Arduino IDE 1.x here:

Regards,
Per

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