Enviroment State:

XP, Quartus II 7.2 with SP1, Nios II 7.2 with SP1, MegaCore IP 7.2, Tinyos Toolchain

Step 1: Install Java 1.5 JDK

Windows Download and install Sun’s 1.5 JDK from http://java.sun.com.

Linux Download and install IBM’s 1.5 JDK from http://www-128.ibm.com/developerworks/java/jdk/.


Step 2: Install Cygwin Related Packages

  1. Check the version of Cygwin by using cygcheck -c, the newest version of Cygwin for SOPC Builder 7.2 should be 1.5.24-2, if older than this please patch it.
  2. Download the confirmed-compatible cygwin packages from the tinyos web site here .
  3. In a cygwin shell, unzip the above package into some directory. In these instructions the directory is /cygdrive/c/newcygpkgs.
         $ cd /cygdrive/c/newcygpkgs
    $ tar zxvf cygwin-1.2a.tgz

    This unzips the packages.

  4. In Windows Explorer, navigate to /cygdrive/c/newcygpkgs and click on the file setup.exe. Setup.exe is the setup program distributed by Cygnus Solutions.
  5. Follow these steps when the Cygwin Setup windows appears:
  6. Opt to disable the virus scanner (it will be enabled when you’re finished).
  7. Opt to Install from Local Directory.
  8. Specify the Root directory to be where your current cygwin installation is. This would be the directory that directories like ‘opt’ and ‘usr’ are in. For example, mine is rooted at c:\tinyos\cygwin, so I enter that.
  9. Select to Install for All Users
  10. Select the Unix file type (very important!)
  11. For the Local Packages Directory, specify where you unzipped the cygwin packages tarfile. For example, I would specify c:\newcygpkgs. (The setup.exe program will probably select the right default directory.)
  12. The next window will allow you to select packages to install. You should see that most of the packages have an X-ed box next to them; these are the packages that are to be installed.
  13. Click install.

Some notes:

  • You might see a message explaining that you need to reboot because some files are in use. This most likely means that your cygwin DLL is loaded and in-use and, therefore, cannot be replaced. When you reboot, the new DLL will be loaded.
  • Related to the above warnings, if you see warnings about the cygwin1.dll not being found, don’t worry. All will be well once you reboot and the right DLL is loaded.

Step 3: Install native compilers

Not so sure what else should it be installed, cauz we build tinyos toolchain on Nios II. Just wait and see.

To test whether tinyos environment could work or not, I install TI MSP430 Tools on the NIOS SOPC Builder after step 5.

