简洁清晰的代码结构有利于项目代码的管理,zephyr的west工具对多仓库代码文件提供了多种拓扑结构管理方式。west对多仓库的管理基本概念可以参考zephyr west简介中”提货单简介”章节,本文主要讨论单一应用的提货单使用方法。
zephyr代码工作空间的拓扑结构
west支持的代码拓扑结构有三种
t1: 星型结构,manifest 在zephyr中
t2: 星型结构,manifest 在app中, 适用于单独应用管理
t3: 树型结构,专门的manifest目录, 适用于多应用管理
t1
zephyr仓库作为中央存储库,并在它的west.yml 中指定其模块(外部项目), app可以放到任意目录。这种形式在不修改west.yml的情况下会下载所有的外部module,适合于zephyr本身的开发。
类似于以zephyr为主项目,其它为git子模块,这是zephyr getting started示例使用的目录结构,这里就不再举例说明
t2
应用程序的仓库充当中央存储库,并在它的west.yml中指定要使用的模块(zephyr和其它外部项目)。该方式适合于单个独立的zephyr应用的开发。
类似于以zephyr应用为主项目,其它(包括zephyr)为git子模块,后文会详细说明该方式的使用,这里不做举例。
t3
不包含 zephyr 源代码的专用”提货单”存储库,指定所有处于同一“级别”的项目列表,适合于多个相互独立的zephyr应用开发。
类似于google的repo管理,示例如下
工作空间的代码结构
west-workspace/
├── app1/ # .git/ project
│ ├── cmakelists.txt
│ ├── prj.conf
│ └── src/
│ └── main.c
├── app2/ # .git/ project
│ ├── cmakelists.txt
│ ├── prj.conf
│ └── src/
│ └── main.c
├── manifest-repo/ # .git/ never modified by west
│ └── west.yml # main manifest with optional import(s) and override(s)
├── modules/
│ └── lib/
│ └── tinycbor/ # .git/ project from either the main manifest or
│ # from some import
│
└── zephyr/ # .git/ project
└── west.yml # this can be partially imported with lower precedence or ignored.
# only the ‘manifest-rev’ version can be imported.
对应的提货单应该放在manifest-repo/west.yml
manifest:
remotes:
- name: zephyrproject-rtos
url-base: https://github.com/zephyrproject-rtos
- name: your-git-server
url-base: https://git.example.com/your-company
defaults:
remote: your-git-server
projects:
- name: zephyr
remote: zephyrproject-rtos
revision: v2.5.0
import: true
- name: app1
revision: some_sha_or_branch_or_tag
- name: app2
revision: another_sha_or_branch_or_tag
self:
path: manifest-repo
单一应用west提货单
我的个人项目只有单应用,因此采用t1或者t2结构都可以。我希望应用仓库里面只有单纯和应用相关的代码,同时又能够通过应用仓库拿到zephyr代码和必要的外部项目代码,这一点t2就非常合适了。
应用仓库的代码拓扑结构如下
app
├── cmakelists.txt
├── boards
├── drivers
├── dts
├── prj.conf
├── scripts
├── src
└── west.yml
west.yaml内容如下
manifest:
remotes:
- name: zephyrproject-rtos
url-base: https://github.com/zephyrproject-rtos
projects:
- name: zephyr
remote: zephyrproject-rtos
revision: zephyr-v2.6.0
clone-depth: 1
import:
name-allowlist:
- cmsis
- hal_nxp
- hal_espressif
- fatfs
- lvgl
self:
west-commands: scripts/west-commands.yml
执行下面命令west init -l app/就会按照west.yaml指定的内容下载zephyr和zephyr外部项目的代码,该west.yaml要下载的内容:
zephyr的源代码:指定下载v2.6.0 tag的
cmsis: 使用cortex-m7,需要cmsis
hal_nxp: 应用会跑到rt1052上因此需要nxp hal
hal_espressif: 应用会跑到esp32上因此需要espressif hal
fatfs:应用使用了文件系统
lvgl:应用使用了gui
除以上内容外,不会再下载其它内容,这样大大缩减了t1模式下载代码的时间和占用的空间
├── license
├── readme.en.md
├── readme.md
├── app
│ ├── cmakelists.txt
│ ├── boards
│ ├── drivers
│ ├── dts
│ ├── prj.conf
│ ├── scripts
│ ├── src
│ └── west.yml
├── modules
│ ├── fs
│ ├── hal
│ └── lib
└── zephyr
参考
https://docs.zephyrproject.org/latest/guides/west/workspaces.html#topologies-supported
开空调会影响纯电动汽车的续航里程吗
维诺信建设合肥6代柔性产线,小米折叠机预计明年第二季度推出
VR技术应用在行业的看房实践中,VR看房问题的解决之道是什么?
基于Paragraf石墨烯的霍尔效应传感器的应用
号称铃木“史上最美”车型的铃木Authentics,是否会放弃中国市场?
West提货单单一应用的提货单使用方法
Vishay推出新款汽车级高压薄膜扁平片式电阻器,扩充其TNPV e3系列
基于宽带巴伦设计的3GHz至20GHz高性能集成混频器
东大金智科技10GBASE-SR/SW 400m|SFP+|FTLX8574D3BCL特征英文版
双面电路板需要的工艺
电气电缆的最全常用手册详细说明
选择扬尘监测系统/扬尘检测仪时的注意细节
如何设置Raspberry Pi 3
基于工频变压器的独立逆变电源设计
滚柱导轨精度等级是如何划分?
四维智联打造车联网“软硬一体化+定制化输出+后台服务”生态圈
5G将成为社会数字化转型的重要基础设施
七孔2开插座的接线方法
全球城市复原力支出在2024年达到3350亿美元
识读电气图的基本要求