Arduino on Ubuntu x86_64

I recently picked up a new laptop (Thinkpad t61), and have been working to get it set up the way I like it. Installing Ubuntu on it was dead simple- using the Hardy Heron 8.04 beta, I had a fully functional system right out of the box. Today I took a look at getting Arduino up and going, so I can get back to work on some projects. Instructions after the break.

On 32-bit systems, the Arduino platform should work fine out of the box. Unfortunately there is a bit of an incompatibility on x86_64 platforms, due to the serial library. I actually ran into this when I set it up on my previous system, but forgot to document it then. I found some steps to work around the problem here. This is what I did to get it to work (you should be able to copy and paste this verbatim into a terminal window):

eval sudo apt-get install gcc-avr sun-java6-jre avr-libc librxtx-java
wget http://www.arduino.cc/files/arduino-0011-linux.tgz
tar -xf arduino-0011-linux.tgz
cd arduino-0011
echo '3c3
< CLASSPATH=java/lib/rt.jar:lib:lib/build:lib/pde.jar:lib/core.jar:lib/antlr.jar:lib/oro.jar:lib/registry.jar:lib/mrj.jar:lib/RXTXcomm.jar
---
> CLASSPATH=java/lib/rt.jar:lib:lib/build:lib/pde.jar:lib/core.jar:lib/antlr.jar:lib/oro.jar:lib/registry.jar:lib/mrj.jar:/usr/share/java/RXTXcomm.jar
13c13
< LD_LIBRARY_PATH=`pwd`/lib:${LD_LIBRARY_PATH}
---
> LD_LIBRARY_PATH=`pwd`/lib:${LD_LIBRARY_PATH}:/usr/lib
' | patch arduino -
mv lib/RXTXcomm.jar lib/RXTXcomm.jar.orig
mv lib/librxtxSerial.so lib/librxtxSerial.so.orig
./arduino

If you are curious, here is a blow-by-blow interpretation:

1. First, install the requisite packages, per the instructions on theArduino site. I chose to use java6 instead of java5. Also install librxtx-java, because the one included with the Arduino software is not compatible with the 64-bit environment. The eval statement is so the script will continue regardless of whether the apt-get command succeeds.

eval sudo apt-get install gcc-avr sun-java6-jre avr-libc librxtx-java

2. Next, get the Arduino release and un-tar it:

wget http://www.arduino.cc/files/arduino-0011-linux.tgz
tar -xf arduino-0011-linux.tgz

3. Change the Arduino startup file so that it uses the newly installed rxtx library instead of the built-in one. This is done by passing the differences to the patch command, which then opens the files and makes the changes. This just saves the trouble of editing the file by hand.

cd arduino-0011
echo '3c3
< CLASSPATH=java/lib/rt.jar:lib:lib/build:lib/pde.jar:lib/core.jar:lib/antlr.jar:lib/oro.jar:lib/registry.jar:lib/mrj.jar:lib/RXTXcomm.jar
---
> CLASSPATH=java/lib/rt.jar:lib:lib/build:lib/pde.jar:lib/core.jar:lib/antlr.jar:lib/oro.jar:lib/registry.jar:lib/mrj.jar:/usr/share/java/RXTXcomm.jar
13c13
< LD_LIBRARY_PATH=`pwd`/lib:${LD_LIBRARY_PATH}
---
> LD_LIBRARY_PATH=`pwd`/lib:${LD_LIBRARY_PATH}:/usr/lib
' | patch arduino -

4. Re-name the serial library files that are included in the Arduino distribution, so that they do not interfere with the ones we installed in step 2.

mv lib/RXTXcomm.jar lib/RXTXcomm.jar.orig
mv lib/librxtxSerial.so lib/librxtxSerial.so.orig

5. Run the software! You might want to make an icon for it or something.

./arduino
This entry was posted in tech. Bookmark the permalink.

11 Responses to Arduino on Ubuntu x86_64

  1. Carl says:

    This also works with version 0012. Thanks!

  2. John says:

    Bummers, this doesn’t work with arduino-0012 on my x86_64 Jaunty Jackalope setup, running the:

    Java VM: OpenJDK 64-Bit Server VM (14.0-b08 mixed mode linux-amd64 )

    though everything else works fine, I can program the sucker and watch LEDs blink happily. I’m happy with that at least!

    Any hints?
    John

  3. mahto says:

    Hi John,

    What exactly isn’t working for you? Error messages? I haven’t looked at Jaunty yet.

    Matt

  4. sleepercivic88 says:

    Experimental: JNI_OnLoad called.
    WARNING: RXTX Version mismatch
    Jar version = RXTX-2.2pre1
    native lib Version = RXTX-2.1-7
    RXTX Warning: Removing stale lock file. /var/lock/LCK..ttyUSB0
    #
    # An unexpected error has been detected by Java Runtime Environment:
    #
    # SIGSEGV (0xb) at pc=0x00007fb49aa53b44, pid=20859, tid=140413698619728
    #
    # Java VM: Java HotSpot(TM) 64-Bit Server VM (11.3-b02 mixed mode linux-amd64)
    # Problematic frame:
    # C [librxtxSerial-2.1-7.so+0x8b44] Java_gnu_io_RXTXPort_nativeDrain+0xf4
    #
    # An error report file with more information is saved as:
    # /home/sleepercivic88/arduino-0015/hs_err_pid20859.log
    #
    # If you would like to submit a bug report, please visit:
    # http://java.sun.com/webapps/bugreport/crash.jsp
    #
    Aborted (core dumped)

    IN jaunty this is what happens to me. everything seems to work except for serail monitor. I can write to the arduino but as soon as I send a command over serial I get this error.

  5. sleepercivic88 says:

    I mean I can download code to the arduino but cant write seral through the serial monitor.

  6. mahto says:

    Hmm, that doesn’t look good, perhaps the java library layout has changed? I just ordered a new hard drive, so when I get it I’ll install Jaunty and see if I can re-create the problem…

  7. mahto says:

    Ok, I’ve got Jaunty up and running on my system, and ran into the same issue: programming works fine, but sending data from the serial monitor to the Arduino causes the program to crash. If I figure it out, I’ll post my solution here.

  8. sleepercivic88 says:

    I just use GtkTerm for the time being.

    • mahto says:

      do you mean, you use gtkterm as a serial terminal? do you just connect it to the serial tty device? i’ve been using minicom, though admittidly i havent done much serial communication with the PC so it hasn’t been a huge issue for me.

  9. Adam says:

    I confirmed this is happening with arduino-0017 on my 64-bit system as well. The arduino file no longer patches cleanly with the patch above, but the part that fails is no longer required so it’s no big deal. I get the same stacktrace as posted above. As long as you don’t use the serial monitor in arduino it works, and using gtkterm for monitoring the serial communication works fine. Hopefully someone will get arduino patched so it can work with 64 bit systems out of the box.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>