The Internet of Things (IoT) is used with heteregenous devices, which range from 8-bit to 32-bit microcontrollers from different manufacturers. Traditional operating systems or the conventional embedded OSs may not suit the requirements that these tiny devices demand (low power, a small size and low memory footprint). The RIOT operating system is a free and open source architecture that is friendly to IoT applications, and has proved to be a perfect OS for IoT systems.
Developed in 2008 as an OS for wireless sensor nodes, it was later fine tuned for IoT systems.
Features of RIOT
The OS is actively developed and maintained.
- There are no new programming environments. C or C++ can be used directly with existing tools like gcc, gdb, etc
- Less hardware dependent code
- Supports 8-,16- and 32-bit microcontroller platforms
- Energy efficieny is maintained
- Less interrupt latency, so real-time capability is ensured
- Multi-threading is enabled
- Supports the entire network stack of IoT (802.15.4 Zigbee, 6LoWPAN, ICMP6, Ipv6, RPL, CoAP, etc)
- Both static and dynamic memory allocation
- POSIX compliant (partial)
- All output can be seen in the terminal if hardware is not available; however, there is a visualisation tool called RIOT-TV that is provided
Architecture, board and driver support
It supports various architectures like
- Cortex-M0, M3 and M4
- x86, etc
It also supports the native port, where one can simulate the output within the OS it is running. So RIOT is supported in Linux as well as OS X.
There are in-built drivers for the following sensors (without the need for hardware, these sensors can be modelled in native mode also):
- Radio receivers
- Environmental sensors for humidity, temperature, pressure, alcohol, gas, etc
- Ultrasonic sensors, light and servo motors
Most of the sensor boards like TelosB, ST, Zolertia, MSP 430, Arduino and Atmel have support from this OS (and the list is quite long). RIOT also supports virtualisation, where the code and application can run as a simple UNIX process. It also uses Wireshark for packet sniffing.
Comparisons with Contiki OS and Tiny OS
There are two other OSs, called Contiki OS (already featured in OSFY) and Tiny OS, which are suitable for IoT applications. But RIOT fares better when it comes to memory usage and support.
Figures 1 and 2 represent the block and network stack diagram of the IoT. Except for RPL, all modules have support from the RIOT OS (for RPL alone, there is partial support from RIOT).
Installation of RIOT in Linux
The OS used for installation is Linux Mint 17.2 and Ubuntu 14.04.2, while the architecture used is 64-bit OSs. The pre-requisite packages for installing RIOT are:
- msp 430 GCC compiler
- msp 430 libraries
- avr utils
- arm based gcc
- gcc multi-library, etc
Assuming that you have installed all just now, follow the steps shown below to install RIOT:
pradeepkumar $] sudo apt-get update pradeepkumar $] sudo apt-get install libc6-dev-i386 build-essential binutils-msp430 gcc-msp430 msp430-libc libncurses5-dev openjdk-7-jre openjdk-7-jdk avrdude avr-libc gcc-avr gdb-avr binutils-avr mspdebug msp430mcu autoconf automake libxmu-dev gcc-arm-none-eabi openocd git bridge-utils gcc-multilib socket
The OS can be downloaded as a zip file from Github (https://github.com/RIOT-OS/RIOT/archive/master.zip); else, you can clone it using the following command:
pradeepkumar $] git clone https://github.com/RIOT-OS/RIOT.git
The folder RIOT/ or RIOT-Master/ contains various sub-folders:
->boards: This folder has all the drivers for the boards that are supported by the OS
->cpu: This folder contains the architecture supported by RIOT
->cores: This has the core of the OS, like kernel, modules, etc
->doc: This folder contains documentation
->examples: Some examples like hello world, border router, Ipv6 formation, etc
->drivers: This one has drivers for all the sensors, etc
A simple example
These types of OSs can be learnt and understood only through the examples given within the source code of the application. RIOT has some examples in the examples/ folder, and one can go through the source code and run it using the following method. There are more examples available in the Github of RIOT (https://github.com/RIOT-OS).
If sufficient board or hardware is not available, then the code can be run in the terminal itself (native mode).
To run the hello-world example from the examples folder, use the following code:
pradeepkumar $] cd RIOT-Master/examples/hello-world pradeepkumar $] make flash pradeepkumar $] make term -----OUTPUT----- /home/pradeepkumar/RIOT-master/examples/hello-world/bin/native/hello-world.elf RIOT native interrupts/signals initialized. LED_GREEN_OFF LED_RED_ON RIOT native board initialized. RIOT native hardware initialization complete. main(): This is RIOT! (Version: UNKNOWN (builddir: /home/pradeepkumar/RIOT-master)) Hello World! You are running RIOT on a(n) native board. This board features a(n) native MCU. Press Ctl+C to quit the application
make flash will compile and show the text and the size of the data occupied by the memory. Since this application is run under native mode, the output can be viewed using the make term command (refer Figures 3 and 4).
Networking applications in RIOT
There are a few applications available in RIOT. One such app is a socket application, which works with the POSIX API with UDP as the protocol. All the relevant source code is available in the directory itself.
pradeepkumar $ ] cd RIOT-Master/examples/posix-socket/ pradeepkumar $ ] make flash pradeepkumar $ ] sudo make term output of the above command /home/pradeepkumar/RIOT-master/examples/posix_sockets/bin/native/posix_sockets.elf tap0 RIOT native interrupts/signals initialized. LED_GREEN_OFF LED_RED_ON RIOT native board initialized. RIOT native hardware initialization complete. main(): This is RIOT! (Version: UNKNOWN (builddir: /home/pradeepkumar/RIOT-master)) RIOT socket example application All up, running the shell now > help udp send data over UDP and listen on UDP ports reboot Reboot the node ps Prints information about running threads random_init initializes the PRNG random_get returns 32 bit of pseudo randomness; ifconfig Configure network interfaces txtsnd send raw data ncache manage neighbor cache by hand routers IPv6 default router list
Figure 5 shows the above configuration; routers can be configured, text messages can be sent and details about running processes can be searched using this application.
There are only a limited number of OSs available for IoT sensors and, among these, RIOT really has a well-documented API with huge support for most of the boards, architecture and sensors. Its main advantages are that it is actively developed and maintained, and there is an incremental version every month. Students and electronics hobbyists/enthusiasts are using Arduino and Raspberry Pi for their IoT applications these days, and RIOT really helps these boards and sensors to achieve a low memory footprint and high energy efficiency without any compromises on the performance of the IoT systems.