Wednesday, March 6, 2013

Install tinyos on Raspberry Pi

sourcehttp://www.mail-archive.com/tinyos-help@millennium.berkeley.edu/msg43109.html
author:   Inglezakis Antonios



You have to install,the following packages from raspbian's repositories first (if they exist). |sudo apt-get install build-essential openjdk-6-jdk openjdk-6-jre python2.7 python2.7-dev automake avarice avr-libc msp430-libc avrdudebinutils-avr binutils-msp430 gcc-avr gcc-msp430 gdb-avr gdb-msp430 subversion graphviz python-docutils git checkinstall

For every needed package than does not exist in raspbian's repositories, you have to build and install it from source code!!!!


|After that, you have to download/clone tinyos source code repository from github
git clone https://github.com/tinyos/tinyos-main.git

Before the complilation of any example, you also need to install from source nesc compiler.
git clone https://github.com/tinyos/nesc.git

cd to nesc source code directory
./configure [--prefix=YOURPREFIXPATH]
make
make install ( or sudo checkinstall if YOURPREFIXPATH is in system directory)
example:

|mkdir -p $HOME/local/compilers
|

|./configure --prefix=$HOME/local/compilers
|

|make
|

|make install|

|export PATH=$HOME/local/compilers/bin:$PATH|


Then you have to build tinyos tools from source code:
|cd tinyos-main/tools
./Bootstrap
./configure --prefix=$HOME/local/tosTools
make all
make install  (or sudo checkinstall  if prefix dir is in system directory)|


After that, you need to set some enviroment variables, so that you can build any application
Create the file $HOME/local/tinyos-env.sh

   #!/bin/bash
   echo "Setting TinyOs 2 enviroment variables!"
   export PATH=$HOME/local/tosTools/bin:$PATH

   export PATH=$HOME/local/compilers/bin:$PATH
   export TOSROOT=$HOME/local/src/tinyos-2x
   export TOSDIR=$TOSROOT/tos
   export MAKERULES=$TOSROOT/support/make/Makerules
   export CLASSPATH=$TOSROOT/support/sdk/java/tinyos.jar:.
   export PYTHONPATH=.:$TOSROOT/support/sdk/python:$PYTHONPATH
   export PATH=$TOSROOT/support/sdk/c:$PATH|

Then make it executable:

   |chmod +x $HOME/local/tinyos-env.sh|


and make it to be loaded on every terminal start, for your user. Just add the following lines to the $????/.bashrc file.
   |# TinyOS enviroment variables
   |

   |source $HOME/local/tinyos-env.sh|


Raspberry Pi is an ARM based platform, so every precompiled package for i386 or amd64 architecture fails to be installed.
Have a nice day!

Inglezakis Antonios

Monday, March 4, 2013

Enforce software ACK on CC2420 tinyos

cc2420/receive/CC2420ReceiveP.nc:


      /*
       * The destination address check here is not completely optimized. If you
       * are seeing issues with dropped acknowledgements, try removing
       * the address check and decreasing SACK_HEADER_LENGTH to 2.
       * The length byte and the FCF byte are the only two bytes required
       * to know that the packet is valid and requested an ack.  The destination
       * address is useful when we want to sniff packets from other transmitters
       * while acknowledging packets that were destined for our local address.
       */
     //--if(call CC2420Config.isAutoAckEnabled() && !call CC2420Config.isHwAutoAckDefault()) {
      if( !call CC2420Config.isHwAutoAckDefault()) {
      //--if (1) {
        //--if (((( header->fcf >> IEEE154_FCF_ACK_REQ ) & 0x01) == 1)
        if ( 1
            && ((header->dest == call CC2420Config.getShortAddr())
                || (header->dest == AM_BROADCAST_ADDR))
            && ((( header->fcf >> IEEE154_FCF_FRAME_TYPE ) & 7) == IEEE154_TYPE_DATA)) {
          // CSn flippage cuts off our FIFO; SACK and begin reading again







      // We may have received an ack that should be processed by Transmit
      // buf[rxFrameLength] >> 7 checks the CRC
      //--if ( ( buf[ rxFrameLength ] >> 7 ) && rx_buf ) {
      if ( rx_buf ) {



cc2420/transmit/CC2420TransmitP.nc:


      case S_EFD:
        sfdHigh = FALSE;
        call CaptureSFD.captureRisingEdge();
       
        //--if ( (call CC2420PacketBody.getHeader( m_msg ))->fcf & ( 1 << IEEE154_FCF_ACK_REQ ) ) {
        if ( 1 ) {