# IoT Operating Systems

## Summary


The use of operating systems for IoT hardware is often categorized into two groups: end devices and gateways. End devices or nodes are often lot smaller in capability as compared to gateways. As more and more processing is pushed to the network edges (to gateways and nodes), traditional devices that used to run without an OS are embracing new OS implementations customized for IoT.

While IoT OS are an evolution of embedded OS, IoT brings its own additional set of constraints that need to be addressed. A mix of open source and closed source IoT OS exist in the market. Since IoT is varied in terms of applications, hardware and connectivity, we expect the market will sustain multiple OS rather than just a couple of them.

## Discussion

### Do IoT end devices require an OS in the first place?

While having an OS is not mandatory, devices are growing in complexity. This complexity is due nodes having more sensors, more data processing and increased connectivity to send that data out. Some devices have rich user interfaces that might include graphical displays, face recognition and voice recognition. End devices that were often based on 8-bit or 16-bit MCUs are moving to 32-bit architectures as costs drop and complexity increases. Addressing these changes without an OS is not only a challenge but also inefficient. The use of OS, particular an RTOS, simplifies the job of application programmers and system integrators because many of the low-level challenges are taken care of by the OS. 

As a thumb rule, a system that consumes less than 16KB of RAM and Flash/ROM does not require an OS. Such systems most often run on 8-bit or 16-bit MCUs. With such systems, we can get away with a single event loop that polls and processes events as they occur. But if more complexity is added to the system, the response times will be limited by the worst-case processing time of the entire loop. 


### What are the parameters for selecting a suitable IoT OS?

The following parameters may be considered for selecting an IoT OS:

    + Footprint: Since devices are constraint, we expect OS to have low memory, power and processing requirements. The overhead due to the OS should be minimal.
    + Scalability: OS must be scalable for any type of device. This means developers and integrators need to be familiar with only one OS for both nodes and gateways.
    + Portability: OS isolates applications from the specifics of the hardware. Usually, OS is ported to different hardware platforms and interfaces to the board support package (BSP) in a standard way, such as using POSIX calls.
    + Modularity: OS has a kernel core that's mandatory. All other functionality can be included as add-ons if so required by the application.
    + Connectivity: OS supports different connectivity protocols, such as Ethernet, Wi-Fi, BLE, IEEE 802.15.4, and more.
    + Security: OS has add-ons that bring security to the device by way of secure boot, SSL support, components and drivers for encryption.
    + Reliability: This is essential for mission-critical systems. Often devices are at remote locations and have to work for years without failure. Reliability also implies OS should fulfil certifications for certain applications.

### What parameters are important for selecting a suitable IoT OS?

The short answer is that there's no universal subset of important parameters. While there are many parameters for selection, some of them may be more important than others depending on the hardware type and application. For example, a small memory footprint may be important for end devices but not so for gateways. Compliance to standards may be important for an industrial application but not so for a hobby project. Someone looking at only ARM-based hardware might choose ARM mbed at the expensive of platform portability. A device that has access to a power supply might not expect power optimization from its OS; whereas a battery-powered device might expect the OS to do power management so that the battery can last for 10 years. 


### What certifications might an IoT OS require?

This is dependent on the vertical. The following is a non-exhaustive list: 

    + DO-178B for avionics systems
    + IEC 61508 for industrial control systems
    + ISO 62304 for medical devices
    + SIL3/SIL4 IEC for transportation and nuclear systems

### What are the open source IoT OS?

The following is a non-exhaustive list: TinyOS, RIOT, Contiki, Mantis OS, Nano RK, LiteOS, FreeRTOS, Apache Mynewt, Zephyr OS, Ubuntu Core 16 (Snappy), ARM mbed, Yocto, Raspbian.

Some of these have come from academic institutions. TinyOS and Contiki are among the oldest. RIOT is more recent and has an active community of developers. FreeRTOS is among the popular ones. LiteOS is from Huawei. ARM mbed is single-threaded, event-driven and modular. It's has good connectivity and low footprint. In Zephyr OS the kernel is statically compiled, which makes it safe from compile time attacks. With Ubuntu Core, rather than having a monolithic build, kernel, OS and apps are expected be packaged and delivered as snaps. Android Things, previously named Brillo, is Google's offering. Yocto is not exactly an embedded Linux distribution. It's a platform to create a customized distribution for your particular application. 


### What are the closed or commercial IoT OS?

