Skip to main content
AnnouncementsBlog

Zephyr 4.0 Is Generally Available: Some Highlights

By November 16, 2024No Comments

The Zephyr community has been hard at work over the past four months, not really getting any rest after getting a new Long-Term Support release out the door in July. Today, I’m thrilled to announce the release of Zephyr 4.0!

It’s always interesting to see how, for each release, there’s always a couple of areas that go through a “sprint” and catch up on overdue refactoring and bug squashing, or that get a flurry of new features and improvements. This time around, storage and multimedia have been particularly active: a new secure storage subsystem brings PSA Secure Storage to all targets, ZMS (Zephyr Memory Storage) proposes a storage system optimized for next-gen memory technologies and, while Zephyr has had video & audio capabilities for quite some time, there’s been some really nice improvements on that front as well.

I always like to pair release announcement blog posts with a video that shows some of the most notable changes in action, and this time is no exception. You can watch it below, or read on for a more detailed description of the new features and improvements in Zephyr 4.0.

As you read through the article, clicking on the ▶️ symbol will directly take you to the section of the video that shows the feature in action.

Be sure to mark your calendars for our next Zephyr Tech Talk! We’ll be having a special episode next Wednesday, November 20th, where I will be joined by several contributors and maintainers to discuss the release and answer all your questions.

The merge window for Zephyr 4.1 will be open again in just a few days, and as always it will be amusing to look at the hundreds of commits landing in the repo as soon as we open the flood gates 🙂 Meanwhile, let’s look back at some of the cool things that landed in 4.0, shall we?

▶️ Secure Storage

The new Secure Storage subsystem provides an implementation of the Platform Security Architecture (PSA) Secure Storage API and enables data protection of non-volatile memory even for targets that don’t already provide an implementation of the API.

While it’s of course always going to be preferable to use a device that provides a secure processing environment (such as TF-M), as this provides better security in particular with regards to making data “secure at rest”,  this new subsystem allows developers to have a common API to interact with a secure storage, no matter their board target. The subsystem exposes multiple levels of customization of the ITS transform and store (ex. the settings subsystem can be used as a storage backend) modules through Kconfig options.

▶️ ZMS (Zephyr Memory Storage)

New solid-state, non-volatile, memory technologies such as RRAM (Resistive RAM) and MRAM (Magnetic RAM) work quite differently than your typical NOR flash. In particular, they don’t require for pages to be erased before being able to write new data.

Zephyr Memory Storage (ZMS) is a new key-value storage system designed to work with a wide variety of non-volatile storage technologies including those such as RRAM or MRAM that don’t require an erase-before-write. And for those devices that do require an erase, it implements an efficient wear-leveling algorithm that minimizes the number of operations required compared to alternatives such as NVS (Non-Volatile Storage).

The documentation of this new subsystem explain in lots of details how to make the most of it, and contains very useful tips and tricks to help you estimate actual space usage based on your data’s topology, or the expected lifetime of your memory chip based on the number of keys being written.

New driver classes

▶️ Haptics

An important aspect of a good human-machine interface is to provide feedback to the user. Haptic feedback is key to improving a user’s experience as it provides tactile feedback confirming that an action has been performed, or alerts them about something. Driving haptics motors typically requires dedicated hardware that is specifically designed to produce vibrations of varying intensity and frequency.

The new haptics device driver subsystem provides developers with a common API to interact with haptics controllers. The generic API allows to basically start/stop the vibrations, and additional control is possible through hardware-specific API. For example, the TI DRV2605 that’s currently supported has an internal bank of waveforms which one can “play” using the dedicated API. I recommend you check out the relevant code sample to familiarize yourself with this new API.

▶️ Analog Comparators

Analog comparators output a digital signal by comparing two voltage signals. It is useful in a variety of applications such as battery voltage monitoring, circuit protection, etc. The main advantage over a classic ADC is that an analog comparator does not require sampling/conversion, so it’s generally faster and consumes less power.

Zephyr 4.0 sees the introduction of a new analog comparator device driver API with already a couple drivers in-tree for Nordic and NXP comparators. A nice touch is the inclusion of a shell module that makes it even easier to check (poll) the value of the comparator or to visualize triggers in real-time. 

▶️ Stepper Motors

Be it for robotics, medical applications, 3D printers, CNC machines, or any other application that requires precise control of the angular position of a motor, stepper motors are pretty ubiquitous.

The new stepper motor driver class provides a generic interface to interact with stepper motors that allows developers to control the motor’s position, speed, etc. Basic control can be achieved through a simple GPIO-based driver and, as driving a stepper motor smoothly can actually be quite tricky, other drivers relying on dedicated ICs will be available. As of Zephyr 4.0, one such driver is available for the ADI/Trinamic TMC5041 and allows to benefit from more advanced features such as the ability to control the motor’s acceleration ramp for smooth motion. Oh, and this subsystem also comes with a shell, which is very convenient to quickly identify the rough limits of your motor before looking at maybe fine-tuning it.

▶️ Multimedia

Zephyr has had multimedia capabilities for quite some time, with support for digital microphones, I2S, video acquisition, … but I must say that these past 4 months have been really busy on that front, and a lot more hardware is now supported, especially in terms of video.

ESP32-S3’s LCD-CAM interface as well as NXP MCUX SMARTDMA are now supported, meaning that there’s quite a few new boards in the Zephyr tree that can now do video. If you add to that new image sensor drivers (ex. for GalaxyCore GC2145), improvements made to video buffer memory allocation (making it easier to e.g. rely on external RAM by just flipping a Kconfig option), I2S support for ESP32-S3 and ESP32-C3, new audio codecs being supported (Wolfson WM8904), it’s fair to say that Zephyr is now a much more capable platform for multimedia applications.

I wouldn’t be surprised to see the momentum continue in the next few months and, in fact, I already know that more is coming, like an implementation of the USB video device class (UVC)… hello Zephyr-powered webcams! 🙂

▶️ Documentation

This was covered in a recent “Weekly Update” so I won’t be repeating myself, but there really were lots of nice documentation improvements over the past few months which I hope will be making everyone’s life easier. You can see many of these improvements in action in the video—sometimes a live demo speaks louder than words!

▶️ Prometheus integration

Prometheus logo

Prometheus is a very popular open source solution for event monitoring and alerting. It is very popular in the cloud-native world and, as the line between “cloud” and “edge” continues to blur, Prometheus can be quite appropriate for monitoring embedded systems, such as edge gateways. Therefore, it was nice to see a contribution proposing to add a Prometheus library to Zephyr, making it easier for folks to expose custom metrics to Prometheus.

You may check out the dedicated code sample that will give you a good starting point should you want to expose Prometheus metrics from your application.

And more…

I could also mention the 60+ new boards supported in this release, the dozens of new sensors, and so much more… but it’s probably best for you to make sure you take some time to read the full release notes alongside the migration guide that’ll help you update your Zephyr 3.7 applications.

Another way for you to learn more will be to join us next week for a fireside chat with some of the Zephyr community members who worked on Zephyr 4.0.

If you enjoyed this article, don’t forget to subscribe to the Zephyr newsletter to receive insightful quarterly updates about all things Zephyr! You can also follow us on Twitter and LinkedIn.