Linux
系统:Ubuntu 21.04
1、更新系统的软件源
sudo apt update
sudo apt upgrade
2、安装依赖
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
cmake的版本需求要大于3.13.1,因此使用以下指令查看cmake版本
cmake --version
如果当前系统版本的cmake小于需求版本,可以使用以下方法进行根系
a、添加kitware签名密匙
wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | sudo apt-key add -
b、添加kitware仓库
sudo apt-add-repository 'deb https://apt.kitware.com/ubuntu/ bionic main'
c、然后使用以下指令进行camke的版本更新
sudo apt update
sudo apt install cmake
3、获取zephyer及其相关模块
安装west,并将其加入到系统环境中
pip3 install --user -U west
echo 'export PATH=~/.local/bin:"$PATH"' >> ~/.bashrc
source ~/.bashrc
获取zephyer源代码
west init ~/zephyrproject
cd ~/zephyrproject
west update
导出zephyer cmake包,这个允许cmake自动加载构建zephyr应用程序所需的样板代码
west zephyr-export
安装zephyr的Python依赖项
pip3 install --user -r ~/zephyrproject/zephyr/scripts/requirements.txt
4、安装工具链
下载最新的SDK安装程序
cd ~
wget https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.12.4/zephyr-sdk-0.12.4-x86_64-linux-setup.run
允许安装程序,将SDK安装在中~/zephyr-sdk-0.12.4
chmod +x zephyr-sdk-0.12.4-x86_64-linux-setup.run
./zephyr-sdk-0.12.4-x86_64-linux-setup.run -- -d ~/zephyr-sdk-0.12.4
安装udev规则,这个规则允许你以常规用户身份刷新大多数zephyr开发板
sudo cp ~/zephyr-sdk-0.12.4/sysroots/x86_64-pokysdk-linux/usr/share/openocd/contrib/60-openocd.rules /etc/udev/rules.d
sudo udevadm control --reload
5、允许demo
使用west build构建blinky,可以根据个人实际进行更改开发板
cd ~/zephyrproject/zephyr
west build -p auto -b <your-board-name> samples/basic/blinky
west build -b native_posix samples/hello_world
如果你连接了开发板,可以通过west flash,将程序烧写入物理设备中(jlink,stlink需要安装)
参考连接:https://docs.zephyrproject.org/latest/getting_started/index.html