zephyr
Primary Git Repository for the Zephyr Project. Zephyr is a new generation, scalable, optimized, secure RTOS for multiple hardware architectures.
Top Related Projects
Arm Mbed OS is a platform operating system designed for the internet of things
'Classic' FreeRTOS distribution. Started as Git clone of FreeRTOS SourceForge SVN repo. Submodules the kernel.
RIOT - The friendly OS for IoT
Contiki-NG: The OS for Next Generation IoT Devices
Quick Overview
Zephyr is an open-source, real-time operating system (RTOS) designed for resource-constrained devices, particularly in the Internet of Things (IoT) space. It supports multiple architectures and provides a robust, scalable platform for embedded systems development.
Pros
- Wide hardware support, including various architectures and boards
- Modular and highly configurable, allowing for optimized resource usage
- Strong focus on security, with features like memory protection and secure boot
- Active community and commercial backing from the Linux Foundation
Cons
- Steeper learning curve compared to some simpler embedded development platforms
- Documentation can be overwhelming for beginners due to the project's extensive features
- Some users report occasional issues with stability in certain configurations
- Limited support for some advanced networking protocols compared to more specialized IoT platforms
Code Examples
- Basic "Hello World" application:
#include <zephyr/kernel.h>
void main(void)
{
printk("Hello World! %s\n", CONFIG_BOARD);
}
- Creating and using a thread:
#include <zephyr/kernel.h>
#define STACK_SIZE 1024
#define THREAD_PRIORITY 7
void thread_entry(void *p1, void *p2, void *p3)
{
while (1) {
printk("Thread running\n");
k_msleep(1000);
}
}
K_THREAD_DEFINE(my_thread, STACK_SIZE, thread_entry, NULL, NULL, NULL,
THREAD_PRIORITY, 0, 0);
- Using a semaphore for synchronization:
#include <zephyr/kernel.h>
K_SEM_DEFINE(my_sem, 0, 1);
void producer_thread(void *p1, void *p2, void *p3)
{
while (1) {
// Do some work
k_sem_give(&my_sem);
k_msleep(1000);
}
}
void consumer_thread(void *p1, void *p2, void *p3)
{
while (1) {
k_sem_take(&my_sem, K_FOREVER);
printk("Semaphore acquired\n");
}
}
Getting Started
-
Install Zephyr SDK and dependencies:
wget https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.15.2/zephyr-sdk-0.15.2_linux-x86_64.tar.gz tar xvf zephyr-sdk-0.15.2_linux-x86_64.tar.gz cd zephyr-sdk-0.15.2 ./setup.sh
-
Set up Zephyr workspace:
west init zephyrproject cd zephyrproject west update
-
Build and flash a sample application:
cd zephyr/samples/basic/blinky west build -b <your_board> west flash
Replace <your_board>
with your target board name (e.g., qemu_x86
for QEMU emulation).
Competitor Comparisons
Arm Mbed OS is a platform operating system designed for the internet of things
Pros of mbed-os
- Extensive hardware support for ARM-based microcontrollers
- Comprehensive libraries and APIs for rapid development
- Strong focus on security features and connectivity options
Cons of mbed-os
- Limited support for non-ARM architectures
- Steeper learning curve for beginners compared to Zephyr
- Less flexible configuration options for advanced users
Code Comparison
mbed-os example:
#include "mbed.h"
DigitalOut led(LED1);
int main() {
while (1) {
led = !led;
ThisThread::sleep_for(500ms);
}
}
Zephyr example:
#include <zephyr/kernel.h>
#include <zephyr/drivers/gpio.h>
#define LED0_NODE DT_ALIAS(led0)
static const struct gpio_dt_spec led = GPIO_DT_SPEC_GET(LED0_NODE, gpios);
int main(void) {
gpio_pin_configure_dt(&led, GPIO_OUTPUT_ACTIVE);
while (1) {
gpio_pin_toggle_dt(&led);
k_msleep(500);
}
}
Both examples demonstrate LED blinking, but Zephyr uses a more hardware-abstracted approach with Device Tree support, while mbed-os provides a simpler, more intuitive API for common tasks.
'Classic' FreeRTOS distribution. Started as Git clone of FreeRTOS SourceForge SVN repo. Submodules the kernel.
Pros of FreeRTOS
- Simpler and more lightweight, making it suitable for resource-constrained devices
- Extensive documentation and community support
- Widely adopted in the industry, with a large ecosystem of compatible tools and libraries
Cons of FreeRTOS
- Limited built-in features compared to Zephyr's comprehensive set of functionalities
- Less focus on standardization and portability across different hardware platforms
- Fewer networking and security features out-of-the-box
Code Comparison
FreeRTOS task creation:
void vTaskFunction(void *pvParameters) {
for (;;) {
// Task code here
}
}
xTaskCreate(vTaskFunction, "Task1", configMINIMAL_STACK_SIZE, NULL, 1, NULL);
Zephyr thread creation:
void thread_entry(void *p1, void *p2, void *p3) {
while (1) {
// Thread code here
}
}
K_THREAD_DEFINE(thread_id, STACK_SIZE, thread_entry, NULL, NULL, NULL, PRIORITY, 0, 0);
Both FreeRTOS and Zephyr provide similar basic RTOS functionalities, but Zephyr offers a more comprehensive set of features and better standardization across different hardware platforms. FreeRTOS, being lighter and simpler, may be preferred for projects with limited resources or when extensive customization is required.
RIOT - The friendly OS for IoT
Pros of RIOT
- More lightweight and suitable for resource-constrained devices
- Broader support for microcontroller architectures
- Stronger focus on IoT and low-power applications
Cons of RIOT
- Smaller community and ecosystem compared to Zephyr
- Less extensive documentation and tutorials
- Fewer advanced features for complex embedded systems
Code Comparison
RIOT example (main.c):
#include <stdio.h>
int main(void)
{
puts("Hello World!");
return 0;
}
Zephyr example (main.c):
#include <zephyr/kernel.h>
#include <zephyr/sys/printk.h>
void main(void)
{
printk("Hello World!\n");
}
Both RIOT and Zephyr are open-source real-time operating systems for embedded devices. RIOT is more focused on IoT and low-power applications, while Zephyr offers a broader range of features for various embedded systems. RIOT's lightweight nature makes it suitable for highly constrained devices, but Zephyr's larger community and more extensive documentation may be advantageous for some developers. The code examples show similar simplicity in basic applications, with minor differences in include statements and printing functions.
Contiki-NG: The OS for Next Generation IoT Devices
Pros of Contiki-NG
- Lightweight and efficient, ideal for resource-constrained IoT devices
- Strong focus on IPv6 and 6LoWPAN networking protocols
- Extensive simulation support through Cooja simulator
Cons of Contiki-NG
- Limited hardware support compared to Zephyr
- Smaller community and ecosystem
- Less frequent updates and releases
Code Comparison
Contiki-NG (main.c):
#include "contiki.h"
#include "net/netstack.h"
#include "net/ipv6/simple-udp.h"
PROCESS(example_process, "Example Process");
AUTOSTART_PROCESSES(&example_process);
PROCESS_THREAD(example_process, ev, data) {
PROCESS_BEGIN();
// Process logic here
PROCESS_END();
}
Zephyr (main.c):
#include <zephyr/kernel.h>
#include <zephyr/net/socket.h>
void main(void) {
// Application logic here
}
Contiki-NG uses a process-based programming model, while Zephyr follows a more traditional RTOS approach. Contiki-NG's code structure is centered around processes, whereas Zephyr uses a main function and supports multiple threads. Zephyr's networking stack is more flexible, supporting various protocols beyond just IPv6.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
.. raw:: html
The Zephyr Project is a scalable real-time operating system (RTOS) supporting multiple hardware architectures, optimized for resource constrained devices, and built with security in mind.
The Zephyr OS is based on a small-footprint kernel designed for use on resource-constrained systems: from simple embedded environmental sensors and LED wearables to sophisticated smart watches and IoT wireless gateways.
The Zephyr kernel supports multiple architectures, including ARM (Cortex-A,
Cortex-R, Cortex-M), Intel x86, ARC, Nios II, Tensilica Xtensa, and RISC-V,
SPARC, MIPS, and a large number of supported boards
_.
.. below included in doc/introduction/introduction.rst
Getting Started
Welcome to Zephyr! See the Introduction to Zephyr
_ for a high-level overview,
and the documentation's Getting Started Guide
_ to start developing.
.. start_include_here
Community Support
Community support is provided via mailing lists and Discord; see the Resources below for details.
.. _project-resources:
Resources
Here's a quick summary of resources to help you find your way around:
Getting Started
| ð Zephyr Documentation
_
| ð Getting Started Guide
_
| ðð½ Tips when asking for help
_
| ð» Code samples
_
Code and Development
| ð Source Code Repository
_
| ð¦ Releases
_
| ð¤ Contribution Guide
_
Community and Support
| ð¬ Discord Server
_ for real-time community discussions
| ð§ User mailing list (users@lists.zephyrproject.org)
_
| ð§ Developer mailing list (devel@lists.zephyrproject.org)
_
| ð¬ Other project mailing lists
_
| ð Project Wiki
_
Issue Tracking and Security
| ð GitHub Issues
_
| ð Security documentation
_
| ð¡ï¸ Security Advisories Repository
_
| â ï¸ Report security vulnerabilities at vulnerabilities@zephyrproject.org
Additional Resources
| ð Zephyr Project Website
_
| ðº Zephyr Tech Talks
_
.. _Zephyr Project Website: https://www.zephyrproject.org .. _Discord Server: https://chat.zephyrproject.org .. _supported boards: https://docs.zephyrproject.org/latest/boards/index.html .. _Zephyr Documentation: https://docs.zephyrproject.org .. _Introduction to Zephyr: https://docs.zephyrproject.org/latest/introduction/index.html .. _Getting Started Guide: https://docs.zephyrproject.org/latest/develop/getting_started/index.html .. _Contribution Guide: https://docs.zephyrproject.org/latest/contribute/index.html .. _Source Code Repository: https://github.com/zephyrproject-rtos/zephyr .. _GitHub Issues: https://github.com/zephyrproject-rtos/zephyr/issues .. _Releases: https://github.com/zephyrproject-rtos/zephyr/releases .. _Project Wiki: https://github.com/zephyrproject-rtos/zephyr/wiki .. _User mailing list (users@lists.zephyrproject.org): https://lists.zephyrproject.org/g/users .. _Developer mailing list (devel@lists.zephyrproject.org): https://lists.zephyrproject.org/g/devel .. _Other project mailing lists: https://lists.zephyrproject.org/g/main/subgroups .. _Code samples: https://docs.zephyrproject.org/latest/samples/index.html .. _Security documentation: https://docs.zephyrproject.org/latest/security/index.html .. _Security Advisories Repository: https://github.com/zephyrproject-rtos/zephyr/security .. _Tips when asking for help: https://docs.zephyrproject.org/latest/develop/getting_started/index.html#asking-for-help .. _Zephyr Tech Talks: https://www.zephyrproject.org/tech-talks
Top Related Projects
Arm Mbed OS is a platform operating system designed for the internet of things
'Classic' FreeRTOS distribution. Started as Git clone of FreeRTOS SourceForge SVN repo. Submodules the kernel.
RIOT - The friendly OS for IoT
Contiki-NG: The OS for Next Generation IoT Devices
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot