Installing TinyOS from Source on Fedora 13 64bit

From TinyOS Wiki
Jump to: navigation, search

TO DO: Format, Create links & add text.

NOTE: Fedora does not add the default user to the /etc/sudoers file by default. Therefore one has to this before copy & pasting the commands, or replace every "sudo" with "su -c "<command>" ".

If you want to develop on a fresh installed Fedora, you need to first install the standard delevopment tools, since they are not part of every Fedora release:

  sudo yum install wget gcc gcc-c++ cvs svn git automake python-devel vim

Additional tools TinyOS uses:

  sudo yum install graphviz flex bison perl msp430-gcc

The rest is not in the Fedora repos, so here begins the odyssey.

Install Sun's Java Platform

In Fedora 13 OpenJDK is the preinstalled java version. Since I'm not sure if it works with TinyOS,

   This works for me, oscilloscope java application as an example
   First install OpenJDK development package; search for 'openjdk-devel'
   This should make it recognizable by '$TOSROOT/tools/tinyos/misc/tos-locate-jre'
       > $TOSROOT/tools/tinyos/misc/tos-locate-jre --javac
       /usr/lib/jvm/java-1.6.0-openjdk.x86_64/bin
   So far so good... --RogerL 09:10, 20 July 2010 (EDT) / Updated 20 Oct

I replaced it with the "official" closed source version. Therefore I removed OpenJDK (sudo yum remove java-1.6.0-openjdk) and installed Sun's (Oracle's) Java Platform (JDK):
Go to http://java.sun.com/javase/downloads/index.jsp and download the JDK. you should chose "jdk-5u22-linux-x64-rpm.bin". The website will annoy you by asking you to register, but you can skip that and download without registration.
Make the file executeable and run it with root rights:

  chmod +x jdk-5u22-linux-x64-rpm.bin
  sudo ./jdk-5u22-linux-x64-rpm.bin

For some, to me unknown reason, the installer does not create the necessary environment variables nor does register the new java version with the system. So one has to do this by hand. First, I created the script "/etc/profile.d/custom.sh" with the following content:

  #Java Variables
  export JAVA_HOME=/usr/java/jdk1.5.0_22:/jre/bin
  1. Addition command
 mv jdk1.5.0_22 /usr/java

Then I ran the following commands as root user:

  export JAVA_HOME=/usr/java/jdk1.5.0_22
  export JAVA_ALTERNATIVE_PRIORITY=15022
  /usr/sbin/update-alternatives --install /usr/bin/java java $JAVA_HOME/bin/java $JAVA_ALTERNATIVE_PRIORITY
  /usr/sbin/update-alternatives --install /usr/bin/javadoc javadoc $JAVA_HOME/bin/javadoc $JAVA_ALTERNATIVE_PRIORITY
  /usr/sbin/update-alternatives --install /usr/bin/appletviewer appletviewer $JAVA_HOME/bin/appletviewer $JAVA_ALTERNATIVE_PRIORITY
  /usr/sbin/update-alternatives --install /usr/bin/javah javah $JAVA_HOME/bin/javah $JAVA_ALTERNATIVE_PRIORITY
  /usr/sbin/update-alternatives --install /usr/bin/javac javac $JAVA_HOME/bin/javac $JAVA_ALTERNATIVE_PRIORITY
  /usr/sbin/update-alternatives --install /usr/bin/jar jar $JAVA_HOME/bin/jar $JAVA_ALTERNATIVE_PRIORITY
  /usr/sbin/update-alternatives --auto java
  /usr/sbin/update-alternatives --auto javadoc
  /usr/sbin/update-alternatives --auto appletviewer
  /usr/sbin/update-alternatives --auto javah
  /usr/sbin/update-alternatives --auto javac
  /usr/sbin/update-alternatives --auto jar

The Sun JDK should now be installed. To verify this one can type:

  java -version

which should result in:

  java version "1.5.0_22"
  Java(TM) SE Runtime Environment (build 1.5.0_22-b06)
  Java HotSpot(TM) 64-Bit Server VM (build 17.0-b16, mixed mode)

or similar.

note:because tinyos don't work if install another java version

Install native compilers

I'm not sure if the versions in the Fedora repositories will work with the hardware, or if one needs modified version... for now I'm only simulating, so the repo versions will do.

  sudo yum install avr-binutils avr-gcc avr-libc avarice avr-gdb avrdude

Install TinyOS toolchain

NesCC compiler

