2019/08/27

於Ubuntu測試Zephyr作業系統

摘要

本文概要說明在Ubuntu 19.04作業系統上測試Zephyr即時作業系統第0.10.3版的操縱步驟。


本文

Zephyr是一個小型的即時作業系統(real-time operating system, RTOS),適用於彼此互聯且資源受限的嵌入式裝置(尤其是微控制器)上。
本文隨後將於Ubuntu 19.04下載、跨平台建構、並測試最新第0.10.3版的Zephyr。
注意,此處選用的Ubuntu 19.04開發主機(x86)本身的套件庫便能滿足Zephyr所要求的3.13.1版(或更新版)的CMake、及1.4.6版(或更新版)的DTC等套件的前置條件。

操縱步驟分述如下。
第1步,更新套件庫。
sudo apt-get update
sudo apt-get upgrade

第2步,以apt-get安裝相依套件。
sudo apt-get install --no-install-recommends git cmake ninja-build gperf \
  ccache dfu-util device-tree-compiler wget \
  python3-pip python3-setuptools python3-tk python3-wheel xz-utils file \
  make gcc gcc-multilib

第3步,以snap安裝相依套件。
sudo snap install cmake --classic
第4步,下載最新的第0.10.3版的Zephyr的SDK檔案(self-extracting installation binary)。
wget https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.10.3/zephyr-sdk-0.10.3-setup.run
第5步,更改權限再執行,以便安裝Zephyr的SDK。
chmod +x ./zephyr-sdk-0.10.3-setup.run
./zephyr-sdk-0.10.3-setup.run -- -d ~/zephyr-sdk-0.10.3

第6步,設定相關的環境變數。
export ZEPHYR_TOOLCHAIN_VARIANT=zephyr
export ZEPHYR_SDK_INSTALL_DIR=$HOME/zephyr-sdk-0.10.3

第7步,安裝west此一Zephyr的meta-tool。
pip3 install --user -U west
第8步,下載原始碼,也就是複製Zephyr的倉庫。
export PATH=$PATH:~/.local/bin
west init zephyrproject
cd zephyrproject
west update

第9步,安裝必備之Python所需的相依套件。
pip3 install --user -r zephyr/scripts/requirements.txt
第10步,進入原始碼所在的目錄、並設置建構環境。
cd ~/zephyrproject/zephyr
source zephyr-env.sh

第11步,建構、並執行Zephyr的範例程式hello_world。
第11-1步,建構reel_board、並執行之。
west build -b reel_board samples/hello_world
west build -t run

無法在開發主機運行reel_board目標機器
第11-2步,建構native_posix、並執行之。
west build -b native_posix samples/hello_world
west build -t run
可以在開發主機運行native_posix目標機器

第11-3步,建構qemu_x86、並執行之。
west build -b qemu_x86 samples/hello_world
west build -t run

可以在開發主機運行qemu_x86目標機器
註:欲建構不同的目標機器,需要將build目錄先移除、再行建構。
rm -rf ./build

參考文獻

https://en.wikipedia.org/wiki/Zephyr_(operating_system)
https://docs.zephyrproject.org/latest/getting_started/installation_linux.html
https://lists.zephyrproject.org/g/devel/topic/30819483

沒有留言:

張貼留言