The following is a non-exhaustive list: Android Things, Windows 10 IoT, WindRiver VxWorks, Micrium µC/OS, Micro Digital SMX RTOS, MicroEJ OS, Express Logic ThreadX, TI RTOS, Freescale MQX, Mentor Graphics Nucleus RTOS, Green Hills Integrity, Particle.

Windows 10 IoT comes in three flavours: IoT Enterprise, IoT Mobile Enterprise and Core. TI RTOS and Freescale MQX target the respective chipsets. Where reliability and safety are important, some of these commercial systems are preferred, particularly in aerospace, automotive, healthcare and industrial systems. Windows 10 IoT and Particle are examples that enable easy integration to cloud services.


### What are the popular IoT OS out there?

From the IoT Developer Survey 2018 conducted by Eclipse Foundation, it was found that 71.8% of the respondents like or use Linux-based OS. Within Linux, Raspbian takes the lead. Windows and FreeRTOS follow at 22.9% and 20.4%. However, the sample size in this survey was small. 

It's interesting that 19.9% of developers prefer bare-metal programming. **Bare-metal** is a term that's used when no OS is used. Bare-metal is preferred for constrained devices. It's a cheaper option but development and support costs may increase. If the device's processing, memory and power requirements can allow it, Embedded Linux is preferred. It will have a shorter time-to-market, better security, wider support base and well-tested connectivity solutions. 


### Do IoT OS need to be real-time OS?

RTOS will be required where data has to be processed within time constraints, often without buffering delays. Where multiple threads are required that have to meet deadlines and share resources effectively, RTOS will be needed. 

There will also be a class of devices that may not have strict real-time constraints. For some, a richer user interface may be more important. Some may buffer data and transmit them occasionally to save power. Such devices need not have an RTOS and may adopt a simpler OS. However, a survey from 2015 has shown that many designers who choose an OS mention real time as one of the top reasons. 

Designers may choose to use multiple processors where it makes sense. For example, an 8-bit MCU may be used to interface to sensors and actuators; a 32-bit processor will run the RTOS for connectivity and multithreading. 


### What are typical memory requirements for IoT OS?

Sensor nodes will have less than 50KB of RAM and less than 250KB of ROM. Contiki requires only 2KB of RAM and 40KB of ROM. Similar numbers are quoted for Mantis and Nano RK. Zephyr requires only 8KB of memory. Apache Mynewt requires 8KB of RAM and 64 KB of ROM. It's kernel takes up only 6KB. Communication protocols typically take up 50-100KB of ROM. 

In all cases, the numbers will increase when more components are added as required by the application. For example, one experiment with SMX RTOS showed 40KB/70KB of RAM/ROM for a node; the same OS for a gateway came up to 200KB/300KB. 

Devices based on Ubuntu Core, Windows 10 IoT, Android Things and MicroEJ are likely to require memories in the order of gigabytes. Gateways will typically have a footprint in the order of gigabytes. This is because of extra functionality that they are require to do: device management, security, protocol translation, retransmissions, data aggregation, data buffering, and so on. 


### What design techniques are used by IoT OS?

TinyOS and ARM mbed use a monolithic architecture while RIOT and FreeRTOS use a microkernel architecture. ARM mbed uses a single thread and adopts an event-driven programming model. Contiki uses protothreads. RIOT, FreeRTOS and µC/OS use a multithreading model. In static systems (TinyOS, Nano RK), all resources are allocated at compile time. Dynamic systems are more flexible but also more complex. File systems may not be required for the simplest sensor nodes but some OS support single level file systems. With respect to power optimization, this is done for the processor as well as its peripherals. 

## Milestones

1999

The first implementation of TinyOS happens within UC Berkeley. It is released to public in 2000. 

2003

Adam Dunkels releases Contiki. Dunkels goes on to found Thingsquare in 2012.

2013

RIOT is released to the public. The origins of RIOT lie in FeuerWare (2008) and µkleos (2010). 

Jun  
2016

Irish firm Cesanta releases 1.0-rc1 version of open source OS named **Mongoose**. Version 2.3 is released in June 2018. Mongoose makes it easy to connect your IoT devices to the cloud and do over-the-air (OTA) updates. Microcontrollers supported include STM32F4, STM32F7, ESP32, ESP8266, CC3220, and CC3200. 

Oct  
2016

Ubuntu Core 16 beta version, based on snaps, is released. 

Dec  
2016

Google rebrands Brillo as Android Things. Brillo was announced earlier at Google I/O 2015. 

Nov  
2017

Amazon announces Amazon FreeRTOS. Based on the FreeRTOS kernel, this makes it easier for developers to connect their IoT devices locally or to the cloud, to make their devices more secure and do over-the-air updates.