User Tools

Site Tools


tinyos_nwprog

~~REDIRECT>ref:tinyos:nwprog:start~~

Over The Air Programming With Blip

TinyOS sports a tool called Deluge for handling network wide reprogramming of motes using the radio. Certain core components of this tool have been adapted for use in a Blip network. In Blip it's called NWProg.

Using NWProg

The basic flow of using NWProg is this:

  • Compile a Blip application with NWProg
  • Compile TOSBoot
  • Program the nodes with TOSBoot + your application
  • Load the app binary you want to reprogram to using a python script
  • Use the Blip shell to tell the node to reprogram and reprogram

Install NWProg

Quick start: Add this to the Makefile of the TinyOS app:

BOOTLOADER=tosboot

And create a file in the app directory for the flash chip you are using. With epic this called volumes-at45db.xml and contains:

<volume_table>
  <volume name="GOLDENIMAGE" size="65536" base="0" />
  <volume name="DELUGE1" size="65536"/>
  <volume name="DELUGE2" size="65536"/>
  <volume name="DELUGE3" size="65536"/>
</volume_table>

You also need to compile tosboot:

$ cd $TOSROOT/tos/lib/tosboot
$ make epic

Install the app like normal

$ make epic blip install bsl,/dev/ttyUSB0

You should see it do two installations, one for TOSBoot and one for your app.

Load an App Binary to the Node

Use the python script tos-nwprog located in tools/tinyos/misc.

$ make epic blip
$ cd build/epic
$ tos-nwprog -u <image number> -f tos_image.xml <ip address>

Tell the Node To Switch Programs

$ nc6 -u <ip address> 2000
nwprog list
nwprog boot <image number> <millisecond delay until reprogramming>

Using a Different Platform

Things get more complicated if you have defined a new TinyOS platform for the board you are using. There are many places in the NWProg/Deluge/TOSBoot stack where there are custom defined settings for all of the given supported platforms. For some reason the platform specifics are not in tos/platforms but in each library folder.

  • Set up support/sdk/make/tosboot.extra for your platform.
  • Set up tos/lib/net/Deluge/extra for your platform.

Dealing with Large Code Sizes

Using Blip2 + RPL + NWProg creates rather large application binaries. I found these to be too large to allow me to run an actually interesting application on top of the networking stack. To work around this I came up with the following solution:

NWProgLite

NWProgLite is similar to NWProg in Blip except all it allows you to do is restart the app and flash into the golden image. This way you can compile your application with NWProgLite and only add 500 bytes to the code size (4KB if you do not have the shell included already).

To make any Blip enabled app compatible compile with:

$ make epic blip nwproglite

BlipNWProgBase

This TinyOS app is basically the simplest app possible that includes Blip, RPL, and NWProg. It doesn't do anything except become a node in the network. When the node is running this app, it can flash either of the flash partitions with a new image. Then, you can boot into the new application.

Procedure

  1. Install BlipNWProgBase on all the nodes in the network.
  2. Use tos-nwprog to load BlipNWProgBase into volume 0 on every node
  3. Use tow-nwprog to load whatever nwproglite compiled app you want into volume 1 of every node
  4. To run your desired app:
    $ nc6 -u <ipaddress> 2000
    nwprog boot 1

To load a different app:

  1. First switch back to the BlipNWProgBase app
    $ nc6 -u <ip address> 2000
    nwprog reset
  2. Use tos-nwprog to load a new application to volume 1
  3. Switch to the new app
    $ nc6 -u <ipaddress> 2000
    nwprog boot 1

Programming Initial Images in Flash

In order to do the large code size trick, BlipNWProgBase needs to be in volume 0. Getting it there can be a pain using over the air programing. To avoid this, we can use some Deluge machinery to program the volumes while they are connected locally.

  1. Install apps/tests/deluge/basestation
  2. Use the Deluge script to load images
  3. Install BlipNWProgBase
$ cd $TOSROOT/apps/tests/deluge/basestation
$ make hemera install bsl,/dev/ttyUSB0
$ cd $TOSROOT/apps/BlipNWProgBase
$ tos-deluge serial@/dev/ttyUSB0:115200 -i 0 build/hemera/tos_image.xml
$ make hemera blip install bsl,/dev/ttyUSB0

It should be noted that I attempted to merge the serial connection loading functionality of the Deluge basestation with BlipNWProgBase, but I couldn't get it to fit on an MSP430F1611.

Flashing Only the Diff

To reduce the amount of data that needs to be transferred over the network, I'm working on a method that only transmits blocks that are different from the current stored block.

This works by asking for hashes of 32 64-byte blocks. Then the local script only sends the blocks that are different. Repeat.

Notes

Using an App Without NWProg Included

It is possible to load an image of an app that does not have NWProg included (something like Blink). The procedure is the same with one change: you must specify where the app should reside in flash manually since tosboot.extra will not automatically do it. To do this, add this line to the application makefile.

CFLAGS += -Wl,--section-start=.text=0x4a00

Mote Won't Reboot into Other Image

Make sure that the code was set to the correct address, see note above.

NWProg/Deluge Error Prevention

After every chuck of data sent by tos-nwprog, the node sends back 6 bytes confirming it was able to store the data.

tinyos_nwprog.txt · Last modified: 2013/02/10 01:10 by bradjc