Zephyr: An Operating System for Wearable Device Development

As the fitness craze has taken off, wearable devices have gained attention, with smart bands and smartwatches gradually being seen as a fashion statement in recent years. However, wearable devices are just a branch of the Internet of Things (IoT), and wearable devices in the medical and health fields are gradually becoming mainstream.

A range of different forms of wearable devices provide users with various information, from biometric parameter measurements, such as heart rate and sweat safety levels, to comprehensive safety information. Moreover, many wearable devices come with displays, can operate independently, and most support some typical wireless communication methods.

Running a dedicated application directly on bare metal is possible. While many compact devices use microcontrollers for low-power operation, having an operating system simplifies programming. This helps enhance system performance, security, and confidentiality, as services provided by the operating system have been tested and optimized in a wide range of application environments compared to a single application.

Zephyr: An Operating System for Wearable Device Development

1. Wearable IoT devices can benefit from a compact operating system, as they generally already include a wireless protocol.

The operating systems and real-time operating systems in this field are diverse, striving to attract developers’ attention, including a large number of commercial and open-source software, and even a mix of both in IoT. Recently, users have discussed not only connectivity (such as wireless protocols) but also IoT communication protocols as a super set, with features like security and online upgrades needing to be integrated with the operating system, which means encapsulating a lot of software into a small space.

Wearable device IoT systems sometimes use Linux, but they also use some more compact operating systems, such as ARM mbed, FreeRTOS, NuttX, RIOT OS, TinyOS, and Zephyr.

Today, I will take you to understand the Zephyr project in detail; it is a derivative of Wind River’s microkernel OS. Wind River provides many professional commercial supports that developers need for Zephyr. In fact, this type of support can be obtained from various resources of other operating systems, which is why commercial operating systems are often the preferred choice for IoT applications.

What is Zephyr?

Zephyr is an open-source project, with source code licensed under Apache 2.0.

Zephyr version 1.6 is built on a unified kernel, with its architecture originally containing a microkernel. The microkernel version is designed for resource-constrained platforms and can run in as little as 2KB of code space. Other functions are provided by the microkernel, requiring a minimum of 50kB of space.

Zephyr: An Operating System for Wearable Device Development

Zephyr has many features similar to compact operating systems, including a single addressing space and non-dynamic real-time support. The former is usually a hardware limitation, while the latter is a design choice, as most devices address a fixed set of application characteristics. Similarly, resources are fixed and defined at compile-time or build-time, which can reduce storage space and enhance performance. The system typically has minimal runtime error checking, although Zephyr has an optional error query infrastructure for system debugging during the application development phase.

The scalability part of the unified kernel is multi-threading services, which can handle priority-based non-preemptive threads as well as preemptive threads with an optional time-slicing scheduler. Interrupt service supports compile-time registration of interrupt handlers.

Zephyr: An Operating System for Wearable Device Development

2. The original microkernel/microkernel platform of Zephyr has been replaced by a unified kernel that can be configured to address the resource-constrained environments targeted by the microkernel. In addition, it can provide nearly all of the functions originally in the microkernel.

Zephyr provides general operating system services, such as dynamic memory allocation. Cross-thread synchronization services support binary semaphores, counting semaphores, and mutexes. Cross-thread data transfer services use basic message queues as well as enhanced message queues and byte streams. Power management services support seamless idle states. Applications can also leverage advanced idle infrastructure, correspondingly increasing code size.

So far, Zephyr looks very much like a typical compact operating system, which is precisely what it is. The higher you look, the more interesting things become.

Zephyr supports wireless protocols such as Bluetooth and WiFi, as well as wired connections such as three-wire and five-wire serial ports. Zephyr also supports standard communication middleware like LoWPAN, and the support for thread groups is on the agenda of the technical steering committee of the Zephyr project; by the way, the Linux Foundation supports Zephyr. Encryption and cryptographic communication support are provided by the TinyCrypt 2 and mbed’s mbedTLS stack. The standard middleware of Zephyr makes it even more interesting in IoT environments.

Static Analysis of Open Source Projects

Let’s take a look at Zephyr’s static analysis, which is crucial for security and assurance. Like many projects, Zephyr is written in C. The C language has many advantages, but it can also lead programmers to inadvertently “shoot themselves in the foot.” Static analysis can detect many erroneous codes that C programmers inadvertently introduce. Unfortunately, traditional C/C++ compilers do not provide static analysis tools, except for basic checks which may be an exception.

There are many commercial static analysis tools on the market. Many commercial C/C++ toolsets also include these supports, such as MISRA C/C++ checks. One of the commercial solutions is Coverity from Synopsys. Coverity Scan is a free service provided by Coverity/Synopsys for open-source projects. It can be used for Java, C/C++, C#, JavaScript, Ruby, or Python open-source projects, and includes platforms like Zephyr. Coverity Scan has some limitations, such as the number of actionable scans per week, but it can be integrated into daily development. Of course, developers can purchase Coverity’s tools without such limitations.

For IoT developers who need to develop applications on resource-constrained platforms like wearable devices, Zephyr is just one of many options available.

About Zephyr

Zephyr Project is a small and scalable operating system, especially suitable for resource-constrained hardware systems, supporting multiple architectures; the system is highly open-source and completely open to the developer community, allowing developers to customize the system as needed to support the latest hardware, tools, and device drivers; the system is a highly modular platform that easily integrates third-party libraries and embedded devices of any architecture.

Leave a Comment