Find all your DIY electronics in the MakerShed. 3D Printing, Kits, Arduino, Raspberry Pi, Books & more!

Xo-Arduino-Screenshot

The XO Laptop comes with the drivers you need to talk to an Arduino board, but you need to do a few things before you can run the Arduino environment. Once you get it running, though, it works just fine. The first step is to install Java. To install Java on the XO Laptop, check out these instructions (the version of Java that you download will be different from what’s listed on that page, so you’ll need to modify the commands slightly to take that into account).

Once you’ve got Java up and running, you need to install the GNU C and C++ compilers as well as the LIBC for the AVR chip that the Arduino uses. To do this, open up the Terminal activity, su to root, and install avr-gcc, avr-libc, and avr-gcc-c++ using yum:

$ su
# yum install avr-gcc avr-libc avr-gcc-c++

While you’re root, you may as well make one of the changes you need to make; add the olpc user to the lock and uucp groups. To do this, edit the /etc/group file with the /usr/sbin/vigr command and add the olpc user to the end of the lock group:

lock::54:olpc

and to the end of the uucp group:

uucp::14:uucp,olpc

After you exit vigr (which is just a script that starts vi to safely edit the group file), decline its offer to edit the gshadow file, and type exit to get back to a normal (non-root) shell):

# /usr/sbin/vigr
You are using shadow groups on this system.
Would you like to edit /etc/gshadow now [y/n]? n
# exit
exit
$

