Deploying Contiki-NG Firmware on Zolertia Re-Motes on Wilab 1

In this tutorial you will learn how you can use the Zolertia motes which are available on the imec w-iLab.t 1 testbed, by building and flashing a CoAP-server firmware from the Contiki-NG framework on the server.

1. Design of the experiment

In this tutorial we will reserve and provision one node on the w-iLab.t 1 testbed which has two Zolertia Re-Mote attached to it. We will flash one of the sensors with a CoAP-server which can be accessed over the 802.15.4-interface. To be able to query the sensor over this network, we will flash the second sensor with border router-firmware. This allows us to connect via serial over USB to the 802.15.4-network, where we can then query all available sensors as normal IPv6-enabled devices.

To validate our setup, we will then run a CoAP-client to query the resources which are exposed by the CoAP-server firmware. For this we will use the Californium CoAP-client

2. Establish the Environment

To run this exercise, you will need an account and a piece of software:

3. Obtain resources

As the w-iLab.t 1 testbed resources are in high demand, you need to reserve the resources you want for a specific timeslot. For this follow the guide on getting started on w-iLab.t 1. Reserve one of the nodes on the ‘Datacenter’-floor, as they all have two Zolertia Re-Mote’s connected.

Once your timeslot has begun, you can use jFed to provision your node which you reserved earlier on. For this, we prepared an ESpec wilab1-coap.tar.gz which contains:

  • an RSpec for reserving one w-iLab.t 1 node

  • Installation script for Ansible

  • Ansible scripts for:

    • installing the compiler
    • downloading the Contiki-NG source code
    • executing the compile and flash make commands for both sensors
    • configuring the system as an IPv6-router
    • setting up the Californium CoAP-client
  • scripts for starting the border router

After downloading and unpacking the ESpec, open the iot.rspec-file, and change the component_id of the sensor-node to the URN of the node you reserved (ex. urn:publicid:IDN+wilab1.ilabt.iminds.be+node+nuc0-10) .

You can now start jFed, and launch the ESpec with the Open ESpec-button. Browse to the folder where you unpacked the ESpec, choose an unique experiment name and a suitable duration, and start the experiment.

While the resources are provisioned, feel free to have a look around in the various files in the ESpec-folder to discover how everything is structured

4. Running the experiment

Once the nodes have been provisioned, and all Ansible scripts have finished running, we can check if we can access the resources on the CoAP-server on the Zolertia ReMote.

Open an SSH-terminal by double-clicking on the sensor-node in the jFed topology viewer. Then execute the following commands:

$ cd /opt
$ sudo /opt/border.sh

The border.sh script does the following:

  1. Power cycle the nodes via the Yepkit USB hub;
  2. Start the tunslip6 process, which establishes a tunnel to the 802.15.4 network over the USB-connection to the border router. We specify the IPv6-subnet (cccc::/64) on which the nodes of the sensor network should be made available;
  3. Query the web-interface of the ‘border-router’-sensor to discover the neighbours available on the 802.15.4-network;
  4. Extract the CoAP-server sensor IPv6-address from the neighbours list.

Once this IPv6-address has been found, in our examples cccc::212:4b00:9df:5419, we can discover which CoAP-resources are available with:

$ cd /opt
$ java -jar cf-client-1.0.0-M3.jar DISCOVER coap://[cccc::212:4b00:9df:5419]

This should then result in output like:

==[ CoAP Response ]============================================
MID    : 59747
Token  : b8fc1d62
Type   : ACK
Status : 2.05
Options: {"Content-Format":"application/link-format", "Block2":98}
Payload: 404 Bytes
---------------------------------------------------------------
</.well-known/core>;ct=40,</test/hello>;title="Hello world: ?len=0..";rt="Text",</debug/mirro
r>;title="Returns your decoded message";rt="Debug",</test/chunks>;title="Blockwise demo";rt="
Data",</test/separate>;title="Separate demo",</test/push>;title="Periodic demo";obs,</sensors
/button>;title="Event demo";obs,</test/sub>;title="Sub-resource demo",</test/b1sepb2>;title="
Block1 + Separate + Block2 demo"
===============================================================
Time elapsed (ms): 0

Discovered resources:
</.well-known/core>;ct=40,</test/hello>;title="Hello world: ?len=0..";rt="Text",</debug/mirro
r>;title="Returns your decoded message";rt="Debug",</test/chunks>;title="Blockwise demo";rt="
Data",</test/separate>;title="Separate demo",</test/push>;title="Periodic demo";obs,</sensors
/button>;title="Event demo";obs,</test/sub>;title="Sub-resource demo",</test/b1sepb2>;title="
Block1 + Separate + Block2 demo"

We can also run a full plugtest with the Californium Plugtest Client:

$ java -jar cf-plugtest-client-1.0.0-M2.jar coap://[cccc::212:4b00:9df:5419]

This Plugtest client will then try to perform a whole list of actions to verify that the server implements all functions defined in the CoAP Plugtests interoperability guide.

Modifying the Contiki-NG firmware

To modify the resources that are exposed on the CoAP-server, go to /opt/contiki-ng/examples/coap/coap-example-server, and make the necessary changes to the file coap-example-server.c and related files in the resources-directory.

After making changes, you can compile and flash the firmware with the following command:

$  make TARGET=zoul BOARD=remote-revb NODE_ID=9 MOTES=/dev/ttyUSB1 coap-example-server.upload

5. Going further

The Contiki-NG project offers a lot of other example firmwares, which you can discover in the /opt/contiki-ng/examples-folder.

Sources

This tutorial was adapted from the FGRE Contiki tutorial on w-iLab.t testbed, which uses the resources available on w-iLab.t 2, and the outdated firmware from the Contiki (not-NG) project.