前言
由於我只在ubuntu下開發zephyr,所以所有的實踐都是針對ubuntu系統的(ubuntu18.04)
Update Your Operating System
sudo apt-get update && sudo apt-get upgrade //Ensure your host system is up to date before proceeding.
Install Requirements and Dependencies
sudo apt-get install --no-install-recommends git cmake ninja-build gperf \ ccache dfu-util device-tree-compiler wget \ python3-pip python3-setuptools python3-wheel xz-utils file make gcc \ gcc-multilib
關鍵(針對CMake):由於Zephyr requires a recent version of CMake, 我在上面的install中沒有加上cmake, 而從從CMake官網下載最新版(有二進制或者源碼安裝,都可以,比較方便的是用二進制安裝方式安裝)來安裝, 因爲通過sudo apt-get install安裝的CMake版本可能會比較低,而官方要求CMake version 3.13.1 or higher is required.
官方給出的如何在系統中存在舊版本的CMake下讓Zephyr使用新版本CMake的解決辦法如下(但是,最好還是刪除舊版的CMake,然後安裝最新版):
CMake version 3.13.1 or higher is required. Check what version you have by using cmake --version
. If you have an older version, there are several ways of obtaining a more recent one:
-
Use
pip
: (方法1)pip3 install --user cmake
-
Download and install from the pre-built binaries provided by the CMake project itself in the CMake Downloads page. For example, to install version 3.13.1 in
~/bin/cmake
: (方法2)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