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.
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
Click the X icon on the "Serial Monitor" tab in the bottom panel of the Arduino IDE window to close the tab:
Upload the sketch.
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:
Close the "Serial Plotter" window.
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
Click the X icon on the "Serial Monitor" tab in the bottom panel of the Arduino IDE window to close the tab:
Upload the sketch.
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.
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: