Zephyr使用高版本工具问题处理

Creative Commons
本作品采用知识共享署名

本文说明解决ubuntu下zephyr编译依赖的工具比ubuntu发新版高的问题

目前遇到的是cmake和dtc。zephyr使用的工具版本都比较新,太过激进,可能会导致环境设置上的困扰,对推广不利。

cmake

ubuntu18.04发行版仓库cmake版本目前是3.10.2,zephyr要求CMake version 3.13.1 or higher is required. cmake很好处理,官方直接给出了解决方案

1
2
3
4
mkdir $HOME/bin/cmake && cd $HOME/bin/cmake
wget https://github.com/Kitware/CMake/releases/download/v3.13.1/cmake-3.13.1-Linux-x86_64.sh
yes | sh cmake-3.13.1-Linux-x86_64.sh | cat
echo "export PATH=$PWD/cmake-3.13.1-Linux-x86_64/bin:\$PATH" >> $HOME/.zephyrrc

dtc

ubuntu18.04发行版仓库dtc版本目前是1.4.5,昨天更新了SDK到0.10.3后zephyr要求A recent DTC version (1.4.6 or higher) is required,官方文档大略说明了如何处理

1
if you have an older version, either install a more recent one by building from source, or use the one that is bundled in the Zephyr SDK by installing it and setting the ZEPHYR_SDK_INSTALL_DIR environment variable.

因为新的SDK中dtc的版本是1.4.7,因此我们可以使用下面的方法将sdk内的dtc加入环境变量即可

1
echo "export PATH=$ZEPHYR_SDK_INSTALL_DIR/sysroots/x86_64-pokysdk-linux/usr/bin:\$PATH" >> $HOME/.zephyrrc

参考

https://docs.zephyrproject.org/latest/getting_started/installation_linux.html