Next, make sure you’re in your home directory, download Arduino (there may be a more recent version of it, so check the Arduino page to be sure. Extract Arduino in your home directory (you’ll be running it out of your home directory as well):

$ cd
$ wget http://www.arduino.cc/files/arduino-0010-linux.tgz
$ tar xvfz arduino-0010-linux.tgz

Now, you’re all Arduino-fied. To run it, cd to the arduino-0010 and run the arduino script:

$ cd ~/arduino-0010
$ ./arduino

There is one last trick: you’ll likely find that the Arduino user interface misbehaves quite a bit. To get it to work right, press the screen rotate button four times to get a nice 360 degree rotation. Arduino will redraw and start behaving itself as shown in the screenshot.

Update: As Seth points out in the comments, the Update.1 build that is coming out this month will do away with the su command, so you should use sudo -s instead of su (or simply prefix each superuser command with sudo).

Update 2: If you use JRE 5 from the Java technology archive instead of JRE 6, you won’t need to use the screen rotation trick. You’ll need to add these two lines to the .bashrc file in your home directory, and then stop and relaunch the Terminal activity:

export JAVA_HOME=/usr/java/jre1.5.0_13/
export PATH=$PATH:$JAVA_HOME/bin

You’ll need to install Java and modify your ~/.bashrc before you try running ./arduino

Brian Jepson

I’m a tinkerer and finally reached the point where I fix more things than I break. When I’m not tinkering, I’m probably editing a book for Maker Media.


Related

Comments

  1. Gian Pablo Villamil says:

    This works great, with one minor hiccup: if I run Arduino as a regular user, I get the message:

    lock_status: No permission to create lock file
    check_group_uucp(): error testing lock file creation

    When this happens, I can see no serial ports in the Arduino IDE.

    However, if I run as a superuser, everything is fine. I can compile and upload code to the Arduino with no issue.

    What am I doing wrong?

  2. Brian Jepson says:

    Gian,

    I think you might need to exit and restart the Terminal activity to make sure that your group membership in both “lock” and “uucp” is updated. You might need to restart, but I think restarting the Terminal should do the trick.

    Another thing you might try is running the command “newgrp uucp” just before you launch Arduino.

    Hope this helps,

    Brian

  3. Gian Pablo Villamil says:

    That did the trick!

    I am working on encapsulating Arduino as an OLPC activity (writing a Python wrapper basically) to sort out the UI issues, and so that it has a regular activity icon.

    This is a *huge* home run for the OLPC project.

  4. Brian Jepson says:

    Gian, that is wonderful news! I can’t wait to try out your activity when it’s done. I think the XO could become my Arduino programming device of choice!

  5. Seth Wodoworth says:

    You should edit your directions a little bit. As of Update.1 root is going to go away as a user, and you will have to sudo all of your commands.

    Also, the developers wont ship non-free java on the XO because it’s not open software. Do you know if the free-java equivalent works with the Arduino?

    Either way we would love to have a writeup on the OLPC wiki. (wiki.laptop.org/go/)

    Seth Woodworth (isforinsects)

  6. Brian Jepson says:

    Thanks, Seth. I noticed that su went away in the latest joyride, but I couldn’t find sudo in 650, so I have to wait until Update.1 is rolled out to revisit these instructions, otherwise they may not work for most G1G1 recipients.

    Could you give me some more information on free Java on the XO? Is there a wiki page with instructions on installing a free Java equivalent on the XO? At the bottom of http://wiki.laptop.org/go/Java there is a link to a mailing list post that says that Open Source JDK is still missing some important pieces. That page still directs users to the RestrictedFormats page.

    Cheers,

    Brian

  7. Scott Penrose says:

    Rather than re-launch terminal, you can just type “source .bashrc”. Saves waiting for the activity to restart.

  8. Chris Spurgeon says:

    Hmm, it looks like the Java install isn’t working for me. I don’t get any errors, it all seems to work just the way the XO Java instructions describe, but when I try to fire the Arduino install I get a “java not installed” error. I double checked and I *am* using jre-1_5_0_13-linux-i586-rpm.bin just like the instructions say. Any suggestions of things I can check?

  9. Chris Spurgeon says:

    Forgot to say, I am running release 656 on my XO. Does that make a difference?

  10. Brian Jepson says:

    Chris, it shouldn’t matter if you are running that build.

    Can you check what you put into your .bashrc very closely? I’ve seen this not work because someone forgot a $ or :

    Also, can you post the output of these commands?:

    echo $PATH
    cat ~/.bashrc
    ls /usr/java

    You can use a 3-button mouse to copy and paste (highlight the text you want to copy while you are in the Terminal activity, switch to the web browser, and paste it in with a middle click).

    Thanks,

    Brian

  11. Chris Spurgeon says:

    Hi Brian (great tutorial at ETech BTW!)…

    I haven’t altered my .bashrc yet, since that step came after the Arduino install step, and that fails for me. When I run ./arduino I get this error…

    ./arduino: line 16: java: command not found

    echo $PATH looks like this…

    /usr/share/activities/Terminal.activity/bin:/usr/bin:/bin

    cat ~/.bashrc looks like this…

    # .bashrc

    # Source global definitions
    if [ -f /etc/bashrc ]; then
    . /etc/bashrc
    fi

    # User specific aliases and functions

    The output of ls /usr/java is …

    jrel.5.0_13

    Thanks in advance for your help!

    Chris Spurgeon

  12. Brian Jepson says:

    Thanks, Chris. You should definitely modify your .bashrc before you proceed; that should be part of the Java installation.

    Sorry that I didn’t make that clearer (what I meant by putting it in the “Update” at the end was that you should do everything listed there in place of installing Java 6. This is because Java 6 takes care of putting things in your PATH, whereas Java 5 does not). I’ll amend the post to reflect that.

  13. Chris Spurgeon says:

    Sweet! That’s all it took, the Arduino IDE is up and running now, thanks! I love the idea of being able to have the smaller, more rugged XO as my machine when making last minute on-site Arduino code tweaks.

  14. Roland Latour says:

    If you use the above method to load Simple Message
    System, you can actually *use* that Diecimila by
    way of my shell script package. Full IO and PWM
    control. AD is scaled to mV and formatted for
    import to most spreadsheets. Run ‘wget
    207.14.167.161/SMS1.tgz’ to get the package.

  15. hc gilje says:

    Its been a while since this post was written, so maybe something has changed:
    when I type yum install avr-gcc avr-libc avr-gcc c++
    I get a not found error from this link.
    koji.fedoraproject.org/static-repos/olpc2-ship2-current/i386/repodata/repomd.xml

    any workaround for this?

    best
    hc

  16. Brian Jepson says:

    hc,

    I just looked into this, and there is a problem with the Fedora repository. According to this thread, the Fedora team is working on fixing this:

    http://www.olpcnews.com/forum/index.php?topic=3156.msg24661;topicseen

    - Brian