做电影网站挣钱,门户网站建设进展情况,网页传奇游戏推广员,东莞有多少个镇简介
国内小伙伴在学习zephyr的时候#xff0c;有以下几个痛点#xff1a;
学习门槛过高github访问不畅#xff0c;下载起来比较费劲。
这篇文章将我自己踩的坑介绍一下#xff0c;顺便给大家优化一些地方#xff0c;避免掉所有的坑。
首先用virtualbox 来安装一个ubu…简介
国内小伙伴在学习zephyr的时候有以下几个痛点
学习门槛过高github访问不畅下载起来比较费劲。
这篇文章将我自己踩的坑介绍一下顺便给大家优化一些地方避免掉所有的坑。
首先用virtualbox 来安装一个ubuntu22.04
本文适应的是ubuntu的操作系统
github访问不畅的问题
github.com 有时候无法访问这边有个非常好用的办法执行下面两个命令
git config --global url.gitgit.zhlh6.cn:.insteadOf https://github.com/这个命令把github.com 转换成镜像国内地址
执行完之后可以通过查看~/.gitconfig 文件来检查替换是否正确。
开始搭建zephyr环境
https://docs.zephyrproject.org/latest/develop/getting_started/index.html#get-zephyr-and-install-python-dependencies
按照zephyr中的install
网页中第一步是安装Kitware 这个只要你的ubuntu是22.04 及以上的就可以跳过这一步
第一步安装软件
当然记得切换一下软件源为国内cn99 这样下载软件会比较快
用下面的命令
sudo apt install --no-install-recommends git cmake ninja-build gperf \ccache dfu-util device-tree-compiler wget \python3-dev python3-pip python3-setuptools python3-tk python3-wheel xz-utils file \make gcc gcc-multilib g-multilib libsdl2-dev libmagic1检查软件是否安装正常
cmake --version
python3 --version
dtc --version获取 Zephyr 并安装 Python 依赖项
安装python venv包
输入下面的命令
sudo apt install python3-venv创建新的虚拟环境
python3 -m venv ~/zephyrproject/.venv激活虚拟环境
source ~/zephyrproject/.venv/bin/activate安装west
pip install west获取源码
west init ~/zephyrproject
cd ~/zephyrproject这里需要注意west update这里会把所有包都下载下来实际上有些hello world没必要下载所有的
下面以STM32-L496ZG举例
打开west.yml
只需要保留cmsis和hal_stm32即可如下所示可以参考当时的west.yml来修改
manifest:defaults:remote: upstreamremotes:- name: upstreamurl-base: https://github.com/zephyrproject-rtos- name: babblesimurl-base: https://github.com/BabbleSimgroup-filter: [-babblesim]## Please add items below based on alphabetical orderprojects:- name: cmsisrevision: 74981bf893e8b10931464b9945e2143d99a3f0a3path: modules/hal/cmsisgroups:- hal- name: hal_stm32revision: 1bc72c299d0365c0ee2575a97918b22df0899e10path: modules/hal/stm32groups:- halself:path: zephyrwest-commands: scripts/west-commands.ymlimport: submanifests执行 west update
这个时候执行一下west update
当然你也可以全部下载其实没必要可以先跑起来后面仓库慢慢添加 我是觉得下载需要很长的时间。
到处模板
执行下面的命令到处cmake模板
west zephyr-exportpip安装依赖
Zephyr 的scripts/requirements.txt文件声明了额外的 Python 依赖项。安装它们pip。
pip install -r ~/zephyrproject/zephyr/scripts/requirements.txt安装SDK
SDK 相当于toolchain
下载命令
cd ~
wget https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.16.1/zephyr-sdk-0.16.1_linux-x86_64.tar.xz
wget -O - https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.16.1/sha256.sum | shasum --check --ignore-missing这个命令也要github.com 这个可以自己在网页上下载。
解压
tar xvf zephyr-sdk-0.16.1_linux-x86_64.tar.xz设置环境变量
cd zephyr-sdk-0.16.1
./setup.sh编译
拿stm32-l496zg开发板举例
参考链接
https://docs.zephyrproject.org/latest/boards/arm/nucleo_l496zg/doc/index.html
编译一个hello_world程序
cd ~/zephyrproject/zephyr
west build -p always -b nucleo_l496zg samples/hello_world这里的-p always 在你想要切换另外的exapmle的时候如果不加这个编译不了必须删除build目录才行。如果加了这个直接强制重新生成example。
烧入
west flash烧入之后的调试可以尝试用ozone 来学习非常方便。