Loading...

Arduino Software Under FreeBSD

This is my first go at getting Arduino software running under FreeBSD 6.1.

FreeBSD is a UNIX-like operating system that's very customizable. It'll work on almost any hardware, and it's up to you how to use it. So FreeBSD and a microcontroller seem like a pretty good match.

First a word about how software installation works on FreeBSD. To install software on FreeBSD, you have three main options:

  1. Using The Ports System
  2. Using Packages
  3. Just downloading source code, extracting and compiling, like you would in Linux.

To help keep things neat and clean on the machine, I'm going to be using the ports system as much as possible.

For more information on general software installation on FreeBSD, see the (excellent) documentation at http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/

As with the other Unix like systems, you'll need to decide whether you want to install the complete Arduino software (runs under Java), or to run command line tools only.

My plan is to try both and sort of see what happens.

Java installation: I'm told that the arduino software requires Java. Java and FreeBSD have some weird relationships with one another, but it's totally possible to get Java running on FreeBSD, nonetheless.

Googling for "freebsd Java," I found out there are several ports and packages for Java on FreeBSD. The only one that worked for me was the one at http://www.freebsdfoundation.org/downloads/java.shtml

You will need to download these files manually because of some weird Sun licensing mumbo jumbo.

The files you need depend on which version of FreeBSD you're using. The one that worked for me was the one ending in "b01" that was for my version of the operating system (6.1).

Just download the file from the site, put it in /usr/ports/distfiles, then head on over to /usr/ports/java/diablo-jdk-1.5

Next, type make install at the prompt, and you should be well on your way.

The port might tell you to download some patches from a different site, if so, go ahead and follow the instructions, placing the patch files in /usr/ports/distfiles, and type make install again from /usr/ports/java/diablo-jdk-1.5.

The command prompt will perk along a while. If you have experience compiling software, or with the ports system on FreeBSD, this all will look familiar.

To get the JRE working on Firefox (which is the browser I use on FreeBSD), I followed the instructions at this page http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/desktop-browsers.html.

I have a feeling we'll need the ports at /usr/ports/devel/avr-gcc, and /usr/ports/devel/avr-libc, and /usr/ports/devel/avrdude, /usr/ports/comms/rxtx, and /usr/ports/java/jikes so let's install each one by cd'ing into the right directories, and doing a make install (or make install clean, if you prefer) from each one.

Next, just like the Linux folks, we'll need to provide the software the right path to find the Java junk we've installed. To do so, set the CLASSPATH and AVR environment variables. In my case it was like: export CLASSPATH=/usr/local/diablo-jdk1.5.0/bin:/usr/local/diablo-jdk1.5.0/jre/lib/rt.jar export DIRAVR=/usr/local/avr

you can double check your work by doing echo $CLASSPATH or echo $DIRAVR on the command line.

To retain these settings after you reboot, you'll want to set them somewhere handy, I'm thinking in the shell rc file (/home/yourlogonname/.bashrc or /home/yourlogonname/.zshrc or same thing in root, depending on how you're logging on.)

Well, folks, that's as far as I've gotten so far.

Oh, and another thing; you should be able to get away with installing the Java runtime edition (JRE) instead of the SDK.

I'll check back in after the other ports install, and as I get the source downloaded from the Arduino site.

edit: OK I'm checking back, and I've hit trouble. the make.sh script throws several errors, one of which caused the whole script to die (i.e. that examples.zip wasn't found.) not sure why it's looking for that - there is no examples.zip in the sourcefiles I have.

So I figured maybe that was normal behavior. After getting rid of examples.zip from make.sh, now it seems to run.

So next, I try run.sh, but no luck so far. It looks like the CLASSPATH is being set by the arduino shellscript (what run.sh is running). I tried setting classpath manually, then running what the "arduino" shellscript (in the "work" subdirectory) runs. It looks like I have to set all paths manually in the "arduino" shellscript. It's unclear from the shellscript comments where processing.app.Base is, and how the shellscript's supposed to be finding it, and what it's doing next. Arg, all this Java class junk is giving me brain-aches.

I found some more info from this site: http://processing.org/discourse/yabb/YaBB.cgi?board=general;action=display;num=1042496741

There's also this http://processing.org/discourse/yabb_beta/YaBB.cgi?board=Integrate;action=display;num=1155112507

In the meantime, here's a quick description of the stuff you've installed so far:

namedescrcategory
avrdudeAVR Downloader/UploaDEr - is a program for updating the flash, eeprom, and fuse bit memories of Atmel AVR microcontrollersArduino
avr-gccgcc-4.x for Atmel AVR cross-developmentArduino
avr-libca C and math library for the Atmel AVR controller familyArduino
diablo java sdk (or jre)permits running java apps on FreeBSD.Java
jikesa java source to byte-code compilerJava
subversionlets you get the sourcecode using the fetch.sh scriptGeneral

Scott (scuppers)(at)(hotmail)(dot)(com)


I would like to add my ten cents' worth, based on my own experiences using FreeBSD 7.3 and 8.1 and the Arduino Uno.

With the Uno it has an additional ATMel 8u2 microcontroller doing the USB in lieu of an FTDI chip. As such, it more closely follows the ACM spec (normally used by USB modems) but is not compatible with any of FreeBSD's drivers. Fortunately I have written one that appears to work properly (to be added to 'ports' when I am done testing it).

A link to a web site with the driver and information is here: http://mrp3.com/uarduno.html

There are also some other issues that I ran into, particularly with the rxtx library and the 'avrdude' application. In particular, the shared libraries for the supplied 'avrdude' application are missing. I looked everywhere for the source, and discovered what modifications had been done to it, and made a set of patch files (also on the same web site) that work with the latest version of avrdude and the Arduino Uno. I do not know if it affects programming other AVR platforms. This may need to be looked into a bit more. It has to do with the way the Uno's boot loader responds to an ID request, hence the need for a patch.

The best news is that I was able to build the 0021 environment (required for the Uno) using the unmodified Linux source, and with a little creative hacking I duplicated what the devel/arduino port does when it sets up the environment, and got it all to work. I also contacted the port maintainer for devel/arduino regarding the issues I had and discovered that he is already in the process of updating the port to the latest version (so that part should be forthcoming).

By making appropriate changes to the comms/rxtx and devel/avrdude ports, using the latest IDE (version 0021), and my 'uarduno' kernel driver, I have been happily working with the Arduino Uno, using FreeBSD 7.3 and 8.1 .

Hopefully the web page (mentioned above) clears up any issues regarding what the changes are and how they need to be applied to get the Uno to work with FreeBSD.

bobf at mrp3 dot com