Go Down

Topic: Interfacing with Linux (Read 3349 times) previous topic - next topic


Hi all,

I'm a total Arduino noob.  Recently got myself an Arduino Uno (genuine one, not a clone) and am having trouble making it talk to Linux.  I introduced a small udev rules file and made it say something like this:

BUS=="usb", ACTION=="add", SYSFS{idVendor}=="2341", SYSFS{idProduct}=="0001", MODE="0666"

That makes it so I get the right permissions for a non-root user when running the ardiuno IDE.  Initially /dev/ttyACM0 was getting recognised all the time.  I wrote some code to interface with an LCD using some of the tutorials and uploaded it, it all worked OK.  Then I started experimenting with 1-wire and that's where all my problems began.  Most of the 1-wire temp sensing examples use the serial port, and what seems to happen with alarming regularity is the board gets in a state with the tx light on solid (presumably sending some serial data?) and just about then, I lose the connection between the IDE and the USB device, get complaints on the command-line about ttyACM0 lock files and so on.  The IDE slows to a crawl at this point, I guess it's repeatedly trying (and failing) to contact the board.

My theory is that if you happen to upload something which writes too much information to the serial port, you can no longer program the board.  To get out of this state I've found by trial and error, that I need to do the following (often about 3-4 times in succession) in order to get back to a working board:

1) Unplug the USB connector (otherwise the IDE takes forever to load and runs like treacle when it does)
2) Choose the barebones example (the one with empty setup() and loop() functions)
3) Compile it (it's only ~400 bytes)
4) Plugin the board and very quickly after hit the upload button
5) Wait and hope for the best

I repeat this about 4-5 times and eventually, I get the bare bones example back on the board, the tx light goes out, and from then the IDE recognises my /dev/ttyACM0 device without too many problems.  Everything tends to go OK from then up until the time when I start messing with serial code, and I then get the problem back again, I think it might have something to do with letting too much data accumulate in the Linux ttyACM0 receive buffer, without having the serial terminal open to deal with it.  It's just a theory.  There is obviously some buffering going on, because if you open the serial terminal a little while after you program finished uploading, you still get the startup messages appearing.

If anyone has any idea what's going on, please let me know.  This is driving me nuts.  I thought the Arduino was supposed to be easy to use.  Up until I started messing with the serial device, that was certainly the case, but now I'm considering going back to prototyping my own AVR circuits and using my USBTiny, for this project it's really important I have reliable communication between the Arduino and Linux, so any tips or tricks to make this work a bit more reliably will be appreciated.



Jan 30, 2011, 05:41 pm Last Edit: Jan 30, 2011, 05:48 pm by firestork Reason: 1
I am also having this same issue, but only with the newer Arduino MEGA 2560. So far I have not encountered this problem with my older Arduino MEGA 1280. The strange thing is that this rarely happens on my xp system, only linux. I am using the ArduinoIDE0021 and running UBUNTU Linux.

Have you tried to add a delay after the serailRead/Write? I believe that sometimes fixed the problem, although I am not a hundred percent sure as it was a awhile ago since I used that board.


Thanks for the post, at least it tells me I'm not going bonkers.   I knew I shouldn't have gone with the 'cutting edge' version as my first purchase!  I got the uno because I thought I could later play around with emulation of other USB devices, but I should have stuck with the Duemilanove.  Your Mega 2560 looks like it has the same USB interface chip as the Uno and I think that's the problem (at least for our kernels: mine is, Slackware).

I've played around with the old pl2302 and cp2101 based USB->serial converters with my AVR projects and never had problems with interfacing them to a Linux PC, so maybe I need to get the older board.  Think I will just order one because I don't really have time to dissect the ACM driver/Arduino IDE to figure out what's going on.

As for delays, yes I put plenty, but something odd is going on.  If the software uploaded correctly, there should be a seconds delay between the tx light going on for each packet, but that wasn't happening.  Maybe there is an issue with the program transfer/flashing as well?  Anyhow, I need a second board so I think I'll just go ahead and order a Duemilanove and maybe someone will figure out this problem in the meantime.

many thanks,


Depending on the Board, you could conceivably use an FTDI chip from one of your USB-Serial converters and hook it up to the Reset, Digital 0 (Rx), Digital 1 (Tx), GND and +5v pins on the Arduino, then use the standard method of uploading, as I am pretty sure that this is all the old board does anyway. Just make sure you only have one connected at a time, as you are setting up the FTDI to replace the function of the new Atmel chip.

Go Up