Zephyr -- Device Tree

Introduction to devicetree All Zephyr and application source code files can include and use devicetree.h. This includes device drivers, applications, tests, the kernel, etc. i2c从设备的reg地址是i2c slave address. spi从设备的reg地址是chip select. Writing property values devicetree_unfixed.h, devicetree_fixups.h: deivcetree编译出来的一些宏供C使用。 zephyr3.5只有devicetree_generated.h Devicetree bindings Binding文件用来规范设备树每个节点的表达。 The build system uses bindings to generate C macros for devicetree properties that appear in DTS files. 如果binding文件中没有列出来,不会生成C宏。 语法参考 # A high level description of the device the binding applies to: description: | This is the Vendomatic company's foo-device....

2023-12-08 · 3 min

Zephyr -- Test Framework

Testing Creating a test suite ZTEST_SUITE /** * Create and register a ztest suite. Using this macro creates a new test suite (using * ztest_test_suite). It then creates a struct ztest_suite_node in a specific linker section. * * Tests can then be run by calling ztest_run_test_suites(const void *state) by passing * in the current state. See the documentation for ztest_run_test_suites for more info. * * @param SUITE_NAME The name of the suite (see ztest_test_suite for more info) * @param PREDICATE A function to test against the state and determine if the test should run....

2023-11-30 · 2 min

Zephyr -- West

West Workspace concepts configuration file .west/config 配置文件,定义了manifest repository等。 manifest file west.yml 描述了管理的其他git仓库。可以用manifest.file覆盖。执行west update可以更新所有git仓库。 Built-in commands west help: 查看支持的命令。 west <command> -h: for detailed help. west update -r: sync的时候会rebase local commits. west compare: compare the state of the workspace against the manifest. west diff west status west forall -c <command>: 对所有仓库执行某个shell命令。 west grep west list: 所有project信息。 west manifest: 管理manifest文件。 Workspaces Topologies supported star topology, zephyr is the manifest repository star topology, a Zephyr application is the manifest repository forest topology, freestanding manifest repository West Manifests West Manifests yaml文件...

2023-11-30 · 1 min

Zephyr -- Developing with Zephyr

Getting Started Guide 设置Python虚拟环境 python3 -m venv ~/zephyrproject/.venv source ~/zephyrproject/.venv/bin/activate deactive 退出虚拟环境。 Remember to activate the virtual environment every time you start working. Build the Blinky sample cd ~/zephyrproject/zephyr west build -p always -b <your_board_name> sample/basic/blinky -p always表示a pristine build,也可以使用-p auto来自动判断是否需要pristine build. Environment Variables 创建zephyr专属的环境变量,touch ~/.zephyrrc, 加入export MY_VARIABLE=foo。 接着进入zephyr repository,执行source zephyr-env.sh source zephyr-env.sh: set ZEPHYR_BASE 为zephyr repository(内核目录). 增加一些环境变量到系统PATH. load .zephyrrc 中的配置. Application Development app目录的结构通常为: <app> ├── CMakeLists.txt ├── app.overlay ├── prj....

2023-11-30 · 2 min

Zephyr -- Device Drvier Model

struct device { const char *name; const void *config; const void *api; void * const data; }; config: 放地址映射,中断号等一些物理信息。 api: 回调函数。 data: 放reference counts, semaphores, scratch buffers等。 Device-Specific API Extensions 标准driver api没法实现的功能。 Single Driver, Multiple Instances 某个driver对应多个instances的情况,比如uart driver匹配uart0, uart1, 并且中断线不是同一个。

2023-11-30 · 1 min