1. TinyOS Manual For Beginners in Linux
(Ubuntu)
Ankit Singh
FH Frankfurt am Main
February 10, 2011
2. Contents
1 TinyOS Installation Guide for Beginners 2
1.1 Procedure for Installation and configuring TinyOS . . . . . . 2
1.1.1 Installation of TinyOS (Source tinyos.net) . . . . . . . 2
1.1.2 Configuration of TinyOS . . . . . . . . . . . . . . . . . 3
1.1.3 Confirming the correct configuration of the Tinyos . . 4
1.1.4 Connecting Motes & pushing modules to Motes . . . . 4
1.1.5 Setting Up Environment for Mote Listener . . . . . . 6
1.2 Compiling and Pushing Sensor board specific Application . . 7
1.2.1 Compile Module . . . . . . . . . . . . . . . . . . . . . 7
1.2.2 To Push it to the Motes . . . . . . . . . . . . . . . . . 7
1.2.3 Running GUI in For Base Station . . . . . . . . . . . 7
1
3. Chapter 1
TinyOS Installation Guide
for Beginners
1.1 Procedure for Installation and configuring TinyOS
1.1.1 Installation of TinyOS (Source tinyos.net)
In Ubuntu operating system open following file:
System → Administration → Synaptic Package Manager
After Synaptic Package Manager get open goto:
Settings → Repositories → Other software → (Press) Add
After pressing Add button, Please enter the following line to add the tinyOS
repositories:
deb http://tinyos.stanford.edu/tinyos/dists/ubuntu <distribution> main
Distribution is the distribution name of the Ubuntu. If you do not know
the distribution name then please follow the steps to know your Ubuntu
Distribution:
Type the the folllowing command on your linux command line:
ankit@ubuntu:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 10.04.1
LTS Release: 10.04
Codename: lucid
You will get some output like the above. The Codename: lucid is my dis-
tribution name. So, Just use the name which shows to you.
2
4. After you inserted the above line in the add pop-up then press close. The
linux will ask your permission to update the repositories. Just close it and
it will automatically do it.
Now, there is a option called Quick Search: Please enter tinyos as search
key. You can see some result on it. Choose tinyos-2.1.1.
Then press Apply button in Synaptic Package Manager.
It will install tinyos for you.
1.1.2 Configuration of TinyOS
Open Terminal in Ubuntu
You need to source the tinyos.sh (shell script) in bashrc. Type the following
command:
ankit@ubuntu:~$ sudo gedit .bashrc
The .bashrc file will be open after hitting enter
Then copy & paste the following lines after the first syntax lines:
#Sourcing the tinyos environment variable setup script
source /opt/tinyos-2.1.1/tinyos.sh
After that, save & exit.
Change the owner ship of the tinyos directory
Change directory to: (use the following command)
ankit@ubuntu:~$cd /opt/
ankit@ubuntu:~$sudo Chown -R ankit:ankit tinyos-2.1.1/
Note: use your home folder name given before ’@’ sign - Add path to
tinyos.jar file in tinyos.sh
ankit@ubuntu:~$cd /opt/tinyos-2.1.1
ankit@ubuntu:/opt/tinyos-2.1.1$sudo gedit tinyos.sh
Add the following line just after the end of the CLASSPATH:
:$TOSROOT/support/sdk/java/tinyos.jar:.
The line should look like:
CLASSPATH=$CLASSPATH:$TOSROOT/support/sdk/java:
$TOSROOT/support/sdk/java/tinyos.jar:.
3
5. 1.1.3 Confirming the correct configuration of the Tinyos
Change directory to:
ankit@ubuntu:~$cd /opt/tinyos-2.1.1/apps/Blink
Type the make command for the module Blink
ankit@ubuntu:/opt/tinyos-2.1.1/apps/Blink$ make micaz
You should see the output like this:
mkdir -p build/micaz
compiling BlinkAppC to a micaz binary
ncc -o build/micaz/main.exe -Os -fnesc-separator=__ -Wall -Wshadow -Wnesc-all
-target=micaz -fnesc-cfile=build/micaz/app.c -board=micasb -DDEFINED_TOS_AM_GROUP=
0x22 --param max-inline-insns-single=100000 -DIDENT_APPNAME="BlinkAppC" -
DIDENT_USERNAME="ankit" -DIDENT_HOSTNAME="ubuntu" -
DIDENT_USERHASH=0x1bba31edL
-DIDENT_TIMESTAMP=0x4cec121eL -DIDENT_UIDHASH=0x92b330deL -fnesc- dump=wiring -
fnesc-dump=’interfaces(!abstract())’ -fnesc- dump=’referenced(interfacedefs,
components)’ -fnesc- dumpfile=build/micaz/wiring-check.xml BlinkAppC.nc -lm
compiled BlinkAppC to build/micaz/main.exe
2052 bytes in ROM
51 bytes in RAM
avr-objcopy --output-target=srec build/micaz/main.exe
build/micaz/main.srec avr-objcopy --output-target=ihex
build/micaz/main.exe build/micaz/main.ihex
writing TOS image
If you are able to see ’writing TOS’ image at end then you have successfully
configured the Tinyos.
1.1.4 Connecting Motes & pushing modules to Motes
Every time you connect a new mote to the serial-based programming board
, you have to again setup & configure the network address of the program-
ming board and system. So, to make life easy, I wrote a shell script.
All SHELL SCRIPTS tools can be found in MicazXpl project repositories.
Following are the shell script for configuring network
ankit@ubuntu:~$sudo gedit /bin/runMoteSetup.sh
#!/bin/sh
sudo ifconfig eth0 10.5.5.1
4
6. sudo arp -s 10.5.5.5 00204A13E829
netcat 10.5.5.5 1
netcat 10.5.5.5 9999
NOTE: 00204A13E829 is the MAC address of my serial-based programming
board. You need to put your own MAC address finding on the board.
This will save the shell script in /bin folder which will make this shell script
accessible from any folder or path. Don’t forget to make the shell script to
executable file by using the following command.
ankit@ubuntu:~$sudo chmod +x /bin/runMoteSetup.sh
ankit@ubuntu:~$ runMoteSetup.sh
??#??#
*** Lantronix Universal Device Server ***
Serial Number 1359433 MAC address 00204A13E829
Software version V5.8.0.1 (041112) LTX
Press Enter for Setup Mode
Now, The shell script to push the modules to the Motes:
ankit@ubuntu:~$sudo gedit /bin/pushToMotes.sh
#!/bin/sh
## For comiling Data And pushing it in the Mote
make micaz install eprb,10.5.5.5
For making the above shell script executable.
ankit@ubuntu:~$sudo chmod +x /bin/pushToMotes.sh
ankit@ubuntu:/opt/tinyos-2.1.1/apps/Blink$ pushToMotes.sh mkdir -p build/micaz
compiling BlinkAppC to a micaz binary ncc -o build/micaz/main.exe -Os
-fnesc-separator=__ -Wall -Wshadow -Wnesc-all -target=micaz -fnesc-cfile=
build/micaz/app.c -board=micasb -DDEFINED_TOS_AM_GROUP=0x22
--param max-inline-insns-single=100000 -DIDENT_APPNAME="BlinkAppC" -
DIDENT_USERNAME="ankit" -DIDENT_HOSTNAME="ubuntu" -
DIDENT_USERHASH=0x1bba31edL -DIDENT_TIMESTAMP=0x4ceef6c4L -
DIDENT_UIDHASH=0x44161342L -fnesc- dump=wiring -fnesc-dump=’interfaces(!abstract())’
fnesc- dump=’referenced(interfacedefs, components)’ -fnesc- dumpfile=build/
micaz/wiring-check.xml BlinkAppC.nc -lm
compiled BlinkAppC to build/micaz/main.exe
2052 bytes in ROM
51 bytes in RAM
5
7. avr-objcopy --output-target=srec build/micaz/main.exe
build/micaz/main.srec avr-objcopy --output-target=ihex build/micaz/main.exe
build/micaz/main.ihex
writing TOS image
cp build/micaz/main.srec build/micaz/main.srec.out
installing micaz binary using eprb uisp -dprog=stk500 -dhost=10.5.5.5
--wr_fuse_h=0xd9 -
dpart=ATmega128 --wr_fuse_e=ff --erase --upload if=build/micaz/main.srec.out
--verify Firmware Version: 1.7 Atmel AVR ATmega128 is found.
Uploading: flash
Verifying: flash
Fuse High Byte set to 0xd9
Fuse Extended Byte set to 0xff
rm -f build/micaz/main.exe.out build/micaz/main.srec.out
1.1.5 Setting Up Environment for Mote Listener
Mote Listner is used to read the data broadcasted by motes in the network
and saves to the output file. Following are the commands for listening:
java net.tinyos.tools.Listen -comm network@10.5.5.5:10002
It is supposed to be serial communication but in our case, we are us-
ing TCP/IP connection. That is why we are using ”network@IP:PORT” in
above command.
You can also go through the java source for getting more details on number
of options available for your type of connection to your PC:
ankit@ubuntu:/opt/tinyos-2.1.1/support/sdk/java/net/tinyos$
vim packet/BuildSource.java
You can export the MOTECOM for not always passing option -comm
export MOTECOM=network@10.5.5.5:10002
Then run java listner without -comm parameter
ankit@ubuntu:/opt/tinyos-2.1.1/apps/tests/TestSerial$
java net.tinyos.tools.Listen
6
8. 1.2 Compiling and Pushing Sensor board specific
Application
We are going to take example of Oscilloscope application given with TinyOS
package.
Application Path is :
/opt/tinyos-2.1.1/apps/Oscilloscope/
1.2.1 Compile Module
To Compile this Module, You need to provide Sensor board type. In our
Case its: mts300.
Type the following command on your linux console.
SENSORBOARD=mts300 make micaz
1.2.2 To Push it to the Motes
Type the following command on your linux console using your variables into
the syntax bracket.
make micaz reinstall eprb,<Node-ID> <IP-Adr>
Node-ID: Mote ID you want to set like Mode ID 1 or 2 or anything
IP-Adr: IP address of the Motes
1.2.3 Running GUI in For Base Station
Goto to Java folder of Oscilloscope:
/opt/tinyos-2.1.1/apps/Oscilloscope/java/
Setting Environment variable for motes communication:
export MOTECOM=network@10.5.5.5:10002
Then RUN the Java Application:
ankit@ubuntu:/opt/tinyos-2.1.1/apps/Oscilloscope-Mic/java$./run
Hope it will be helpful for you to get started!!! Thank You!!
7