arduino on a headless pi

Moderators: adafruit_support_bill, adafruit

Forum rules
Talk about Adafruit Raspberry Pi® accessories! Please do not ask for Linux support, this is for Adafruit products only! For Raspberry Pi help please visit: http://www.raspberrypi.org/phpBB3/
Locked
tldr
 
Posts: 466
Joined: Thu Aug 30, 2012 1:34 am

arduino on a headless pi

Post by tldr »

so a while back i ordered some stuff and padded my order with a couple of hundred dollars in gift certificates and finally got a pi. then adafruit started selling them. then newark had some in stock. then mcm started carrying them.

but, anyway, i got mine. also got one of those pl2303 usb-ttl serial cables, a pi box and a ribbon cable. and i finally got some time to play with it. i stuck a piece of header into the end of the ribbon cable and plugged the pl2303 into the appropriate place, then downloaded occidentalis v0.2, logged in via the console, enabled ssh, plugged in to my lan, and wondered what to do next.

well, it would be nice to have a screen on the thing, so i figured i'd get vnc going.

turned out to be pretty easy.

Code: Select all

sudo apt-get install tightvncserver
tightvncserver
vncserver :1 -geometry 1280x720 -depth 16
the first line installs the tightvncserver package on the pi. it also happens to include the vnc client, which is called vncview.

the second line configures the package which involves prompting you for two passwords. the first password is for a regular interactive vnc connection. the second is the password to use if you want a view only session without control of the keyboard and mouse on the pi.

the third line starts the vnc server on the pi. ":1" specifies the screen number. "-geometry 1280x720" specifies the screen geometry for the virtual console and "-depth 16" specifies the color depth of the display.

cool. now i'm able to run the gui on the pi from other computers on my lan.

what now?

arduino, of course. the problem with installing arduino on the pi is that the arduino team hasn't distributed any packages with binaries for arm. still, the first thing to do is download the arduino package, then uncompress it, then delete the x86 versions of the compiler, avrdude and a host of other useful by incompatible tools.

actually, the first thing to do is update the package lists on the pi.

Code: Select all

sudo apt-get update
wget http://arduino.googlecode.com/files/arduino-1.0.1-linux.tgz
tar zxvf arduino-1.0.1-linux.tgz
mv arduino-1.0.1/hardware/tools arduino-1.0.1/hardware/foo
the first line, like i said, updates the package lists on the pi.

the second line retrieves the arduino ide from google code. it is compressed into a what's know as a tarball, named after the program we'll use to uncompress it.

the third line uses a utility called tar to uncompress the tarball. the ar in tar is for "archiving." after this step we've got a pretty standard looking arduino installation in a directory called ~/arduino-1.0.1. the problem is that although the arduino ide itself is written in java which is cross platform, there are several binaries in the package that were compiled to a 32bit x86 linux machine.

the fourth line hides all of those binaries, by renaming the directory in which they are stored. fortunately, if arduino cannot find these programs within its own directory structure, it will search for them in their normal locations on the system.

so it's up to us to put them there.

Code: Select all

sudo apt-get install avr-libc
sudo apt-get install libftdi1
sudo apt-get install avrdude
here, the first line installs the c++ compiler, various utilities and libraries all needed to compile your arduino programs.

the second line installs a library that allows programs on the pi to talk to the ftdi chips on some older arduinos.

the third line installs a program called avrdude, which arduino uses to upload your program to your arduino board once it is compiled.

alas, there remaina couple of things to do. as i mentioned before, the arduino ide, itself, is written in java. the occidentalis distribution i'm running does not have a java virtual machine, so that must be installed. there is also a platform dependent library that arduino relies on for serial communication called librxtxjava, that we must install and then copy into the correct location in the arduino's directories.

Code: Select all

sudo apt-get install openjdk-6-jre
sudo apt-get install librxtx-java
cp /usr/lib/jni/librxtxSerial.so ~/arduino-1.0.1/lib/
cp  /usr/share/java/RXTXcomm.jar ~/arduino-1.0.1/lib/
the first line, here, installs a java development kit.

the second line installs librxtx.

the third and fourth lines copy the rxtx system and java libraries into the arduino directory tree.

that's it. i can now fire up a virtual network connection on any computer on my home network and start working on code on an arduino connected to my raspberry pi.

i like it. i learned some stuff. looks like i've got my 8Gb sd card about 31% full.

Image

