Monday, April 11, 2016

Hands-on RIOT OS

RIOT is an operating system for low-powered resource constrained wireless devices which are mostly used in IoT applications. Since I have experiences only on TinyOS and Contiki so far, I decided to tryout RIOT OS to see it's capabilities. It is important to note that unlike most of other operating systems for IoT applications where event-driven model is used, RIOT is a microkernel based OS with truely real-time process scheduling capability. So, I guess it will be more interesting to write applications for RIOT though I need more time to understand the basics.

RIOT OS source code can be downloaded from their Github page as follows.

git clone

Compiling to native platform:

There are some example applications available to try inside RIOT source code which you can find inside the "examples" directory. Let's try the "default" application first. Like in Contiki, we can compile this RIOT application to native platform enabling us to run it on Linux. We can easily do that as follows.

cd RIOT/examples/default

Now, run this compiled elf executable using the following command,

sudo ./bin/native/default.elf tap0 -c /dev/ttyS0 -c /dev/ttyS1

When running this application, we get a small shell program on which we can type simple commands and interact with the RIOT program. Type "help" on this shell prompt to see the available commands. To exit from this program, we have to give Ctrl+C on the prompt. To clean the compiled files from the directory space, we can use the following command later.

make BOARD=native clean

Compiling and running on real telosb platform:

Now, let's try compiling RIOT OS to some other real wireless sensor mote platform. I selected "telosb" platform since we have Tmote Sky modules in our lab which are equivalent to telosb platform. Following command can be used to compile RIOT to telosb platform.

cd RIOT/examples/default
make BOARD=telosb

Now, plug-in a telosb mote into a USB port of the computer and properly give permission to access it using chmod command. For example, if the mote is mounted to /dev/ttyUSB0, following command will provide permission to access it.

sudo chmod 777 /dev/ttyUSB0

We can use a single command to compile RIOT OS and write it into the flash memory of the plugged-in telosb mote as follows.

make BOARD=telosb PORT=/dev/ttyUSB0 flash

It will take a little time to write to the flash memory of the mote. Finally, if we want to clean up the temporary files generated during the compilation time, we can use the following command.

make BOARD=telosb clean

Compiling and running on Cooja simulator:

Another possibility of trying RIOT programs is available for us. That is compiling RIOT progam into some real mote platform and running the executable on Cooja sensor network simulator which usually comes with Contiki OS. Let's try that now. First, we have to compile our program to a specific sensor mote platform. I will use telosb platform as usual.

cd RIOT/examples/default
make clean all BOARD=telosb

Now rename the elf file default.elf to to be able to use in Cooja since Cooja simulator expects an executable that it is supposed to run on Cooja to be save with .sky extention. Then, this executable is ready to run on Cooja. I had Cooja on my InstantContiki VM so, I started the VM and then started the Cooja simulator inside it using "ant run" command. Copy the file into the instant contiki filesystem. Now create a new simulation and a sky mote type and for the firmware, browse and give the firmware. Running the simulation should print the RIOT OS output on the mote output log.



No comments:

Post a Comment