Why Zephyr?
When the Zephyr project was announced in February, many members of the Linux community seemed to find it puzzling. Although Zephyr is hosted by the Linux Foundation, it is an entirely separate operating system that incorporates no Linux code. It also targets small hardware devices—from Arduinos to ARM system-on-chips (SoCs)—even though there are several other open-source OS projects (including Linux for many ARM SoCs) that also address that device class. At the 2016 Embedded Linux Conference in San Diego, the Zephyr team was on hand to make the case for why the new project is necessary and, hopefully, interesting to developers.
OSes of Things
Intel's Anas Nashif presented an overview of Zephyr in his talk, describing
both its background within Intel and its capabilities. The bottom-line goal of the
project is to provide an open-source, realtime operating system (RTOS)
for "sub-Linux devices." Beyond that, however, Intel looked at the
existing RTOS offerings on the market and found them lacking in
several respects. First, many of them focus only on one architecture,
which limits their appeal.
Second, many of them are "roll your own" projects developed for research or maintained by a single person. That seems to correlate with a lack of security work, which is a serious drawback. In addition, some of these smaller RTOS projects use peculiar software licenses, which also inhibits their adoption within the open-source community. Finally, many of the existing projects are too limited in functionality to serve as a general-purpose OS for Internet of Things (IoT) devices, which Intel sees as the primary use case for Zephyr.
Put all of those factors together, and one has the Zephyr product brief: an open-source RTOS that supports multiple architectures, has a broad contributor base, and offers "more than just a scheduler"—specifically, good networking support and a real security framework. Intel happened to acquire the rights to Wind River's microcontroller RTOS, decided it could be developed into a good fit, and set about to clean up the code and prepare it for release. That RTOS is now the open-source Zephyr, although it also serves as the core of Wind River's "Rocket" RTOS product. Intel is currently leading the development effort.
By building on the existing Wind River code base, Nashif said, Zephyr can start with a battle-tested code base used for more than a decade in real-world conditions. Expanding the original code involved several key steps. First, it was restructured to be more modular. At compile time, developers can include or exclude whichever subsystems they need in order to fit the hardware. The hardware in question includes what he called "the very lowest end of the sub-Linux device spectrum", "where the cost of the silicon is minimal." He showed a slide listing the initial hardware products on which Zephyr runs, which includes the Arduino 101 and Intel Quark D2000 at the low end, and goes all the way up to the second-generation Intel Galileo at the high end. But, he added, the Galileo is a development platform only; it is fully capable of running Linux, so he expected no one would use it for a real Zephyr deployment.
![Constanza Heath [Constanza Heath]](https://static.lwn.net/images/2016/04-elc-heath-sm.jpg)
Second, the Zephyr team added networking. It wrote a Bluetooth Low Energy (BLE) implementation from scratch, and ported the IP stack from the open-source Contiki RTOS. IPv6 is supported, include the low-energy 6LoWPAN. The project is still looking at other network stacks; Near-Field Communication (NFC) is likely; ZigBee and WiFi are also possibilities if there is demand.
The third addition to the code base was a cryptographic library based on TinyCrypt. In a separate session, security developer Constanza Heath described TinyCrypt's set of random-number generation (RNG), cipher, and key-exchange primitives, as well as Zephyr's general approach to security. A Zephyr image runs only a single application, which is statically linked in at compile time. There is a single address space and no loadable kernel modules are supported, which reduces the attack surface considerably. In brief, she said, with a single, statically linked process running, if there is malicious code running on your Zephyr hardware, then it was there at compile time. The project thus skips some other security features that larger OSes include to protect against security exploits, though she said the team is still looking into adding some protections like address-space randomization. For most security features, the question at hand is the security-versus-size trade-off.
Features
When it comes to size, Zephyr can run comfortably in 8KB of RAM, and can even run in a minimum of 2KB of RAM, although Nashif said that at that size it provides nothing but a "Hello World" demo. The Zephyr kernel can be configured in either one of two modes. The smallest is "nanokernel" mode, which provides a basic multi-threaded execution environment, inter-thread synchronization services (including semaphores and mutexes), message queues, and interrupt services. Nanokernel mode is expected to be used for the smallest and cheapest devices, he said, such as environmental sensors, which need to do little processing beyond gathering and sending data.
A step up from nanokernel mode is microkernel mode, which offers a superset of nanokernel mode's features, including more sophisticated message queuing, additional memory allocation services, preemptive tasks, and round-robin time slicing. This mode is expected to be used on slightly larger IoT nodes, such as sensor hubs that may need to process and format data collected from sensors before forwarding it on to a remote server. Nashif pointed out that networking was available in both nanokernel and microkernel mode, although configuring a nanokernel build for the full IP networking stack could potentially make it hard to fit Zephyr into a sub-10KB RAM device.
Nashif noted Zephyr also makes use of some tooling from Linux. Configuration is done using the Linux kernel's kconfig, and Zephyr builds are done using kbuild. But the similarities stop with those tools, he said—a Zephyr image is configured and built for a single application. "We're just trying to learn from Linux, not to be Linux." The project offers a software development kit (SDK) that supports five compilers and provides tools for flashing images onto devices and for debugging. In addition to running on Linux, Windows, and Mac OS X, the SDK can run in Docker containers.
Intel sees Zephyr as a strategic investment, Nashif said. It saw gaps in the RTOS market, particularly where IoT devices are concerned, and took the opportunity to try building a project to fill the gap. It hopes to win over the community, and hopes to work with other open-source projects wherever possible. Nashif added that he knows the IoT space is a crowded one; he has seen two new IoT OSes announced since Zephyr was released, and does not expect that trend to slow down.
Whoever establishes dominance in the IoT market will have to overcome quite a bit of competition, both proprietary and open source. It is quite early in Zephyr's lifespan, even though the code base has a longer history through its days at Wind River. Wherever it goes from here, it will be interesting to watch.
[The author would like to thank the Linux Foundation for travel assistance to attend ELC 2016.]
Index entries for this article | |
---|---|
Conference | Embedded Linux Conference/2016 |
Posted Apr 7, 2016 7:34 UTC (Thu)
by abogani (subscriber, #57602)
[Link] (4 responses)
Posted Apr 7, 2016 8:25 UTC (Thu)
by tao (subscriber, #17563)
[Link] (3 responses)
Posted Apr 7, 2016 10:14 UTC (Thu)
by epa (subscriber, #39769)
[Link] (2 responses)
Posted Apr 7, 2016 11:27 UTC (Thu)
by tao (subscriber, #17563)
[Link] (1 responses)
The major benefit is that even with a tinified Linux kernel you still optionally have access to almost every feature provided by the Linux kernel, an tons and tons and tons of HW support to choose from. Plus a much, much, MUCH larger pool of experts to choose from if you want to subcontract development or maintenance work.
Zephyr might get ported to several platforms and have support for common HW and things that comes with it (some wifi-chipsets, low power bluetooth, NFC, etc.), but there will always be a lot of cases where you'd have to write your own drivers for Zephyr to get support for what you need.
If you're in a situation where your memory budget isn't so small that a Zephyr (or other nanokernel) is the only option -- where a Linux kernel with only your specific requirements enabled would *almost* fit, then a tinified Linux kernel would make sense.
The tinification project has other benefits too -- the effort of going through code to identify candidates for memory bloat means code review, and sometimes even optimisations that can benefit larger scale systems too. Size optimisations can, if they make things fit in a cache line, have quite nice performance benefits.
Posted Apr 7, 2016 12:03 UTC (Thu)
by epa (subscriber, #39769)
[Link]
Posted Apr 7, 2016 11:06 UTC (Thu)
by dgm (subscriber, #49227)
[Link]
Posted Apr 7, 2016 14:33 UTC (Thu)
by ken (subscriber, #625)
[Link]
clearly they know about Contiki as they took the ip stack from that but what was the problem with just using contiki?? or ecos or any of the other. What is it really that makes Zephyr so uniq.
Posted Apr 7, 2016 15:07 UTC (Thu)
by karim (subscriber, #114)
[Link] (2 responses)
Posted Apr 7, 2016 16:30 UTC (Thu)
by paulj (subscriber, #341)
[Link]
Posted Apr 8, 2016 18:57 UTC (Fri)
by lsl (subscriber, #86508)
[Link]
Posted Apr 7, 2016 15:54 UTC (Thu)
by faramir (subscriber, #2327)
[Link] (1 responses)
Posted Apr 16, 2016 6:00 UTC (Sat)
by oldtomas (guest, #72579)
[Link]
Had I to choose an RTOS, I'd pick a GPL licensed one. Preferably GPL V3.
Posted Apr 8, 2016 20:58 UTC (Fri)
by giraffedata (guest, #1954)
[Link] (10 responses)
Posted Apr 9, 2016 1:44 UTC (Sat)
by tao (subscriber, #17563)
[Link] (8 responses)
Posted Apr 9, 2016 15:47 UTC (Sat)
by giraffedata (guest, #1954)
[Link] (7 responses)
Posted Apr 9, 2016 16:09 UTC (Sat)
by pizza (subscriber, #46)
[Link] (4 responses)
Posted Apr 9, 2016 16:20 UTC (Sat)
by giraffedata (guest, #1954)
[Link] (2 responses)
Posted Apr 9, 2016 18:50 UTC (Sat)
by alonz (subscriber, #815)
[Link]
(As an aside, most dense memories are of the DRAM variety—Dynamic RAM—which requires continuous refresh from the memory controller, and therefore eat through batteries with unholy glee. On Internet-of-Things devices, which are often expected to last for years on a teeny battery, this option is just plain out.)
Posted Apr 9, 2016 23:22 UTC (Sat)
by Cyberax (✭ supporter ✭, #52523)
[Link]
Posted Apr 9, 2016 23:37 UTC (Sat)
by excors (subscriber, #95769)
[Link]
An RTOS designed for 8KB RAM is targeting a totally different scale, where you're counting in cents rather than dollars, or where you're battery-powered and are counting fractions of a milliwatt.
Posted Apr 9, 2016 22:30 UTC (Sat)
by cbaker (guest, #105649)
[Link]
Take this image for example:
And doubling the number of CPUs *means* doubling your profit.
And forget what the other people in this comment thread are saying about CPUs that cost only $1-2. The ultimate target of something like project Zephyr is CPUs that cost 1-2 *cents*. The sort of CPU you can put in a disposable greeting card.
Posted Apr 14, 2016 9:41 UTC (Thu)
by farnz (subscriber, #17727)
[Link]
Looking at ARM-based microcontrollers on Digikey, I can get an ARM Cortex-M0 with 16 KiB of Flash and 2 KiB of RAM at a unit price of 6.3p each. I have to more than double that price to 14.7p each to get a microcontroller with 256 KiB of Flash and 64 KiB of RAM, and I'm looking at 35.9p per IC for one with 1 MiB of Flash.
On top of that, in this space, you're looking for a single chip with enough I/O to do everything you want - the fewer support chips you need, the better. So, instead of choosing a high capacity external Flash chip (as your USB stick has done), and going for the cheapest discrete Flash that supports the use case, the MCU user picks the cheapest MCU that has as much of the things they need as possible integrated - if you can get away with one MCU talking SPI to a wireless module, that's a big saving compared to having to place down a wireless module, an MCU, a RAM chip, and a Flash chip.
Posted Apr 9, 2016 17:31 UTC (Sat)
by cjr (guest, #88606)
[Link]
A different product we make (that I don't maintain) contains 2 even smaller processors, one of them inside a component you wouldn't even imagine has a processor in it. A product that a friend works on uses these types of chips to perform PMIC and watchdog functions as part of a much more powerful board. These things are literally everywhere.
Not that we're going to try to use Zephyr on these, but I can definitely see the appeal.
[1] http://www.microchip.com/wwwproducts/en/PIC18F65J50
Posted Apr 10, 2016 9:06 UTC (Sun)
by remicardona (guest, #99141)
[Link] (4 responses)
So it's a *Linux* Foundation project that won't be able to cross-pollinate with Linux itself. On a technical level, that sounds like a lost opportunity, but I can't help but wonder why this choice was made. Am I reading too much into this?
Posted Apr 10, 2016 13:54 UTC (Sun)
by anselm (subscriber, #2796)
[Link] (3 responses)
We're told that for the sort of system envisioned here, the application is usually directly linked to the kernel. Under the popular theory promulgated by the likes of the FSF, that would make the application a “derived work” of the kernel, and bring it under the GPL. While that probably wouldn't be a problem as far as users of the devices in question is concerned, manufacturers won't be too keen on the idea, making GPL'ed Zephyr a non-starter.
It is unlikely that the Linux Foundation would want to spend money and effort on something device manufacturers (including possibly companies that fund the LF) don't have any use for, hence the – more palatable – Apache licence.
Posted Apr 11, 2016 8:13 UTC (Mon)
by robbe (guest, #16131)
[Link] (2 responses)
I don’t see this as a given. If I produce, say, an espresso machine, and want to make it WiFi-capable, would I really consider the small application that reports "water tank N % full, beans reservoir M % full" worthy of protection? Would my competitors gain valuable insight from reading its source code? Would copying it give them some advantage?
I suspect the answers are "not really" to both questions for a number of appliances. But maybe I am mistaken ... or enough companies are just paranoid about sharing their code.
I certainly can’t see the big security benefits if the OS gets patches, but not the bespoke application linked to it.
Posted Apr 11, 2016 8:43 UTC (Mon)
by anselm (subscriber, #2796)
[Link] (1 responses)
Your developers might not, but your lawyers might. Usually in a company, what the lawyers say carries more weight than what the developers say.
Posted Apr 11, 2016 15:53 UTC (Mon)
by flussence (guest, #85566)
[Link]
Why Zephyr?
Why Zephyr?
Why Zephyr?
Why Zephyr?
Why Zephyr?
Why Zephyr?
Why Zephyr?
Why Zephyr?
Why Zephyr?
Why Zephyr?
Why Zephyr? (because it isn't GPLed)
Why Zephyr? (because it isn't GPLed)
What is an example of something that has only 8K of memory? And would such a thing have any persistent memory?
Why Zephyr?
Why Zephyr?
I can see that some devices don't need more than 8K, but is it cheaper to make a sensor with 8K than with 8M? Consider that if I want a USB flash drive on which to store an 8M file, the smallest one I can buy is 8G. Wouldn't similar economics apply to sensors?
Why Zephyr?
Why Zephyr?
Still struggling to understand how it costs less to make a sensor with kilobytes of memory than to make one with megabytes. Are Chinese laborers constructing the bits one at a time? Do we have to mine the transistors?
Why Zephyr?
These sensors are usually built around single-chip microcontrollers (which often also include all of the digital parts of the sensor itself, so the components external to this chip are mostly passive parts like resistors, capacitors, and the like). Since these microcontrollers use a single piece of silicon to implement both logic and memory, they end up costing very little (often less than $1, in bulk). Unfortunately, dense memories require a different silicon process than processing components (low-power ones in particular), so the memories on such chips take up significantly more space than you would expect per bit of storage.
Why Zephyr?
Why Zephyr?
Why Zephyr?
Why Zephyr?
Apart from licensed IP cores (which are artificially expensive), memory is the single most expensive thing you can add to a piece of silicon. It just takes up so much space.
http://www.komtech.lt/images/text/upload/filtri/large_cac...
I pulled it from GIS somewhat randomly; I don't know what CPU it is for but it has the cache memory highlighted. I would guess that it has less than 1 MB of memory per core.
This CPU has an extraordinarily large amount of memory on it. It is completely mental -- they could have doubled the number of CPUs if they didn't have so much cache.
For a CPU to be that cheap, you have to be able to carve thousands (millions?) of them out of a single silicon wafer.
Why Zephyr?
Why Zephyr?
[2] http://www.microchip.com/wwwproducts/en/PIC16F688
Choice of Licence
Choice of Licence
Choice of Licence
Choice of Licence
If I produce, say, an espresso machine, and want to make it WiFi-capable, would I really consider the small application that reports "water tank N % full, beans reservoir M % full" worthy of protection?
Choice of Licence