here are the commands i used all in one place. you can probably roll them all up in a file, run chmod to make it executable and just run it as a shell script. tightvncserver is the only thing that requires any input from the user.

Code: Select all

sudo apt-get install tightvncserver
tightvncserver
vncserver :1 -geometry 1280x720 -depth 16
sudo apt-get update
wget http://arduino.googlecode.com/files/arduino-1.0.1-linux.tgz
tar zxvf arduino-1.0.1-linux.tgz
mv arduino-1.0.1/hardware/tools arduino-1.0.1/hardware/foo
sudo apt-get install avr-libc
sudo apt-get install libftdi1
sudo apt-get install avrdude
sudo apt-get install openjdk-6-jre
sudo apt-get install librxtx-java
cp /usr/lib/jni/librxtxSerial.so ~/arduino-1.0.1/lib/
cp  /usr/share/java/RXTXcomm.jar ~/arduino-1.0.1/lib/
Last edited by tldr on Tue Apr 30, 2013 8:37 pm, edited 1 time in total.

tldr
 
Posts: 466
Joined: Thu Aug 30, 2012 1:34 am

Re: arduino on a headless pi

Post by tldr »

this does not provide the same compiler version as the arduino distribution. avr-gcc -v gives the following

Code: Select all

pi@raspberrypi ~ $ avr-gcc -v
Using built-in specs.
COLLECT_GCC=avr-gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/avr/4.7.0/lto-wrapper
Target: avr
Configured with: ../src/configure -v --enable-languages=c,c++ --prefix=/usr/lib --infodir=/usr/share/info --ma=/usr/share/man --bindir=/usr/bin --libexecdir=/usr/lib --libdir=/usr/lib --enable-shared --with-system-zlib -ble-long-long --enable-nls --without-included-gettext --disable-libssp --build=arm-linux-gnueabihf --host=arm-x-gnueabihf --target=avr
Thread model: single
gcc version 4.7.0 (GCC) 
pi@raspberrypi ~ $ 
so the version of avr-gcc frrom the debian repositories seems to be 4.7.0, whereas the version packaged with arduino is 4.3.2. this will probably not be a problem unless someone tries to compile a bootloader. maybe not even then.

guess i'll try copying the avr binutils, gcc and libc into the arduino tree and then see if i can make a useable tarball. it will still be the wrong compiler version, but que sera, sera, eh?

there is a readme amongst the binaries that explains what was done.

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: arduino on a headless pi

Post by adafruit_support_rick »

i can now fire up a virtual network connection on any computer on my home network and start working on code on an arduino connected to my raspberry pi.
that's like, like genius! Now you need some sort of emulator or IDE running on the arduino. :lol:

Seriously - that's pretty cool. I'm going to have to try it myself. I've already lost count of the number of VMs, remote computers, and remote development targets I'm running with here, so what's one more?

User avatar
cyborg5
 
Posts: 71
Joined: Tue Apr 24, 2012 4:13 pm

Re: arduino on a headless pi

Post by cyborg5 »

I realize this is a very old thread I'm hoping you still have it monitored or subscribed or whatever…

In your examples of copying and renaming directories sometimes you spell "arduino" with a number zero where the final letter "o" should be. Is that a typo or is there some reason you don't want those files in the standard arduino folder?

tldr
 
Posts: 466
Joined: Thu Aug 30, 2012 1:34 am

Re: arduino on a headless pi

Post by tldr »

very peculiar. those were pretty clearly not the commands i used, because there are no files on my pi with names like that. think i'll change all occurrences of arduin0 in the original post to arduino and hope there's no further stupidity there.

thanks for pointing it out.

User avatar
churten
 
Posts: 12
Joined: Tue Jan 22, 2013 9:39 pm

Re: arduino on a headless pi

Post by churten »

For the lazy, the arduino IDE is also packaged for debian (including raspbian), so you can:

Code: Select all

sudo apt-get update
sudo apt-get install arduino
:)

User avatar
cyborg5
 
Posts: 71
Joined: Tue Apr 24, 2012 4:13 pm

Re: arduino on a headless pi

Post by cyborg5 »

I discovered that recently however it appears to only have version 1.0.1 available. If you want to upgrade to 1.0.4 you have to do it manually.

Locked
Forum rules
Talk about Adafruit Raspberry Pi® accessories! Please do not ask for Linux support, this is for Adafruit products only! For Raspberry Pi help please visit: http://www.raspberrypi.org/phpBB3/

Return to “Adafruit Raspberry Pi® accessories”