HOWTO run Arduino on the XO Laptop

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

Posted by Brian Jepson | Dec 21, 2007 06:35 PM
Education, Linux, olpc | Permalink | Comments (16) Bookmark and Share

Recent Entries

Comments

Newest comments listed first.

Posted by: Gian Pablo Villamil on December 22, 2007 at 4:31 PM

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?


Posted by: Brian Jepson on December 22, 2007 at 8:06 PM

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


Posted by: Gian Pablo Villamil on December 23, 2007 at 5:35 AM

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.


Posted by: Brian Jepson on December 23, 2007 at 9:20 AM

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!


Posted by: Seth Wodoworth on January 1, 2008 at 6:09 PM

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)


Posted by: Brian Jepson on January 1, 2008 at 6:24 PM

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


Posted by: Scott Penrose on March 3, 2008 at 7:44 AM

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


Posted by: Chris Spurgeon on March 9, 2008 at 3:29 PM

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?


Posted by: Chris Spurgeon on March 9, 2008 at 3:49 PM

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


Posted by: Brian Jepson on March 9, 2008 at 4:04 PM

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


Posted by: Chris Spurgeon on March 9, 2008 at 5:09 PM

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


Posted by: Brian Jepson on March 9, 2008 at 5:43 PM

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.


Posted by: Chris Spurgeon on March 9, 2008 at 8:00 PM

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.


Posted by: Roland Latour on March 10, 2008 at 2:27 AM

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.


Posted by: hc gilje on August 19, 2008 at 4:42 AM

errors installing gnu compiler and avr libraries

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


Posted by: Brian Jepson on August 19, 2008 at 6:25 AM

Re: errors installing gnu compiler and avr libraries

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


Leave a comment



Bloggers

Welcome to the Hacks Blog!

Brian Jepson.Brian Jepson


Jason Striegel.Jason Striegel


Philip Torrone.Phillip Torrone



See all of the books in the Hacks Series!
Advertise here.

Recent Posts

www.flickr.com
photos in Hacks More photos in Hacks