Arduino Setup instructions for Raspberry Pi

These instructions are for setting up an Arduino and alamode friendly environment on the Pi. Gathered from many sources (see earlier posts) and updated with the latest info.

Download and install Linux Image

Download the Black Raspberry Distribution from Adafruit:
http://learn.adafruit.com/adafruit-raspberry-pi-educational-linux-distro
DIrect link to the current (0.2 version):
http://adafruit-raspberry-pi.s3.amazonaws.com/Occidentalisv02.zip

Burn to your favorite sd card. Helpful tips at:
http://elinux.org/RPi_Easy_SD_Card_Setup

If you need to set up Wifi, or other things, follow the instructions at the first link above.

Configure your keyboard and Timezone

It’s difficult to edit config files when the quote key produces a different symbol.
Unless you are in or have a Great Britain keyboard, you’ll need to:

[code]sudo dpkg-reconfigure keyboard-configuration
sudo dpkg-reconfigure tzdata[/code]

Reboot

Serial Port configuration

AlaMode can communicate via the UART pins of the GPIO connector. Unfortunately, for now, the Arduino IDE doesn’t recognize the device name /dev/ttyAMA0, so you’ll need to create an alias. By the way, it also doesn’t recognize the Arduino UNO (/dev/ttyACM0) so you can handle this the same way.
[code]

sudo vi /etc/udev/rules.d/80-alamode-rules

KERNEL==”ttyAMA0″,SYMLINK+=”ttyS0″ GROUP=”dialout”
KERNEL==”ttyACM0″,SYMLINK+=”ttyS1″ GROUP=”dialout”

[/code]

Next, disable logging messages:
This bit disables logging to the GPIO UART, so if you are using an Arduino via USB, it’s not necessary.
[code]Edit /boot/cmdline.txt
From:

dwc_otg.lpm_enable=0 rpitestmode=1 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 rootwait

to:

dwc_otg.lpm_enable=0 rpitestmode=1 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 rootwait[/code]

deleting the two parameters involving the serial port /dev/ttyAM0
You also have to edit /etc/innitab to remove the login (getty)
comment out:

[code]2:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100[/code]

Reboot

Installing the Arduino IDE

Before getting any of the other packages:

[code]sudo apt-get update[/code]

and again:

[code]sudo apt-get update[/code]


The IDE is written in Java (based on Processing) and while Oracle doesn’t have an official Java for the ARM core in the Pi, the Open JDK has been ported. It doesn’t have a JIT (Just In Time Compiler) so it’s a little slower, but it works.
First grab the Arduino IDE code. 1.01 is heavily entwined with the native GCC toolchain, so is a lot more work and not recommended. For now, stick with 1.0.

[code]wget http://arduino.googlecode.com/files/arduino-1.0-linux64.tgz

tar zxvf arduino-1.0-linux64.tgz[/code]

The Arduino IDE is written in Java, but there are native parts to do compilation for the atmega328p  microcontroller. Fortunately those have also been ported:

[code]sudo apt-get install avr-libc

sudo apt-get install libftdi1

sudo apt-get install avrdude[/code]

Java:

[code]sudo apt-get install openjdk-6-jre[/code]

Serial support:

[code]sudo apt-get install librxtx-java[/code]

And then copy the native stuff into the Arduino directory:

[code]cd arduino-1.0

for i in $(find . -name “librxtxSerial.so”) ; do cp /usr/lib/jni/librxtxSerial.so $i ; done

for i in $(find . -name “RXTXcomm.jar”) ; do cp /usr/share/java/RXTXcomm.jar $i ; done

cp /usr/bin/avrdude /home/pi/arduino-1.0/hardware/tools/avrdude

cp /etc/avrdude.conf /home/pi/arduino-1.0/hardware/tools/avrdude.conf

[/code]

And probably reboot again, and then you should be good to go! Contact me on Google + and let me know how it goes!