The Zephyr OS is based on a small-footprint kernel designed for use on resource-constrained and embedded systems: from simple embedded environmental sensors and LED wearables to sophisticated embedded controllers, smart watches, and IoT wireless applications.
The Zephyr kernel supports multiple architectures, including ARM Cortex-M, Intel x86, ARC, NIOS II, Tensilica Xtensa and RISC-V 32. The full list of supported boards can be found here.
LicensingZephyr is permissively licensed using the Apache 2.0 license (as found in the LICENSE file in the project’s GitHub repo). There are some imported or reused components of the Zephyr project that use other licensing, as described in Licensing of Zephyr Project components.
目前已经支持的板子如下
x86 Boards
Arduino/Genuino 101
Galileo Gen1/Gen2
MinnowBoard Max
X86 Emulation (QEMU)
Quark D2000 Development Board
Quark SE C1000 Development Board
tinyTILE
UP Squared
Jailhouse cell X86 Emulation (QEMU)
ARM Boards
96Boards Argonkey
96Boards Carbon
96Boards Carbon nRF51
96Boards Neonkey
96Boards Nitrogen
96Boards STM32 Sensor Mezzanine
Adafruit Feather M0 Basic Proto
Adafruit Trinket M0
Arduino Due
Arduino/Genuino Zero
SAM D20 Xplained Pro Evaluation Kit
SAM D21 Xplained Pro Evaluation Kit
ST B-L072Z-LRWAN1 Discovery kit
BBC MicroBit
CC2650 SensorTag
CC3220SF LaunchXL
NXP i.MX 7 Computer on Module - Colibri iMX7
Curie (BLE)
PSoC6 WiFi-BT Pioneer Kit (CM0+ Core)
PSoC6 WiFi-BT Pioneer Kit (CM4 Core)
ST Disco L475 IOT01 (B-L475E-IOT01A)
Dragino LSN50 LoRA Sensor Node
EFM32HG-SLSTK3400A
EFM32 Pearl Gecko Starter Kit
EFM32WG-STK3800
EFR32-SLWSTK6061A
EFR32MG-SLTB004A
NXP FRDM-K64F
NXP FRDM-KL25Z
NXP FRDM-KW41Z
Hexiwear
Hexiwear KW40Z
NXP LPCXPRESSO54114
NXP MIMXRT1050-EVK
NXP MIMXRT1060-EVK
ARM V2M MPS2
MSP-EXP432P401R LaunchXL
Waveshare BLE400
Redbear Labs Nano
nRF51-PCA10028
nRF51-VBLUno51
nRF52810-PCA10040
nRF52832-mdk
nRF52840-mdk
nRF52840-PCA10056
nRF52840-PCA10059
nRF52 Adafruit Feather
Redbear Labs Nano v2
nRF52-PCA10040
nRF52-PCA20020 (Thingy:52)
nRF52-VBLUno52
ST Nucleo F030R8
ST Nucleo F070RB
ST Nucleo F091RC
ST Nucleo F103RB
ST Nucleo F207ZG
ST Nucleo F302R8
ST Nucleo F334R8
ST Nucleo F401RE
ST Nucleo F411RE
ST Nucleo F412ZG
ST Nucleo F413ZH
ST Nucleo F429ZI
ST Nucleo F446RE
ST Nucleo F746ZG
ST Nucleo F756ZG
ST Nucleo L053R8
ST Nucleo L073RZ
ST Nucleo L432KC
ST Nucleo L476RG
ST Nucleo L4R5ZI
OLIMEX-STM32-E407
OLIMEX-STM32-H407
OLIMEX-STM32-P405
OLIMEXINO-STM32
ARM Cortex-M3 Emulation (QEMU)
reel board
SAM4S Xplained
SAM E70 Xplained
STM3210C-EVAL
STM32373C-EVAL
STM32 Minimum Development Board
ST STM32F072-EVAL
ST STM32F072B-DISCO
ST STM32F0DISCOVERY
ST STM32F3DISCOVERY
STM32F411E-DISCO
ST STM32F412G Discovery
ST STM32F429I-DISC1 Discovery board
ST STM32F469I Discovery
ST STM32F4DISCOVERY
ST STM32F723E Discovery
ST STM32F746G Discovery
ST STM32F769I Discovery
ST STM32L476G Discovery
ST STM32L496G Discovery
UDOO Neo Full
NXP USB-KW24D512
ARM V2M Beetle
WaRP7 - Next Generation IoT and Wearable Development Platform
ARC Boards
Arduino/Genuino 101 (Sensor Subsystem)
DesignWare(R) ARC(R) EM Starter Kit
DesignWare(R) ARC(R) Emulation (nsim)
NIOS II Boards
Altera MAX10
Altera Nios-II Emulation (QEMU)
XTENSA Boards
ESP32
Intel S1000 CRB
Xtensa Emulation (QEMU)
Xtensa simulator
POSIX/NATIVE Boards
Native POSIX execution (native_posix)
NRF52 simulated board (BabbleSim)
RISCV32 Boards
SiFive HiFive1
Microsemi M2GL025 Mi-V
RISCV32 Emulation (QEMU)
Zedboard Pulpino
Shields
NXP FRDM-KW41Z
X-NUCLEO-IKS01A1: MEMS Inertial and Environmental Multi sensor shield
X-NUCLEO-IKS01A2: MEMS Inertial and Environmental Multi sensor shield
下面是它支持的一些特性
Extensive suite of Kernel services
Zephyr offers a number of familiar services for development:
Multi-threading Services for cooperative, priority-based, non-preemptive, and preemptive threads with optional round robin time-slicing. Includes POSIX pthreads compatible API support.
Interrupt Services for compile-time registration of interrupt handlers.
Memory Allocation Services for dynamic allocation and freeing of fixed-size or variable-size memory blocks.
Inter-thread Synchronization Services for binary semaphores, counting semaphores, and mutex semaphores.
Inter-thread Data Passing Services for basic message queues, enhanced message queues, and byte streams.
Power Management Services such as tickless idle and an advanced idling infrastructure.
Multiple Scheduling Algorithms
Zephyr provides a comprehensive set of thread scheduling choices:
Cooperative and Preemptive Scheduling
Earliest Deadline First (EDF)
Meta IRQ scheduling implementing “interrupt bottom half” or “tasklet” behavior
Timeslicing: Enables time slicing between preemptible threads of equal priority
Multiple queuing strategies:
Simple linked-list ready queue
Red/black tree ready queue
Traditional multi-queue ready queue
Highly configurable / Modular for flexibility
Allows an application to incorporate only the capabilities it needs as it needs them, and to specify their quantity and size.
Cross Architecture
Supports a wide variety of supported boards with different CPU architectures and developer tools. Contributions have added support for an increasing number of SoCs, platforms, and drivers.
Memory Protection
Implements configurable architecture-specific stack-overflow protection, kernel object and device driver permission tracking, and thread isolation with thread-level memory protection on x86, ARC, and ARM architectures, userspace, and memory domains.
For platforms without MMU/MPU and memory constrained devices, supports combining application-specific code with a custom kernel to create a monolithic image that gets loaded and executed on a system’s hardware. Both the application code and kernel code execute in a single shared address space.
Compile-time resource definition
Allows system resources to be defined at compile-time, which reduces code size and increases performance for resource-limited systems.
Optimized Device Driver Model
Provides a consistent device model for configuring the drivers that are part of the platform/system and a consistent model for initializing all the drivers configured into the system and Allows the reuse of drivers across platforms that have common devices/IP blocks
Device Tree Support
Use of Device Tree (DTS) to describe hardware and configuration information for boards. The DTS information will be used only during compile time. Information about the system is extracted from the compiled DTS and used to create the application image.
Native Networking Stack supporting multiple protocols
Networking support is fully featured and optimized, including LwM2M and BSD sockets compatible support. OpenThread support (on Nordic chipsets) is also provided - a mesh network designed to securely and reliably connect hundreds of products around the home.
Bluetooth Low Energy 5.0 support
Bluetooth 5.0 compliant (ESR10) and Bluetooth Low Energy Controller support (LE Link Layer). Includes BLE Mesh and a Bluetooth qualification-ready BLE controller.
Generic Access Profile (GAP) with all possible LE roles.
GATT (Generic Attribute Profile)
Pairing support, including the Secure Connections feature from Bluetooth 4.2
Clean HCI driver abstraction
Raw HCI interface to run Zephyr as a Controller instead of a full Host stack
Verified with multiple popular controllers
Highly configurable
Mesh Support:
Relay, Friend Node, Low-Power Node (LPN) and GATT Proxy features
Both Provisioning bearers supported (PB-ADV & PB-GATT)
Highly configurable, fitting in devices with at least 16k RAM
Native Linux, macOS, and Windows Development
A command-line CMake build environment runs on popular developer OS systems. A native POSIX port, lets you build and run Zephyr as a native application on Linux and other OSes, aiding development and testing.
Virtual File System Interface with NFFS and FATFS Support
Newtron Flash Filesystem (NFFS) and FATFS Support, FCB (Flash Circular Buffer) for memory constrained applications, and file system enhancements for logging and configuration.
Powerful multi-backend logging Framework
Support for log filtering, object dumping, panic mode, multiple backends (memory, networking, filesystem, console, …) and integration with the shell subsystem.
User friendly and full-featured Shell interface
A multi-instance shell subsystem with user-friendly features such as autocompletion, wildcards, coloring, metakeys (arrows, backspace, ctrl+u, etc.) and history. Support for static commands and dynamic sub-commands.
Settings on non-volatile storage
The settings subsystem gives modules a way to store persistent per-device configuration and runtime state. Settings items are stored as key-value pair strings.
Non-volatile storage (NVS)
NVS allows storage of binary blobs, strings, integers, longs, and any combination of these.
Native POSIX port
Supports running Zephyr as a Linux application with support for various subsystems and networking.
这个项目是linux基金会发起的,看起来他们是认真的。说了这么多,我们一起看看怎么配置开发编译环境,以及编译一个简单的helloworld来验证一下。
zephyr支持多种操作系统:linux, macos, windows。zephyr同样也支持多种linux桌面系统,包括Ubuntu 16.04 LTS or 18.04 LTS 64-bit,Fedora 28 64-bit,Clear Linux,Arch Linux。我这里介绍一下怎么在Ubuntu 16.04 LTS下安装开发环境。
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install --no-install-recommends git cmake ninja-build gperf ccache dfu-util device-tree-compiler wget python3-pip python3-setuptools python3-wheel xz-utils file make gcc gcc-multilib
下载sdk文件
wget https://github.com/zephyrproject-rtos/meta-zephyr-sdk/releases/download/0.9.5/zephyr-sdk-0.9.5-setup.run
安装sdk,默认安装目录是 /opt/zephyr-sdk/
sh zephyr-sdk-0.9.5-setup.run
把sdk配置到环境变量中去,这里的是指运行sh zephyr-sdk-0.9.5-setup.run指令时,sdk的安装目录,默认是/opt/zephyr-sdk/。这里建议把下面两行指令添加到/etc/profile中去,避免每一开机都需要重新输入这两行指令。假如你把这两行指令添加到/etc/profile,记得source /etc/profile,让其立刻生效。
export ZEPHYR_TOOLCHAIN_VARIANT=zephyr
export ZEPHYR_SDK_INSTALL_DIR=/opt/zephyr-sdk/
git clone https://github.com/zephyrproject-rtos/zephyr
pip3 install --user -r zephyr/scripts/requirements.txt
进入源码目录zephyr下,运行
source zephyr-env.sh
进入helloworld的源码目录下
cd samples/hello_world
mkdir build && cd build
编译在x86平台上运行的helloworld
cmake -GNinja -DBOARD=qemu_x86 ..
运行
ninja
ninja run
按 Ctrl-a, 然后 x.退出