This guide will go through how to properly install TinyOs on Ubuntu (most versions included). The installation requires some basic libraries before installing the compiler and other components. I only cover the flashing process for Mulle and no other platforms (some may work if you are lucky, I however have not tried and give no guarantee that it would work).
You may follow this tutorial to install TinyOs, or you may download the automatic python installer which will do it for you. It’s a bit experimental but I’ve tried it out a few times and it works great and requires almost no user interaction at all. You may download the automatic installer from the following link (it requires python 3+):
Build essentials and libraries needed
There are some libraries that are needed to compile and install TinyOS and all its dependencies. Firstly download the linux build essentials and some basic tools.
sudo apt-get install m4 autoconf libtool gawk bzip2 bison flex gettext texinfo zlib1g-dev build-essential libmpc-dev libmpfr-dev
Add TinyOS apt sources to /etc/apt/sources.list
One thing you also have to do before you are able to install TinyOs from apt is to add the apt source to /etc/apt/sources.list, you will need administrator access to do this.
TinyOS apt repository
deb http://tinyos.stanford.edu/tinyos/dists/ubuntu main
Supported distributions: karmic, lucid, hardy, edgy, feisty, gutsy, jaunty. If you are installing it on maverick is suggest using lucid as it should work without any troubles.
Next up is updating the apt cache by running:
sudo apt-get update
After your cache have been updated successfully with all the newest versions it’s time to try and install TinyOs. You can either search for TinyOs in apt or you can try it and install it directly. Notice that there are several different versions of TinyOs out there, I suggest getting the newest one if you don’t feel sure which version to use.
The following command will most likely give you a message telling you to choose among a couple of available versions. The version which is the newest one today (at the time of writing this article) is 2.1.1.
sudo apt-get install tinyos
To install the 2.1.1 version you may execute:
sudo apt-get install tinyos-2.1.1
Install binutils from gnu
Installing TinyOs is however not yet completed as you will need a compiler for the source code as this is not included when installing from the repository. There are several different versions for all following packages, and I suggest using the package versions given in the article below. Using any other package version may result in serious misbehavior of the compiled code (such as timers not working properly or at all, compile errors)
The first step in installing the compiler is to download binutils, as said above you may replace given version numbers of any package with the newest one. Binutils may be downloaded from gnu.org, and the compilation of binutils works as follows:
tar xjf binutils-2.19.1.tar.bz2 mkdir binutils-obj cd binutils-obj ../binutils-2.19.1/configure --target=m32c-elf make sudo make install cd ..
You should be able to execute the above commands with any errors, if some errors however occur you are probably missing some libraries for the compilation process. Any missing libraries could most probably be found in apt.
Compiling and installing GCC for tinyos
To compile tinyos you will need GCC (Gnu Compiler Collection) which you can download from nluug.nl. The most stable compiler at the time is 4.3.3 (this is due to optimization bugs etc. experienced in newer versions such as 4.5.1). You are welcome to try any other version, if one version gives you trouble it’s an easy task to just repeat the steps following with another version of gcc. I will however use 4.3.3 as this works perfectly for me.
wget ftp://ftp.nluug.nl/mirror/languages/gcc/releases/gcc-4.3.3/gcc-4.3.3.tar.bz2 wget ftp://ftp.nluug.nl/mirror/languages/gcc/releases/gcc-4.3.3/gcc-core-4.3.3.tar.bz2 wget ftp://sources.redhat.com/pub/newlib/newlib-1.17.0.tar.gz tar xjf gcc-4.3.3.tar.bz2 tar xjf gcc-core-4.3.3.tar.bz2 tar xzf newlib-1.17.0.tar.gz cd gcc-4.3.3 ln -s ../newlib-1.17.0/newlib ln -s ../newlib-1.17.0/libgloss cd .. mkdir gcc-obj cd gcc-obj ../gcc-4.3.3/configure --target=m32c-elf --with-newlib --enable-languages="c" make sudo make install cd ..
After compilation and installation of gcc you may check that the installed version is correct by running
If the version for some reason isn’t showing the one you were trying to install you may need to change the symbolic links to make is run properly. (tip: use “which m32c-elf-gcc” to find out where the binary is located, then change the link to this file to point to the correct version which also should be located in the same folder)
Installing simple flasher M16
To flash the micro controller you need to download sm16cf which is a python flasher. It may be located at sourceforge. Run the following command lines to download the 1.0.0 version and install it. You can also download the git repository to get the newest version as it most likely includes some small fixes to stability that have not yet been added to the downloadable tar file.
wget -O sm16cf-1.0.0-rc5.tar.bz2 http://sourceforge.net/projects/sm16cf/files/sm16cf/1.0.0-rc5/sm16cf-1.0.0-rc5.tar.bz2/download?use_mirror=sunet tar xjf sm16cf-1.0.0-rc5.tar.bz2 cd sm16cf-1.0.0-rc5 sudo python setup.py install
You need to add this to the .bashrc (~/.bashrc) to load tinyos upon initialization of the bash shell:
source /opt/tinyos-2.1.1/tinyos.sh export CLASSPATH=$TOSROOT/support/sdk/java/tinyos.jar:.
(You can also customize the tinyos.sh file which is located in /opt/tinyos-/)
Next you need to restart you terminal to make the changes active, just close down the terminal session and start it up again and you should see something like “Setting up for TinyOS 2.1.1″
This step is optional and only works for the Mulle platform!
I recommend downloading TinyDude from Sourceforge. TinyDude is a simple “shadow flasher” for tinyos. It allows for simpler and quicker flashing and is easy to use.