IoT Monkey > Prototyping 101 > ContikiOS: first impressions

ContikiOS: first impressions

Yesterday I have had my hands on ContikiOS and my first impression is really great. Contiki is an open source, highly portable, multi-tasking operating system for memory-efficient networked embedded systems and wireless sensor networks. It is designed for microcontrollers with small amounts of memory in mind.

Dubbed as the open source OS for the Internet of Things, Contiki is really promising.

ContikOSi provides powerful low-power Internet communication and supports fully standard IPv6 and IPv4, along with the recent low-power wireless standards: 6lowpan, RPL, CoAP. With Contiki’s ContikiMAC and sleepy routers, even wireless routers can be battery-operated.

With Contiki, development is easy and fast, as applications are written in standard C. With the Cooja simulator [it deserves a separate article] Contiki networks can be emulated before burned into hardware, and Instant Contiki provides an entire development environment in a single download.

Probably the best of all is that Contiki is an open source software: Contiki can be freely used both in commercial and non-commercial systems and the full source code is available at GitHub. The operating system is developed by a world-wide team of developers with contributions from Atmel, Cisco, ETH, Redwire LLC, SAP, Thingsquare. The project is led by Adam Dunkels, the founder and CEO of  Thingsquare.

Contiki is designed for tiny systems, having only a few kilobytes of memory available. Contiki is therefore highly memory efficient and provides a set of mechanisms for memory allocation: memory block allocation memb, a managed memory allocator mmem, as well as the standard C memory allocator malloc.

To save memory but provide a nice control flow in the code, Contiki uses a mechanism called protothreads. Protothreads is a mixture of the event-driven and the multi-threaded programming mechanisms. With protothreads, event-handlers can be made to block, waiting for events to occur.

The operating system provides a full IP network stack, with standard IP protocols such as UDP, TCP, and HTTP, in addition to the new low-power standards like 6lowpan, RPL, and CoAP. The Contiki IPv6 stack, developed by and contributed to Contiki by Cisco, is fully certified under the IPv6 Ready program.

In situations when bandwidth is at a premium or where the full IPv6 networking stack is overkill, Contiki provides a tailored wireless networking stack called Rime. The Rime stack supports simple operations such as sending a message to all neighbors or to a specified neighbor, as well as more complex mechanisms such as network flooding and address-free multi-hop semi-reliable scalable data collection. Everything runs with sleepy routers to save power.

Contiki is designed to operate in extremely low-power systems: systems that may need to run for years on a pair of AA batteries. To assist the development of low-power systems, Contiki provides mechanisms for estimating the system power consumption and for understanding where the power was spent.

It can run on a wide range of tiny platforms, ranging from 8051-powered systems-on-a-chip through the MSP430 and the AVR to a variety of ARM devices. There are also a number of more exotic platforms thrown in there for good measure.

For devices that has an external flash memory chip, Contiki provides a lightweight flash file system, called Coffee. With Coffee, application programs can open, close, read from, write to, and append to files on the external flash, without having to worry about flash sectors needing to be erased before writing or flash wear-leveling. The performance of Coffee is within 95% of the raw throughput of the flash memory.

Contiki provides an optional command-line shell with a set of commands that are useful during development and debugging of Contiki systems. With Unix-style pipelines, shell commands can be combined in powerful ways. Applications can define their own shell commands that work together with existing commands.

The Contiki build system makes it easy to compile applications for any of the available Contiki platforms. This makes it easy to try out applications on a range of different platforms. The best thing of all is that if you don’t have the hardware available, you can use the Cooja simulator to emulate any of the available hardware devices that Contiki supports.

ContikiOS is definitely something, which I will dig into the future. As I advance, I will be keeping you posted. Stay tuned!