The Role of Operating Systems in IoT
The Role of Operating Systems in IoT
Right-sizing OSes for your IoT environments
Over the last 20 years we have changed how we talk about the technology that integrates into our daily lives. As it has become easier to embed computer processing into objects, we invented a category for objects that had the ability to communicate electronically: the “Internet of Things,” or IoT
Smart devices have evolved rapidly, and as embedding processors capable of communication into devices became simpler and cheaper, an enormous number of inexpensive devices began joining the Internet. The growth of IoT has been astounding, and internet-connected “smart” versions of various consumer devices are now for sale at Ikea and other mainstream retailers.
With the Internet coming to ‘things’ in this way, we have become more accustomed to computing power in our homes coming from devices most don’t consider “computers” in the traditional sense. In the early days of Apple, Steve Jobs dreamed that computers would become like appliances, as easy to use as a coffee maker. In some ways the computer has managed to become an appliance— but the Internet of Things consists of appliances that have become computers instead.
IoT devices range from tiny environmental sensors up to central hubs that can manage your home storage and run multiple appliances. At the lower end of performance, devices can be little more than a Bluetooth LE (low-energy) chip set and a sensor—enough processing power to send an alert about a door opening, but nowhere near enough to rival a general-purpose computer.
At the other end of the scale, we have devices that have enough computing power to take on tasks typically given to a home server. These higher end devices often serve as the core component that enables lower powered sensors to reach the Internet.
All of these smart devices have Operating Systems, regardless of how much or how little of them are exposed to the user. An Operating System is the software that runs on a device, manages the hardware, and ensures that components work together to perform some task. Some of these Operating Systems are very singular in their purpose, while others are general platforms that the owners can run custom applications on.
This article is going to look at the role Operating Systems have in IoT from the smallest battery powered sensors all the way up to central hubs that can manage dozens of cameras. We will look at how our favorite Operating System, FreeBSD, can fit into this environment.
Features that determine the size of IoT devices
Beyond the ability to observe the real world with sensors or cameras, there are two main features that determine the roles of an IoT device and its Operating System—processing power and connectivity.
You might also want be interested in
FreeBSD development is easy when you have a team of world-class developers at your fingertips.
At Klara, we dedicated our team dedicated to helping you develop and take your FreeBSD infrastructure project further. Whether you’re planning a FreeBSD project, or are in the middle of one and need a bit of extra insight, we’re here to help!
The computational power of a smart device is determined by the type of processor that it uses. Processors vary in clock speeds, RAM sizes and buses for different peripherals, but the main decider is whether the processor is designed as a Microcontroller or Application class. This distinction typically determines if there is a Memory Multiplexer Unit (MMU) and other features required for general-purpose operating systems.
The smallest systems that we think of as IoT are simple devices that offer sensor data or provide simple outputs (such as lights or speakers). The processor in these systems might be a simple small ARM core that has just enough power to control the Bluetooth chip. These devices might offer a service such as a sensor reading (think smart bathroom scales) or an output like an LED (smart light bulb). While these devices lack much in the way of onboard computing power, they are paired with more powerful controllers, such as dedicated hubs or mobile apps, which process and summarize this data and assist in uploading it to the cloud.
More rich-featured devices have larger and faster microcontrollers, some scaling out to multiple cores. These devices can be found embedded with Wi-Fi chipsets such as the Espressif ESP8266 (found in many smart power devices) or the TI CC3230S. These devices typically have the capacity to run much more sophisticated software applications, and in some cases can manage their own modern cryptography, allowing them to speak to Internet services directly, without needing a separate controller or smartphone app to act as intermediary.
At the top of the range are devices with Application processors. Home wireless routers are a good example of devices in this category. This class of device typically has a modest Application processor capable of running a full Operating System and hosting multiple services. They can range from a relatively simple hub which controls smart sensors, up to small home servers that can host multiple applications.
Connectivity is the physical equipment and radio protocols the device has to communicate with other computers. IoT devices are connected through a huge range of different technologies. The most pedestrian of these is Wi-Fi, where the device uses the normal home network to connect to a local hub or to the Internet directly.
Smaller devices can use Bluetooth Low Energy (LE) as a local area network technology. A device will use Bluetooth to connect to a smart phone; from there, an app running on that phone logs the device’s data and may upload it to an Internet-hosted service using the phone’s own connectivity. Dedicated “hub” devices may offer the same functionality, either instead of or in addition to a smartphone app.
An option for small devices such as sensors is to use a lower transfer rate proprietary local network technology such as Zigbee or Z-Wave. This is the type of technology in Phillips Hue light bulbs. These technologies tie all devices to each other in a mesh, where one device can connect to multiple others.
Mesh networks allow connectivity to grow beyond the reach of a single central hub, making it more cost effective to grow out a network with more things across larger, less centrally-addressable physical spaces. These technologies need to be converted to reach the Internet and this is handled using a network hub that centralizes the traffic and forwards it out to the cloud.
A final and more recent technology for smart devices is LoraWan. LoraWan is a wide area networking technology that allows devices to connect over multiple kilometers to hubs that then forward traffic onto the Internet. Lora allows applications that need to grow far beyond the reach of a building and Lora is being used in applications such as making street lights smart and remote monitor for railways.
The Role of Operating Systems
The smallest IoT devices do not have a general-purpose operating system. The platform runs a limited amount of code, and is not typically able to offer any further services. The majority of what the device can do is determined by a minimal firmware, so the device can negotiate a Bluetooth connection and act as a speaker, but it is not able to repurposed to be a data logger in the field. Its services are determined by the manufacturer in the factory.
Devices that have more recent microcontrollers are in a middle point, where they can either run firmware on the bare metal or run small operating systems which are able to offer more services on the device. The ESP8266 family of devices have achieved massive popularity for making smart, Wi-Fi connected devices; this has led to a cottage industry in repurposing devices with these chipsets, or just using the chipsets themselves for prototypes and hobby projects.
These devices do not have an MMU or the architectural features required to run a full Unix like Operating System, but are able to run small Real Time Operating Systems (RTOS).
There are many small open source RTOS available to choose from when specifying a new project. Common open-source projects in this context include MBED for ARM devices, the IoT focused RIOT, and more generic platforms such as FreeRTOS. These platforms are able to run complicated applications, but they’re quite different from the operating systems that we use on typical desktop and server computers. These minimalistic operating systems are chosen instead of full-featured, multipurpose operating systems because they fulfill a timing requirement for the device, or fit within the constraints of the hardware.
These platforms enable multiple applications to be run on the hardware and allow these applications to be portable to different processors. Because the operating system offers common APIs for services such as hardware access and networking, product development can be more flexible, and code reuse becomes much easier. The operating system for these devices ensures that the resources of the device are shared effectively among its applications. You can find these operating systems in sensor devices that need to handle more connectivity or have higher processing requirements.
The high end of hardware that is limited to RTOS overlaps with the low end of hardware that is able to run full-featured operating systems. Many open source RTOS can run on full-featured application sized processors, and the choice between an RTOS and a full operating system in this case is largely dependent upon the purpose of the device.
More capable application processors cost more than microcontrollers which integrate communications devices such as radios for WiFi and Bluetooth along with the processor itself. The ecosystem benefits that come from using larger application processors—and the greatly improved security options they offer—can more than make up for this difference.
Real Time Operating Systems have to be able to satisfy the timing requirements that allow them to offer real time guarantees. Most applications that we use don’t need to work in these environments, and are instead developed for more fully featured POSIX compatible Operating Systems.
A big advantage to using a full Unix compared to deploying on an RTOS is the ability to take code that has been written to work in other environments, either servers or on the desktop and run it without requiring changes. This makes the full software stack from your normal server applications available on your embedded IoT devices as well. By contrast, when using an RTOS you might have to use less commonly deployed libraries to get support for your product.
This benefit also works in the other direction. If you want to turn your IoT device into a virtual appliance, you are able to take advantage of the common operating system support for running your full Unix in a virtual machine— a deployment strategy that is certainly much better tested for a full POSIX operating system, and may not be supported for your RTOS at all.
Operating Systems for Building an IoT product
There are a lot of operating systems suitable for integration into an IoT product. Linux is the most common choice for building an IoT product with an application sized processor. Linux has been ported to every processor architecture, and is commonly made available by vendors as a reference platform.
Build your own
There are also a number of frameworks that help developers build their own distributions to run on IoT products, as well as fully fledged distributions with support designed to be integrated into such products.
The two main frameworks for building a distribution for an embedded target or IoT platform are Yocto and buildroot. Both of these are environments for configuring a build and creating an image that can be flashed to a board or run from an SD card. Neither Yocto or buildroot are distributions, instead they are frameworks for building out a platform. They do not offer support for the end product that is created.
Ubuntu IoT Core
Canonical offers a specialized, IoT-focused version of Ubuntu called Ubuntu IoT Core. Ubuntu IoT Core offers support and integration into Canonical’s cloud APIs, in a similar way that Windows 10 IoT Core does for Microsoft.
Ubuntu offers a coherent platform similar to what you would run on the desktop or on a server. One of the main features offered for Ubuntu IoT Core is the availability of ‘snaps’ (Ubuntu’s containerized application image format). Canonical offers a free tier for IoT Core, but if your product requires more than best effort software updates and patching, you will need to purchase a per device support contract.
Windows 10 IoT Core
Windows is still a contender in the embedded space, although it is less common than it used to be. Windows 10 IoT Core services the market for IoT devices. Windows 10 IoT Core offers a similar platform to Windows 10 on the desktop or server, but in a stripped back profile which allows it to fit into more memory and processor constrained devices.
Beyond the operating system platform, Windows 10 IoT Core offers integration into Azure cloud services and the ability to run .NET Applications on your IoT device. Unfortunately, though unsurprisingly, Microsoft’s platform is proprietary, and you are limited to the platforms and processors with existing and supported ports, with no guarantee of support beyond 2027.
FreeBSD for IoT Products
The final option we are going to consider for IoT devices on application processors is FreeBSD. FreeBSD has support for a large range of hardware with all the driver support in the main branch of the tree.
While FreeBSD does not have quite the range of hardware support that Linux benefits from, it does offer a broad range of supported, well-tested devices with stable drivers. FreeBSD has ports to many different Systems on a Chip (SoC) with the ARM64, ARMv7 and AMD64 architectures.
Thanks to dedicated work by FreeBSD committers, there are high quality drivers for most of the devices on these systems, and support is available to help add more drivers for new hardware.
If you are building an image for an IoT device, the FreeBSD project’s unified approach to kernel and userland development means that FreeBSD’s own release tooling is already in place to build your image. It is also possible to modify the FreeBSD release infrastructure to offer custom images with your own branding without a ton of extra work.
The single development model also makes it easy to get an IoT image that is in most senses identical to a desktop release. Where Linux based systems will lean towards leaner versions of the normal Linux tools, FreeBSD images are generally available “fat,” since it’s simple to strip out unwanted features yourself. This makes it easy to run a FreeBSD image on IoT hardware with as much of the original functionality intact as you’d like, while still stripping out as much as you’d like.
FreeBSD also has a workflow for building images customized with packages through poudriere and poudriere-image. This tool makes it straight forward to build and maintain your own package archives.
On platforms that can support more of FreeBSD, you are able to take advantage of more FreeBSD features. You can deploy isolated services by using jails, or leverage jails to provide a common framework for third party applications on top of your IoT device.
Development and testing for software running on FreeBSD is the same on an IoT device as it is on a desktop or server system, which smooths development workflow and can make it easier to bring a product to market. Since FreeBSD’s own tools can be used to strip it down to a minimal image, that image is not an exotic, difficult-to-support environment.
Klara offers comprehensive services around designing, building, and supporting IoT devices in the field.
The sheer breadth of IoT systems—ranging from battery power environmental sensors up to high-definition cameras—makes it hard to draw any single conclusion. The real needs of an IoT operating system are largely determined by the goals of the device it needs to support. Full operating systems such as FreeBSD are not common on the smallest of devices, but they aren’t entirely unheard of.
FreeBSD fits well into the application processor sized IoT space and offers a common development and deployment platform that has been proven to work well in large deployments.