[upload] could not open port /dev/ttyACM0: [Errno 2] No such file or directory: '/dev/ttyACM0'

Hello All, I am running platformIO IDE above VSC. I get the above error trying to upload to my uno board.
My /dev is in my PATH and the file is there.

I got a list of my serial ports using the command below
$ dmesg | grep tty //to find serial ports
[ 0.000000] console [tty0] enabled
[37119.190390] cdc_acm 1-4.3:1.0: ttyACM0: USB ACM device
[38796.029040] cdc_acm 1-4.3:1.0: ttyACM0: USB ACM device
[38860.567181] cdc_acm 1-4.2:1.0: ttyACM0: USB ACM device

My ini file contains:

platform = atmelavr
board = uno
framework = arduino
upload_port = /dev/ttyACM0:

BTW I can use the arduino ide to upload to my board succesfully using /dev/ttyACM0

so, I don’t know why platform can not find the serial port for uploading to my board.
Any help is appreciated.

1 Like

The device file (unix: everything is file) does not contain a final :. It’s just the path to the device file for that USB / UART adapter (or USB ACM device).

So you should try /dev/ttyACM0.

If this doesn’t work we need a full error log and the output of ls -la /dev/ttyACM0. You might have wrong group permissions on that “file” which disallow that it is opened by a normal user / the dialout / plugdev group or whatever (refer to Linux Setup | Adafruit Arduino IDE Setup | Adafruit Learning System).

Thank you for responding Max.

I have removed the colon from the upload_port command. Also tried removing the upload_port cmd to
see if platformio could find port by default, but could not.

Below is the error text and some commands showing existance of files, and groups

Configuring upload protocol…
AVAILABLE: arduino
CURRENT: upload_protocol = arduino
Looking for upload port…
Use manually specified: /dev/ttyACM0
*** [upload] could not open port /dev/ttyACM0: [Errno 2] No such file or directory: ‘/dev/ttyACM0’
[ERROR] Took 6.95 seconds ==============================================================
The terminal process terminated with exit code: 1
Terminal will be reused by tasks, press any key to close it.

$ ls -la /dev/ttyACM0
crw-rw---- 1 root dialout 166, 0 May 26 06:53 /dev/ttyACM0

$ groups
joe adm dialout cdrom sudo dip plugdev lpadmin sambashare

/etc/udev/rules.d $ ls -l
-rw-r–r-- 1 root root 9304 May 25 21:50 99-platformio-udev.rules

udev rules file (just the part concerning arduino)

Arduino boards

SUBSYSTEMS==“usb”, ATTRS{idVendor}==“2341”, ATTRS{idProduct}=="[08][02]", MODE:=“0666"
SUBSYSTEMS==“usb”, ATTRS{idVendor}==“2a03”, ATTRS{idProduct}==”[08][02]
", MODE:=“0666”

Thanks again

Weird that it would say that it cannot find the file when it’s there. Do you run in some kind of VM? Does it work on other computers? You have a standard Uno board, right? Did you try diferent USB cables? Can you attach do a dmesg -w, then an upload from the IDE and post that output?

No VM’s that I no of. Using linux mint and new to linux (about two weeks).
It is wierd that it is looking in the correct directory and saying it can not find it
but i can list it.

Yes, I have a standard uno board.

This is my only computer with linux and my only computer with platformio.
When I upload from Geany or arduino ide there is no problem so it’s not the usb cable.

Output from mesg -w command when connecting uno via usb
[619390.909930] usb 1-4.2: new full-speed USB device number 13 using xhci_hcd
[619391.012156] usb 1-4.2: New USB device found, idVendor=2a03, idProduct=0043
[619391.012160] usb 1-4.2: New USB device strings: Mfr=1, Product=2, SerialNumber=220
[619391.012162] usb 1-4.2: Product: Arduino Uno
[619391.012163] usb 1-4.2: Manufacturer: Arduino Srl
[619391.012165] usb 1-4.2: SerialNumber: 8553130343135131E140
[619391.014942] cdc_acm 1-4.2:1.0: ttyACM0: USB ACM device

when i upload from platformio there is no change in the buffer from the kernel.

Thanks for your help.

You’re using Linux Mint 18.3?

Can you try to upload from the shell as root? Inside your project directory, to sudo pio run -t upload.
Have you reloaded the udev rules as in the Adafruit link given above? Have you done a full reboot after that? Can you do a reboot and retry? Can you try removing the 99-platformio-udev.rules again and retry?

I have literally no idea why it doesn’t find the device anymore when dmesg doesn’t say anything about a removed / inserted device. I thought maybe it would eject the device temporarily or something.

Yes, linux mint 18.3

I shut the machine off and turned it back on.

added the ~/.platformio/penv/bin directory to my path so I could access pio commands from outside the platformio_ide , PATH is below so it is in there.

joe@joe-450-a114 ~ $ echo $PATH

when I try to run the command you gave me I get the error shown below.
joe@joe-450-a114 ~/Documents/PlatformIO/Projects/180525-203708-arduino-blink $ sudo pio run -t upload
[sudo] password for joe:
sudo: pio: command not found

Using the terminal inside platformio
sh-4.3$ pio run -t upload

Configuring upload protocol…
AVAILABLE: arduino
CURRENT: upload_protocol = arduino
Looking for upload port…
Use manually specified: dev/ttyACM0
*** [upload] could not open port dev/ttyACM0: [Errno 2] No such file or directory: ‘dev/ttyACM0’

I think I tried everything. I will see if I can use the cmd line inside platformio and see if I can get any
traction. Other than that I can un-install then install

Thanks for your ideas : )

I think this is linux permission problem. Try to start vscode with sudo. Following command will open your vscode and then upload your sketch.
$ sudo code --user-data-dir ~/YOURPROJECTLOCATION

I can upload my sketches without errors with the above command in Ubuntu 18.04.

1 Like

To get rid of this error you can try using os.listdir() function to check that at least python sees the file exists or not.

1 Like

That would then suggest you need to add your user to the dialout group, so that you don’t use sudo when it’s not needed! :wink:

Please install 99-platformio-udev.rules

Hello, one problem might be your brltty that silently blocks the upload port.
brltty is software designed to assist people with visual impairments or blindness.
$ ps -C brltty
$ sudo apt-get remove brltty
$ sudo usermod -a -G dialout $USER
$ sudo usermod -a -G plugdev $USER
These commands should solve this problem. Ive had same problem with many computers and doing this always does the thing.

  • error msg: No device found on ttyACM0 when trying to upload
  • linux version: debian/kde plasma
  • i installed 99-platformio-udev.rules and rebooted
  • still getting: No device found on ttyACM0
  • also had to do:

    sudo usermod -a -G dialout <your_user_name_here>

    • this cmd adds a user to dialout group
  • now i can upload.