For the NesC compiler there do exist various .rpms, but none in the official Fedora repositories, so I compiled from source.

  wget http://sourceforge.net/projects/nescc/files/nescc/v1.3.5/nesc-1.3.5.tar.gz/download
  tar -xvf nesc-1.3.5.tar.gz
  cd nesc-1.3.5/
  ./configure
  make
  sudo make install

Deputy compiler [Optional - Safe TinyOS]

This is also not in the repos, again compiled from source. Yet this program is written in Objective Caml, whose compiler also needs to be compiled from source, since there's no version in the repo's. *sigh*.
IMPORTANT: To compile deputy-1.1 one needs ocaml-3.09.0. I initially downloaded the latest version (ocaml-3.11.2), and deputy DID NOT COMPILE.

  wget http://caml.inria.fr/pub/distrib/ocaml-3.09/ocaml-3.09.0.tar.gz
  tar xvf ocaml-3.09.0.tar.gz
  cd ocaml-3.09.0/
  ./configure
  make world
  make opt
  sudo make install
  wget http://deputy.cs.berkeley.edu/deputy-1.1.tar.gz
  tar xfv deputy-1.1.tar.gz
  cd deputy-1.1
  ./configure
  make
  sudo make install

Install the TinyOS 2.x source tree

Originally I wanted to download the tarball from Sourceforge, but apparently they were just migrating to Google Code and both repos were disabled. So I checked out the cvs repo, which also has the advantage that I can be sure to have the very latest version.

  cd ~/opt/
  cvs -d:pserver:anonymous@tinyos.cvs.sourceforge.net:/cvsroot/tinyos login
  cvs -z3 -d:pserver:anonymous@tinyos.cvs.sourceforge.net:/cvsroot/tinyos co -P tinyos-2.x

Also, one has to set the TinyOS environement variables. So I added to /etc/profile.d/custom.sh the following lines:

  #Tiny OS Variables  
  export TOSROOT=~/opt/tinyos-2.x
  export TOSDIR=$TOSROOT/tos
  export CLASSPATH=$TOSROOT/support/sdk/java/tinyos.jar:.
  export MAKERULES=$TOSROOT/support/make/Makerules

Install tinyos-tools

Once you have the source tree correctly set up, you need to compile the tools which are included there as source.

  cd $TOSROOT/tools/
  ./Bootstrap
  cd platforms/mica/uisp;./bootstrap; cd $TOSROOT/tools/
  ./configure
  make
  sudo make install

The programs you just installed include:

  /usr/bin/mig
  /usr/bin/motelist
  /usr/bin/ncc
  /usr/bin/ncg                                                                                                                                                                         
  /usr/bin/nesdoc                                                                                                                                                                      
  /usr/bin/tinyos.py                                                                                                                                                                   
  /usr/bin/tos-bsl                                                                                                                                                                     
  /usr/bin/tos-build-deluge-image                                                                                                                                                      
  /usr/bin/tos-channelgen                                                                                                                                                              
  /usr/bin/tos-check-env                                                                                                                                                               
  /usr/bin/tos-deluge                                                                                                                                                                  
  /usr/bin/tos-ident-flags                                                                                                                                                             
  /usr/bin/tos-install-jni                                                                                                                                                             
  /usr/bin/tos-locate-jre                                                                                                                                                              
  /usr/bin/tos-mote-key                                                                                                                                                                
  /usr/bin/tos-mviz                                                                                                                                                                    
  /usr/bin/tos-serial-configure                                                                                                                                                        
  /usr/bin/tos-serial-debug                                                                                                                                                            
  /usr/bin/tos-set-symbols
  /usr/bin/tos-storage-at45db
  /usr/bin/tos-storage-stm25p
  /usr/bin/tos-write-image
  /usr/bin/uisp

Verification

Congrats, you're pretty much done! To verify everything installed correctly run

  tos-check-env

In my case I got 2 Warnings, because I have newer versions of the installed programs than the script checks for, but I hope this will not lead to problems. Even though in the case of the ocaml compiler, it just did...

[Optional] TOSSIM

Since by the time of the installation I did not have access to any actual hardware, I wanted to compile some example programs for TOSSIM, the TinyOS simulator. Typing

  cd $TOSROOT/apps/Blink
  make micaz sim

resulted in an error. Apparently make could not find the file "Python.h".

First you need to check that you have the package for python development installed i.e. python-devel

Still does not work?

If you are using a newer version of python than 2.5 you need to edit the file "$TOSROOT/support/make/sim.extra" Change line "PYTHON_VERSION=2.5" to "PYTHON_VERSION=2.6"

With this change you will compile and link against the same python version.

   Howto use TOSSIM, and more configuration help, see
   ./doc/html/tutorial/lesson11-200.html