基于Zephyr RTOS的嵌入式软件开发实践
Embedded Software Development Practice with Zephyr RTOS
DOI: 10.12677/etis.2025.22006, PDF,   
作者: 何灵渊:博通公司,森尼韦尔 美国;何小庆:嵌入式系统联谊会,北京
关键词: 嵌入式系统软件开发实时操作系统Zephyr项目Embedded System Software Development Real-Time Operating System Zephyr Project
摘要: Zephyr开源项目由Linux基金会维护,是一个针对资源受限的嵌入式设备优化的小型、可缩放、多体系结构实时操作系统(RTOS)。近年来,Zephyr RTOS在嵌入式开发中的采用度逐步增加,支持的开发板和传感器不断增加,其广泛的设备支持和高度的可扩展性吸引了开发者的关注。相比FreeRTOS等小型RTOS而言,教育生态不够成熟的Zephyr系统规模更大,结构更复杂,这提高了开发者入门和精通的门槛。文章对Zephyr硬件抽象层和设备驱动的架构与实现进行系统性分析,重点阐述了设备驱动模型和设备树的作用。为了展示基于Zephyr的嵌入式软件开发,文章在BBC micro:bit V2开源硬件上构建样例Zephyr设备驱动和应用程序,并做解释和验证。
Abstract: Zephyr, an open-source initiative managed by the Linux Foundation, is a small, scalable, multi architecture Real-time Operating System (RTOS) optimized for resource-constrained embedded systems. In recent years, the adoption rate of Zephyr RTOS has increased significantly. The range of supported boards and sensors continues to rise. Developers are increasingly interested in Zephyr because of its board device support and scalability. Compared to a minimum RTOS like FreeRTOS, Zephyr, whose education infrastructure has not yet matured, has a larger scale and a more complex architecture. This means Zephyr’s learning curve for a developer is steep. This paper systematically describes the architecture and implementation of Zephyr’s hardware abstraction and device driver, especially its device driver model and its usage of the device tree. It also demonstrates embedded software development with Zephyr by building, analyzing, and verifying a custom driver and an example application based on the BBC micro:bit V2 open-source hardware.
文章引用:何灵渊, 何小庆. 基于Zephyr RTOS的嵌入式软件开发实践[J]. 嵌入式技术与智能系统, 2025, 2(2): 59-77. https://doi.org/10.12677/etis.2025.22006

参考文献

[1] Zephyr Project (2025) About the Zephyr Project.
https://zephyrproject.org/learn-about/
[2] Eclipse Foundation (2024) 2024 IoT & Embedded Developer Survey Report.
https://outreach.eclipse.foundation/iot-embedded-developer-survey-2024
[3] 王洪波. 嵌入式虚拟化技术与应用: ACRN开源项目实践[M]. 北京: 机械工业出版社, 2023.
[4] Zephyr Project (2024) Zephyr Project Overview.
https://www.zephyrproject.org/wp-content/uploads/2024/10/Zephyr-Overview-20241017.pdf
[5] Zephyr Project (2025) Device Driver Model.
https://docs.zephyrproject.org/latest/kernel/drivers/index.html
[6] The Devicetree Organization (2023) Devicetree Specification, Release v0.4.
https://github.com/devicetree-org/devicetree-specification/releases/download/v0.4/devicetree-specification-v0.4.pdf
[7] Zephyr Project (2025) Devicetree.
https://docs.zephyrproject.org/latest/build/dts/index.html
[8] Zephyr Project (2025) Scope and Purpose.
https://docs.zephyrproject.org/latest/build/dts/intro-scope-purpose.html
[9] Zephyr Project (2025) Syntax and Structure.
https://docs.zephyrproject.org/latest/build/dts/intro-syntax-structure.html
[10] Zephyr Project (2025) Devicetree Bindings.
https://docs.zephyrproject.org/latest/build/dts/bindings.html
[11] Lampacher, M. (2025) Practical Zephyr Git Repository.
https://github.com/lmapii/practical-zephyr/tree/main/03_devicetree_semantics
[12] Eliasz, A. (2024) Zephyr RTOS Embedded C Programming. Apress Berkeley.
[13] Lampacher, M. (2024) Practical Zephyr-Kconfig (Part 2).
https://interrupt.memfault.com/blog/practical_zephyr_kconfig
[14] The Micro:Bit Organization (2025) Meet the New BBC Micro:Bit.
https://microbit.org/new-microbit/
[15] Gammell, C. (2024) Zephyr for Hardware Engineers: GPIO.
https://blog.golioth.io/zephyr-for-hardware-engineers-gpio/
[16] Valens, C. (2024) Getting Started with the Zephyr RTOS. Elektor, 2, 98-105.
[17] The Micro:Bit Organization (2025) Micro:Bit Pins.
https://makecode.microbit.org/device/pins
[18] Zephyr Project (2025) Example Application Git Repository.
https://github.com/zephyrproject-rtos/example-application/tree/main
[19] Zephyr Project (2025) Devicetree HOWTOs.
https://docs.zephyrproject.org/latest/build/dts/howtos.html
[20] Zephyr Project (2021) Zephyr and the BBC Microbit V2 Tutorial Part 1: GPIO.
https://www.zephyrproject.org/zephyr-and-the-bbc-microbit-v2-tutorial-part-1-gpio/
[21] Lampacher, M. (2024) Practical Zephyr-Devicetree Semantics (Part 4).
https://interrupt.memfault.com/blog/practical_zephyr_dt_semantics
[22] Szczys, M. (2024) How to Write a Zephyr Device Driver with a Custom API.
https://blog.golioth.io/how-to-write-a-zephyr-device-driver-with-a-custom-api/
[23] Nordic Semiconductor (2025) GPIO Generic API.
https://academy.nordicsemi.com/courses/nrf-connect-sdk-fundamentals/lessons/lesson-2-reading-buttons-and-controlling-leds/topic/gpio-generic-api/
[24] Lampacher, M. (2024) Practical Zephyr-Devicetree Practice (Part 5).
https://interrupt.memfault.com/blog/practical_zephyr_05_dt_practice
[25] Zephyr Project (2025) Building, Flashing and Debugging.
https://docs.zephyrproject.org/latest/develop/west/build-flash-debug.html