zehpyr 搭建开发环境遇到的一些问题

问题一: west build指令提示不支持build 操作

问题描述如下:

 解决:

官网描述参考: https://docs.zephyrproject.org/latest/guides/west/troubleshooting.html

根据官网描述,build、flash等指令属于扩展指令,这些扩展指令必须在west workspace中

有两种解决方法:

  1. Run the command from inside a workspace (e.g. the zephyrproject directory you created when you got started).

    For example, create your build directory inside the workspace, or run west flash --build-dir YOUR_BUILD_DIR from inside the workspace.  运行时指定通过 --build-dir 指定workspace

  2. Set the ZEPHYR_BASE environment variable and re-run the west extension command. If set, west will use ZEPHYR_BASE to find your workspace.  使用环境变量ZEPHYR_BASE  指定workspace

然而,按照官网的方法,依旧没有解决,还是依旧找不到build 等,然后看到一篇博文

《west命令详解:build 》   http://www.sunyouqun.com/2020/04/west-cmd-build/

west build命令怎么就变成了cmake命令呢?

west在运行时会根据当前路径向上寻找.west文件夹,.west\config文件记录了zephyr文件夹的路径,然后读取zephyr\west.yml

打开west.yml,关注最后几行:

  self:
    path: zephyr
    west-commands: scripts/west-commands.yml

它指向了west扩展命令清单的路径:scripts/west-commands.yml; 

找到问题了: 我没有使用官方的west init 而是下载好release zephyr版本,解压后,使用west init -l 使用本地版本。

所以,我的SDK的文件夹名是“zephyr-2.2.0-rc3”, 而不是“zephyr”

所以只需要改west.yml 最后几行改为

  self:
    path: zephyr-2.2.0-rc3
    west-commands: scripts/west-commands.yml

就可以了

问题二:某些模块的头文件找不到

描述:例如运行hello_world samples程序时,执行下列指令

cd samples/hello_world
mkdir build && cd build
cmake -GNinja -DBOARD=nrf52_pca10040 ..    #构建编译
ninja                                                                     #执行编译

执行 ninja 构建编译时,会报 类似 nrfx.h 头文件找不到的问题,打开工程也确实找不到;

原因:开发板的HAL和一些lib是通过module的形式集成到zephyr中的,即zephyr源码中未包含这部分内容,需要使用west update这样的命令进行安装,我在windows中下载实际体验也是非常的慢。

解决:

  进入zephyr 工程根目录,执行 west init -l   

  然后, west update 更新开发板的HAL和lib,  更新的内容由根目录下的west.yaml 文件定义的,当然也可以根据项目需要,只更新需要的模块

问题3 west init出现FATAL ERROR: already initialized in xxx问题

C:\Users\Administrator\zephyr_project>west init -l
FATAL ERROR: already initialized in C:\Users\Administrator, aborting.

分析原因: 原来的west workspace 在C:\Users\Administrator, 现在把workspace 设置到C:\Users\Administrator\zephyr_project,原来的west init信息依旧存在

解决:删掉原来workspace 目录下的.west文件夹,进入到zephyr SDK 重新进行west init

C:\Users\Administrator\zephyr_project>cd zephyr-2.2.0-rc3

C:\Users\Administrator\zephyr_project\zephyr-2.2.0-rc3>west init -l
=== Initializing from existing manifest repository zephyr-2.2.0-rc3
--- Creating c:\users\administrator\zephyr_project\.west and local configuration file
=== Initialized. Now run "west update" inside c:\users\administrator\zephyr_project.

猜你喜欢

转载自blog.csdn.net/wangzhiqin365/article/details/107175011