Install the appropriate version of the following (Windows or Linux, avr or msp430 or both) with the rpm command ‘rpm -ivh rpm>‘. On windows, if you get an error claiming that the rpm was build for an NT computer and you’re on a windows NT computer, bypass the erroneous error by using ‘rpm -ivh –ignoreos rpmname‘. (We have xscale compiler tools online at http://www.tinyos.net/dist-1.2.0/tools/ but they have not yet been extensively tested by a large community.)

TI MSP430 Tools



python tools




Not yet available

Not yet available

Step 4: Install TinyOS toolchain

The TinyOS-specific tools are the NesC compiler and a set of tools developed in the tinyos-2.x/tools source code repository. They are also installed using rpms. If you using the Cygwin version recommended in these install instructions, you should install the "Recommended" Windows/Cygwin nesC RPM. If you get strange errors when you try to compile TinyOS programs, such as the error message "the procedure entry point basename could not be located in the dynamic link library cygwin1.dll", this is likely due to a Cygwin version incompatibility: try the "Other" Windows/Cygwin RPM (1.2.7a). If you are using Cygwin and installing the nesC RPM causes an error that the RPM was built for Cygwin, add the --ignoreos option.

TinyOS-specific Tools

Tool : NesC
Recommended Windows/Cygwin
nesc-1.2.8a-1.cygwin.i386.rpmOther Windows/Cygwin


rpm -Uvh
rpm -Uvh --ignoreos (if Cygwin complains)

Tool: tinyos-tools
rpm -ivh --force (1.x tree)
rpm -Uvh (no 1.x tree)

Note: After installing nesc-1.2.8a-1.cygwin.i386.rpm successfully, when try to install tinyos-tools-1.2.4-2.cygwin.i386.rpm, error encountered:

error: Failed dependencies:

          nesc >= 1.2.7 is needed by tinyos-tools-1.2.4-2

Just using rpm -Uvh –nodeps tinyos-tools-1.2.4-2.cygwin.i386.rpm, but not sure whether could work normally.

To double guarente, install nesc-1.2.8b-1.cygwin.i386.rpm instead, then execute rpm -Uvh tinyos-tools-1.2.4-2.cygwin.i386.rpm, done!

In another installation, execute: rpm -Uvh –nodeps tinyos-tools-1.2.4-2.cygwin.i386.rpm , sth wrong again, but could ignore first.

[SOPC Builder]$ rpm -Uvh –ignoreos tinyos-tools-1.2.4-2.cygwin.i386.rpm
Preparing…                ########################################### [100%]
   1:tinyos-tools           ########################################### [100%]
/var/tmp/rpm-tmp.81844: ./giveio-install: permission denied
Installing Java JNI code in /cygdrive/c/Program Files/Java/jdk1.5.0_13/jre/bin .

In another installation, this error doesn’t appear.

Step 5: Install the TinyOS 2.x source tree

Now that the tools are installed, you need only install the tinyos 2.x source tree and then set your environment variables. Install the appropriate version of the following (Window or Linux) with the rpm command ‘rpm -ivh rpm‘. As with the previous rpms, if you get an error claiming that the rpm was built for an NT computer and you’re on a windows NT computer, bypass the erroneous error by using ‘rpm -ivh –ignoreos rpmname‘.

Note: The same prolem encountered, the error of this time is

error: Failed dependencies:

          tinyos-tools >= 1.2.4 is needed by tinyos-2.0.2-2

Execute rpm -Uvh –nodeps tinyos-2.0.2-2.cygwin.noarch.rpm, and ignore the dependency.


Note: Could not find /opt/tinyos-2.x in Cygwin, is it because of access right???, stopped!!

When add –ignoreos parameter, these errors would not appear any more.

  • Pending & Try another way: Installing uClinux on it first to see their solutions to build cross-tools on Nios II. —–It turns out that errors also exist in uClinux, anyway, since I have figured out part of the problems installing TinyOS in SOPC Builder, let me continue the above work.
  • Configure your environment

    Ideally, you’ll put these environment variables in a shell script that will run when your shell starts, but you needn’t put such a script under /etc/profile.d.

    The example settings below assume that the tinyos-2.x installation is in /opt/tinyos-2.x. Change the settings to be correct for where you’ve put your tinyos-2.x tree. Note that the windows CLASSPATH must be a windows-style path, not a cygwin path. You can generate a windows style path from a cygwin-style path using ‘cygpath -w’. For example:

    export CLASSPATH=`cygpath -w $TOSROOT/support/sdk/java/tinyos.jar`

    TinyOS 2.x

    Environment Variable




    †Only necessary if you’re using the MSP430 platform/tools.

    I added the scripts into Altera\72\nios2eds\nios2_sdk_shell_bashrc

# Added By Neil For TinyOS 2.x Environment
export TOSROOT=/opt/tinyos-2.x
export TOSDIR=$TOSROOT/tos
export CLASSPATH=`cygpath -w $TOSROOT/support/sdk/java/tinyos.jar`
export MAKERULES=$TOSROOT/support/make/Makerules
export PATH=/opt/msp430/bin:$PATH
echo ————————————————
echo TinyOS Toolchain Configured
echo ————————————————

Note: There’s no space between ‘=’.

  • Finally, if you have installed TinyOS 2.0.1, there is a bug in TOSSIM (which will be fixed in 2.0.2). The bug is in file tos/chips/atm128/sim/atm128_sim.h. Change these lines 22 and 23 from:

    #define _SFR_IO8(io_addr) _MMIO_BYTE((io_addr) + 0x20)
    #define _SFR_IO16(io_addr) _MMIO_WORD((io_addr) + 0x20)


    #define _SFR_IO8(io_addr) _MMIO_BYTE((io_addr))
    #define _SFR_IO16(io_addr) _MMIO_WORD((io_addr))

    If you do not do this, then timers will not work correctly.

Step 6: Installing Graphviz

Go to download page of the Graphviz project and download the appropriate RPM. You only need the basic graphviz RPM (graphviz-); you don’t need all of the add-ons, such as -devel, -doc, -perl, etc. If you’re not sure what version of Linux you’re running,

uname -a

might give you some useful information. Install the rpm with rpm -i rpm-name. In the case of Windows, there is a simple install program, so you don’t need to deal with RPMs.

Note: Actually I don’t know what’s this for, since they suggest me to install, just do it;).


That’s all, I will write another article related with how to test this environment soon. Please wait and see^_^



1. Installing TinyOS 2.0.2

2. Cygwin User’s Guide