Using an Adafruit ESP32 v2 on Mac - USB port errors

Trying to get an Adafruit ESP32 v2 to work on a Mac.
using Arduino IDE 2.0, downloaded and installed the correct BSPs and chipset drivers.
Simple sketch now compiles but won't upload.
Below is the error msg.
Needless to say ..... any help / suggestions much appreciated.

Traceback (most recent call last):
File "serial/serialposix.py", line 322, in open
OSError: [Errno 16] Resource busy: '/dev/cu.usbmodem54790241221'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "esptool.py", line 5387, in
File "esptool.py", line 5380, in _main
File "esptool.py", line 4687, in main
File "esptool.py", line 114, in get_default_connected_device
File "esptool.py", line 320, in init
File "serial/init.py", line 90, in serial_for_url
File "serial/serialposix.py", line 325, in open
serial.serialutil.SerialException: [Errno 16] could not open port /dev/cu.usbmodem54790241221: [Errno 16] Resource busy: '/dev/cu.usbmodem54790241221'
[923] Failed to execute script 'esptool' due to unhandled exception!
esptool.py v3.3
Serial port /dev/cu.usbmodem54790241221
Failed uploading: uploading error: exit status 1

Something else seems to be using already the port.

Any suggestions of how to find out what ???
Nothing else physically plugged in and i cant see any software issues

do you have a Serial monitor open on that port ? did something crash leaving the port open? are you 100% sure that /dev/cu.usbmodem54790241221 is your ESP32?

what happens if you reboot, plug the ESP32 in, launch the IDE, open the sketch and try to upload?

I get the same error message :frowning:

Sketch uses 235441 bytes (17%) of program storage space. Maximum is 1310720 bytes.
Global variables use 16168 bytes (4%) of dynamic memory, leaving 311512 bytes for local variables. Maximum is 327680 bytes.
Traceback (most recent call last):
File "serial/serialposix.py", line 322, in open
OSError: [Errno 16] Resource busy: '/dev/cu.usbmodem54790241221'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "esptool.py", line 5387, in
File "esptool.py", line 5380, in _main
File "esptool.py", line 4687, in main
File "esptool.py", line 114, in get_default_connected_device
File "esptool.py", line 320, in init
File "serial/init.py", line 90, in serial_for_url
File "serial/serialposix.py", line 325, in open
serial.serialutil.SerialException: [Errno 16] could not open port /dev/cu.usbmodem54790241221: [Errno 16] Resource busy: '/dev/cu.usbmodem54790241221'
[895] Failed to execute script 'esptool' due to unhandled exception!
esptool.py v3.3
Serial port /dev/cu.usbmodem54790241221
Failed uploading: uploading error: exit status 1

For some reason the port is being used or seen as used.

Have you tried with the latest non 2.0 IDE?

Have you tried an lsof on the device ?

No I haven't.
Would I need to erase all content and restart fresh?
ie the Arduino folder, the arduino15, the 2.0 IDE app etc
the full works ?

then reinstall IDE 1.8.19

You can have both 1.x and 2.0 installed - no need to remove 2.0

Running as root lsof or fuser -n file /dev/… could give you some hint on what process is holding the resource

sketch won't even compile in IDE 1.8.

exec: "python3": executable file not found in $PATH
Error compiling for board Adafruit Feather ESP32 V2.

running lsof -n file /dev/cu.usbmodem54790241221 in terminal gives ....

lsof: status error on file: No such file or directory

There is a quick fix for python3

See Exec: "python": executable file not found in $PATH - #30 by J-M-L

Just want to start with a big thank you for taking the time to help J-M-L
Really much appreciated.

so ......

Ok ..... running that bit of code (from the other thread) in terminal and then opening Arduino 1.8 via terminal has got rid of the error "exec: "python3": executable file not found in $PATH"

However ..... after compiling and trying to upload were now back to the same error in both versions of the IDE.

Traceback (most recent call last):
esptool.py v3.3
File "serial/serialposix.py", line 322, in open
Serial port /dev/cu.usbmodem54790241221
OSError: [Errno 16] Resource busy: '/dev/cu.usbmodem54790241221'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "esptool.py", line 5387, in
File "esptool.py", line 5380, in _main
File "esptool.py", line 4687, in main
File "esptool.py", line 114, in get_default_connected_device
File "esptool.py", line 320, in init
File "serial/init.py", line 90, in serial_for_url
File "serial/serialposix.py", line 325, in open
serial.serialutil.SerialException: [Errno 16] could not open port /dev/cu.usbmodem54790241221: [Errno 16] Resource busy: '/dev/cu.usbmodem54790241221'
[1053] Failed to execute script 'esptool' due to unhandled exception!
the selected serial port [1053] Failed to execute script 'esptool' due to unhandled exception!
does not exist or your board is not connected

if you do (as an admin or root)

sudo lsof /dev/cu.usbmodem54790241221

with the Serial monitor open or not

➜ what do you see ?

with an Lora ESP32 attached to my Mac and the serial monitor open I see

lsof /dev/cu.usbserial-0001
COMMAND  PID     USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
Arduino 1728     ****   88u  CHR     9,5    0t388  651 /dev/cu.usbserial-0001

if I close the Serial monitor then there is nothing to report

nothing.
Using serial tools as the monitor and after executing the code in the terminal window, it asks for the password, then there is a 10 second pause and it returns to the cursor.

Screenshot 2022-09-24 at 14.01.12

that's with the Serial monitor open in the IDE and pointing at /dev/cu.usbmodem54790241221 ?

nada

and with the 1.x IDE ?

that's weird

that was with 2.0
let me try 1.8

After initial plug in and config (ie set board to Adafruit ESP32 v2 and select port) it appears on the bottom line of the IDE like this.

If I then pull the cable out it shows as not connected like so .....

Screenshot 2022-09-25 at 10.13.30

But then if I plug it back in it does not reappear. I have to restart the computer to enable the port to be selected in the IDE again.