[on Sun 27 of Dec., 2009 22:55 EST, by LarryP]
Greetings all,
After my initial struggles getting my Maple to do something, and after getting some good help via the IRC and email, I decided to write up what worked for me. I hope this helps at least those with access to a LINUX system get started with their Maple boards.
Enjoy,
Larry
=============================================================================
Getting Started with a leafLabs' Maple board and the Arduino GUI, Linux version
Copyright (C) 2009
Lawrence E. Pfeffer, all rights reserved.
Contact via: ursine @t gmail d0t com
Version 1, 28 Dec. 2009, (Second draft)
Spellchecked, added copyright, changed to share-alike lic.
Licensed under the Creative Commons Attribution-Share Alike 3.0 United States License
http://creativecommons.org/licenses/by-sa/3.0/us/
===========================================================
Intro/Credits:
Following is a basic description of what I've done to get a simple Arduino sketch (blink.pde) working on my Maple board. This may not be the best way, and I suspect it'll be superseded by official docs. But until then, I hope it helps other Maple enthusiasts get started. I'll probably explain things that are obvious to many readers, but I'd rather be explicit, because some Maple users might find that extra detail useful.
Apparently, there is at least one command-line method to compile/load/run code on the Maple, but I haven't tried that, yet. If you have done so, please consider writing a similar doc and posting it to the forums. Similarly, if you've gotten a Maple working on a different O/S.
Much of the credit for key details goes to Andrew (Postlathian on leafblowers IRC) and John ( on leafblowers); errors or unclear language are my fault.
==========================================================
Main sources of Info:
Code repository: http://code.google.com/p/leaflabs/
IRC channel: irc://freenode/leafblowers
(I use the Chatzilla plugin for firefox)
leafLabs Forums: http://leaflabs.com/tiki-forums.php
=========================================================
My setup:
1. Dell Vostro 1500 laptop (with a couple open USB ports), running Ubuntu Linux, v9.04 = Jaunty Jacalope.
1.5 The root password (or sudo setup for you by ever does have root.)
2. Maple board
3. USB USB-mini cable
4. Internet connection
5. An anti-static Mat, grounded to the screw of an AC socket coverplate.
(An antistatic bag and a clip-lead to ground is way better than nothing, esp. in dry weather.)
==========================================================
Key software tools
Some of the steps require root permission. This is better done via sudo (for logging, etc.) than simply su'ing to root. So I suggest you use sudo (and sudoedit to create the sudoers file.) I think both are already installed on most distros. If not su to root, apt-get install them and use sudoedit to give yourself "super powers." (Google for instructions and an example sudoers file.) I gave myself permissions to sudo everything, for now.
Thereafter, use sudo instead of su'ing.
Software tools/packages and versions used (in addition to the leafLab's repo code), installed using apt-get install pkgName
apt-get probably in /usr/bin
sudo sudo/jaunty uptodate 1.6.9p17-1ubuntu3
subversion subversion/jaunty-security uptodate 1.5.4dfsg1-1ubuntu2.1
Java sun-java6-bin/jaunty-updates uptodate 6-16-0ubuntu1.9.04
JRE sun-java6-jre/jaunty-updates uptodate 6-16-0ubuntu1.9.04
dfu-util dfu-util/jaunty uptodate 0.0+r4880-1
apt-show-versions apt-show-versions/jaunty uptodate 0.15
Just to show versions of installed packages
Note, I had problems installing Java with apt-get, and {after some googling}, used the Synaptic Package Manager instead. The problem w/apt-get was that it wouldn't accept my click to accept the SUN license terms. But installing via Synaptic was able to do it fine. In Ubuntu, synaptic is invoked via
TopMenuBar->System->Administration->Synaptic Package Manager.
See https://bugs.launchpad.net/ubuntu/+source/sun-java6/+bug/307370 )
==========================================================================
Step 0.
Set up sudo, giving yourself root privileges. (Google sudo and/or sudoedit for instructions.)
-
Step 1.
Install the above packages (apt-show-versions is optional, but IMHO handy.)
via the following command in a terminal window:
apt-get install pkgName
-
Step 2: Pull down the code from leafLab's repository.
2.1 Find out where svn is installed:
which svn
It'll probably be something like:
larry@larry-laptop:~$ which svn
/usr/bin/svn
2.15 Set up your Internet access, if you aren't already online. If you have options, go for the highest bandwidth you have access to.
2.2 (Optional) open a web browser to http://code.google.com/p/leaflabs/source/checkout
This is where the code (and directions for browsing and downloading) are.
By clicking the Changes link, you can see what the latest revision is. I had my first success with rev 92. (Rapid changes while I slept; Thanks Andrew!)
2.3
cd to wherever you want the leafLabs code and tools to be downloaded.
2.4
If svn is on your PATH, run
svn checkout http://leaflabs.googlecode.com/svn/ leaflabs-read-only
If svn is not on your PATH (yet) run:
your/path/to/svn checkout http://leaflabs.googlecode.com/svn/ leaflabs-read-only
This is a *big* download, so expect it to take quite a while, esp. with a slow connection.
No help for it, unless you have higher bandwidth elsewhere, in which case you could try downloading and burning a CD.
I put this in under home directory, in ~/mapleStuff:
larry@larry-laptop:~/mapleStuff/leaflabs-read-only$ ls
branches tags trunk
larry@larry-laptop:~/mapleStuff/leaflabs-read-only$
-
3. Edit your PATH:
The syntax for environment variables is slightly different, depending on which shell you use.
In bash, you can show your path with:
larry@larry-laptop:~$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/home/larry//mapleStuff/leaflabs-read-only/trunk/maple/build/linux/work/hardware/tools/arm/bin/:/home/larry/bin:/home/larry//mapleStuff/leaflabs-read-only/trunk/maple/build/linux/work/hardware/tools/arm/bin/:/home/larry/bin:.
larry@larry-laptop:~$
IMHO, the best way to change your PATH (and not have to redo it) is to put it in a file that gets sourced when you open a shell. That's .bashrc on my system. So I added the following lines to my .bashrc file:
export MAPLE_BINUTILS=~/mapleStuff/leaflabs-read-only/trunk/maple/build/linux/work/hardware/tools/arm/bin/
export PATH=$PATH:$MAPLE_BINUTILS:~/bin:.
-
The first (export MAPLE_BINUTILS....) defines an env var for where the executable tools from leafLabs are (on my system.) The second line (export PATH=....) redefines PATH to it's previous contents + MAPLE_BINUTILS and the current directory.
(Copy your old .bashrc to another name, if you're cautious like me.) Edit .bashrc to suit, and test if by source'ing it and echo'ing your $PATH. Adjust until the
/absolute/path/to/your/mapleStuff/leaflabs-read-only/trunk/maple/build/linux/work/hardware/tools/arm/bin/
is somewhere on your PATH, separated from other entries by colons (:).
======================================================================
Step 4, Build the Arduino GUI
cd to /wherever/you/put/leaflabs-read-only/trunk/maple/build/linux
check for files and directories; you should have two .sh scripts and a subdir named work, like so:
larry@larry-laptop:~/mapleStuff/leaflabs-read-only/trunk/maple/build/linux$ ls
dist dist.sh jre.tgz make.sh run.sh work
If you put the current dir (.) on your path, you can build it with the command make.sh;
otherwise use ./make.sh:
larry@larry-laptop:~/mapleStuff/leaflabs-read-only/trunk/maple/build/linux$ make.sh
Building processing.core
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Done.
larry@larry-laptop:~/mapleStuff/leaflabs-read-only/trunk/maple/build/linux$
Note: you'll see (*much*) more resultant output than in my example; I had already built it before writing this doc. If you encounter errors, I suggest you join the IRC and seek help from whoever's on. (I had good luck there. And/or post to the leafLab forums (both problems and solutions, like this doc.)
============================
Step 5. Running the Arduino GUI (with *root* privileges)
In order for the GUI to download code to the Maple board,
it needs to use dfu-util and have root privileges. So this is where sudo comes in:
5.1 Launch the GUI via sudo:
sudo ./run.sh
trunk/maple/build/linux$ sudo ./run.sh
sudo password for larry:
(:7842): Gtk-WARNING **: Attempting to add a widget with type GtkButton to a GtkComboBoxEntry (need an instance of GtkEntry or of a subclass)
(:7842): Gtk-CRITICAL **: gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed
Experimental: JNI_onload called.
Stable Library
=========================================
Native lib Version = RXTX-2.1-7
Java lib Version = RXTX-2.1-7
This should pop up the (hopefully familiar) Arduino GUI. Note that this version says "Arduino 18"
5.2 Set the board type:
In the GUI, go to the top row and select
Tools -> Board -> LeafLabs Maple to Flash
5.3 Use a simple script for basic checkout, preferably one that needs no extra hardware.
I used the classic Blink sketch, since Maples already have an LED on the same pin as most Arduino boards. I used:
File > Open > Examples > Digital > Blink (Then double click on Blink.pde)
The sketch window should show the following code:
-
/*
Blink
Turns on an LED on for one second, then off for one second, repeatedly.
The circuit:
* LED connected from digital pin 13 to ground.
* Note: On most Arduino boards, there is already an LED on the board
connected to pin 13, so you don't need any extra components for this example.
Created 1 June 2005
By David Cuartielles
http://arduino.cc/en/Tutorial/Blink
based on an orginal by H. Barragan for the Wiring i/o board
*/
int ledPin = 13; // LED connected to digital pin 13
// The setup() method runs once, when the sketch starts
void setup() {
// initialize the digital pin as an output:
pinMode(ledPin, OUTPUT);
}
// the loop() method runs over and over again,
// as long as the Arduino has power
void loop()
{
digitalWrite(ledPin, HIGH); // set the LED on
delay(1000); // wait for a second
digitalWrite(ledPin, LOW); // set the LED off
delay(1000); // wait for a second
}
5.4 Verify that the toolchain is working correctly
Select Sketch > Verify/Compile
You should see *lots* of output in both the status pane of the Arduino GUI (and also in the window where you ran sudo ./run.sh) If all goes to plan, the end of this output should show something like so:
/home/larry/mapleStuff/leaflabs-read-only/trunk/maple/build/linux/work/hardware/tools/arm/bin/arm-none-eabi-size -A /tmp/build60846.tmp/blink.cpp.out
out :
section size addr
.text 13920 134238208
.ARM.exidx 8 134252128
.data 1368 536873984
.bss 408 536875352
.comment 1050 0
.debug_frame 604 0
.ARM.attributes 39 0
Total 17397
Binary sketch size is reported above. Check it against a 100000 byte maximum)
6. Download and run the code on your Maple:
6.1 ESD safety to keep your Maple healthy:
Discharge any static on you by touching something grounded. (E.g. bare wire secured to the screw between socket on an outlet.)
Remove your Maple from its antistatic bag and place on an antistatic mat, if you have one.
If not, running a wire or clip-lead from the antistatic bag your Maple came in to the screw between the sockets on an outlet will do *much* better than nothing. It ain't pretty, but it's reasonably functional.
6.2
Connect the mini end of a USB-to-miniUSB cable to your Maple.
6.3
Plug the big end of the cable into a USB port on your computer.
You should see a little blue LED (tiny SMT thing) blink furiously for a couple seconds.
6.4 Download and execute the blink code:
Click on the next-to-rightmost icon in the row below the word menus near the top of the GUI.
it's a box with an arrow pointing to the right.
The Maple's LED should blink furiously, and then settle down to once/second.
There should be copious text in the GUI's status pane, ending with (in red text):
dfu-util - (C) 2007-2008 by OpenMoko Inc.
This program is Free Software and has ABSOLUTELY NO WARRANTY
Opening USB Device 0x0110:0x1001...
Claiming USB DFU Runtime Interface...
Determining device status: state = appIDLE, status = 0
Device really in Runtime Mode, send DFU detach request...
Resetting USB...
Opening USB Device...
Found Runtime: 0x0110:0x1001 devnum=5, cfg=0, intf=0, alt=1, name="UNDEFINED"
Claiming USB DFU Interface...
Setting Alternate Setting ...
Determining device status: state = dfuIDLE, status = 0
dfuIDLE, continuing
Transfer Size = 0x0400
bytes_per_hash=305
Starting download: ################################################## finished!
state(8) = dfuMANIFEST-WAIT-RESET, status(0) = No error condition is present
Done!
Resetting USB to switch back to runtime mode
At this point, you have a functional Maple, and have successfully compiled, linked, downloaded and run a simple program. (Yes, a fair bit of work for a single blinkenLight, but the first step is often the hardest one....)
-
The rest is up to you. (And it's getting late here.)
I hope this document helps you/others get up and running. I hope to learn the non-GUI tools next. But if you know them, *please* write a similar document and post it for everybody (to the forums and/or the Wiki.) If you see errors, omissions, or unclear writing in this document, please let me know, and I'll do my best to fix it up.
Thanks,
Larry Pfeffer,
Lexington MA, USA
ursine @t gm4il d0t c0m