Error opening serial port '/dev/ttyUSBx' on Ubuntu

Hi!

I'm suddenly having problems uploading/communicating with my Arduino board via the Arduino Java IDE.. The strange thing is it happened after working for 2 days straight..

I was editing a program, continously uploading and testing it, when I clicked the "Serial Monitor" button so I could debug (which had worked fine just minutes ago).
First I get a lot of weird char's, like you'd get trying to Serial.print a non-alphanumeric byte (although it was an int) - then, after fiddeling with the Serial rate from the IDE (while the Arduino program was still running), I got an error.
Ctrl+c, ./arduino and "Upload to I/O Board"... Still get an error.

I've tried rebooting Ubuntu, reinstalling the software, removing all components and reprogrammed the Blink-example with my Windows machine (which worked - so I doubt the board is damaged).

Below is the full error message. I'm 100% sure the usb-device is correct.

processing.app.SerialException: Error opening serial port '/dev/ttyUSB0'.
at processing.app.Serial.(Serial.java:142)
at processing.app.Serial.(Serial.java:72)
at processing.app.Uploader.flushSerialBuffer(Uploader.java:66)
at processing.app.AvrdudeUploader.uploadViaBootloader(AvrdudeUploader.java:73)
at processing.app.AvrdudeUploader.uploadUsingPreferences(AvrdudeUploader.java:48)
at processing.app.Sketch.upload(Sketch.java:1632)
at processing.app.Sketch.exportApplet(Sketch.java:1701)
at processing.app.Editor$41.run(Editor.java:2004)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273
)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173
)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)
Caused by: gnu.io.UnsupportedCommOperationException: Invalid Parameter
at gnu.io.RXTXPort.setSerialPortParams(RXTXPort.java:171)
at processing.app.Serial.(Serial.java:132)
... 15 more

Try editing your Arduino preferences file (~/.arduino/preferences.txt I think) and setting the serial.debug_rate to, say, 9600. (serial.download_rate should be 19200).

Also make sure /dev/ttyUSB0 exists and has the correct permissions so your account can access it

You can chown it if necessary

sudo chown username /dev/ttyUSB0
dmesg

will let you confirm the FTDI chip is getting detected correctly

:slight_smile:

3 Likes
dmesg

should show messages like these when you connect your device

usb 2-6: new full speed USB device using ohci_hcd and address 5
usb 2-6: configuration #1 chosen from 1 choice
ftdi_sio 2-6:1.0: FTDI USB Serial Device converter detected
ftdi_sio: Detected FT232RL
usb 2-6: FTDI USB Serial Device converter now attached to ttyUSB0
usb 2-6: New USB device found, idVendor=0403, idProduct=6001
usb 2-6: New USB device strings: Mfr=1, Product=2, SerialNumber=3
usb 2-6: Product: TTL232R
usb 2-6: Manufacturer: FTDI
usb 2-6: SerialNumber: FTDxxxxx

Sometimes the device may not be ttyUSB0, it could be ttyUSB1 ttyUSB2 and so on

:slight_smile:

Try editing your Arduino preferences file (~/.arduino/preferences.txt I think) and setting the serial.debug_rate to, say, 9600. (serial.download_rate should be 19200).

Thanks, this fixed the problem! :slight_smile:

thanks
it works for me also
I just edit
Try editing your Arduino preferences file (~/.arduino/preferences.txt I think) and setting the serial.debug_rate to, say, 9600.

Ubuntu 9.10
Arduino Uno 0022

It appears to be intermittent, the menu is 10 seconds behind and sometimes the serial port is there and sometimes it dont

yesterday it eventually stabilised, (many unplugs reboots etc etc) and i ran it all day no probs, i assumed it was because i ran arduino as root which seemed to help but today it's not having any.

sudo ./arduino

terminal implied it was a permission issue so i chowned it to me anyways

sudo chown username  /dev/ttyACM0

it shows no serial port but i can upload! and fails only when i try to open the serial monitor

i get this message sometimes "serial port already in use" so i rm the lock and try again but i am going in circles

when run sudo ./arduino i get this in the terminal window, it implies my port isn't there

Native lib Version = RXTX-2.1-7
Java lib Version   = RXTX-2.1-7
RXTX Warning:  Removing stale lock file. /var/lock/LCK..ttyACM0
Binary sketch size: 7564 bytes (of a 32256 byte maximum)
processing.app.SerialNotFoundException: Serial port '/dev/ttyACM0' not found.  Did you select the right one from the Tools > Serial Port menu?
      at processing.app.Serial.<init>(Serial.java:153)
      at processing.app.Serial.<init>(Serial.java:76)
      at processing.app.debug.Uploader.flushSerialBuffer(Uploader.java:75)
      at processing.app.debug.AvrdudeUploader.uploadViaBootloader(AvrdudeUploader.java:93)
      at processing.app.debug.AvrdudeUploader.uploadUsingPreferences(AvrdudeUploader.java:56)
      at processing.app.Sketch.upload(Sketch.java:1603)
      at processing.app.Sketch.exportApplet(Sketch.java:1568)
      at processing.app.Sketch.exportApplet(Sketch.java:1524)
      at processing.app.Editor$DefaultExportHandler.run(Editor.java:2293)
      at java.lang.Thread.run(Thread.java:636)

i don't know the answer but hope there is a fix for this one day

... i got it working briefly today by sudo ./arduino then pasting in my code into the default (and empty) sketch and saved then uploaded it without looking at the selected Serial port, Yay success, but the next upload a minute later failed with the old 'Serial port /dev/ttyACM0 not found' nutmeg

aaaaagggghh

1 Like

kubuntu 9.10
arduino-0022
arduino-0021 [?]

i have the exact same problem. it started yesterday when i tried arduino-0022 to play with my new ethernet/sd shield. there is a huge lag in the java application and i cannot choose a serial port.

i deleted the preference file, but it did not help. i used a fresh sketchbook folder. i was not able to change/see the serial port and it complained com1 was busy. my serial port is /dev/ttyACM0. i closed the application and edited the serial device in the preference file. when i started the application, it automatically had chosen the duemilanove instead of uno and i could see/set the serial port. i changed it to uno and the serial port was gone.

it is not usable at all anymore and the application is really, really slow/nonresponding :frowning:

sorry, i did not realise that this is an ancient thread. should we open up a new one for this, even if it seems to be related?

also i found that after i manage to upload a sketch without serial output, all seems to be fine again. if i upload one of the basic examples without all seems ok (i tried "blink" and can use the software again). if i upload basic-analogreadserial it is broken again.

i will need serial output soon though? :confused:

it complained com1 was busy

If you can, post the actual error message you are getting.

Does arduino software run normally without the uno plug in? select the duemilanove board, how does it run.

plug in the uno and run the commands:
lsusb -v
ls /dev/tty*

and post results

thank you, i could solve my problem with some further reading in this fine forum. it is a problem of the old firmware of the 8u2 (uno's replacement for the ftdi). basically it blocks the serial port by constantly sending data when serial output is used in a sketch.

i solved it by

  1. setting the arduino in dfu-mode http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1285962838/10#10
  2. uploading the new firmware http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1286088093/34#34
  3. unplugging the arduino and plugging it in again

it's faster than ever now and serial output seems to work fine too :slight_smile:

i hope this can help andy mac too.