Part 1
요약·해설
운영체제 갱신과 build dependency 설치부터 오래된 CMake·DTC·Python 보완, SDK 0.16.8 검증·설치, 여러 SDK 자동 선택과 SDK 없는 build 조건까지 설명합니다.
Ubuntu · Fedora · Clear · Arch
CMake · DTC · Python
SDK · QEMU · OpenOCD
Part 2
접을 수 있는 영어 원문 전체
영어 원문 전체 펼치기
46691C61164FEF67CF4E2C14797EE14D49F26D10CBEC757BA4983F0A35BECD47
.. _installation_linux:
Install Linux Host Dependencies
###############################
Documentation is available for these Linux distributions:
* Ubuntu
* Fedora
* Clear Linux
* Arch Linux
For distributions that are not based on rolling releases, some of the
requirements and dependencies may not be met by your package manager. In that
case please follow the additional instructions that are provided to find
software from sources other than the package manager.
.. note:: If you're working behind a corporate firewall, you'll likely
need to configure a proxy for accessing the internet, if you haven't
done so already. While some tools use the environment variables
``http_proxy`` and ``https_proxy`` to get their proxy settings, some
use their own configuration files, most notably ``apt`` and
``git``.
Update Your Operating System
****************************
Ensure your host system is up to date.
.. tabs::
.. group-tab:: Ubuntu
.. code-block:: console
sudo apt-get update
sudo apt-get upgrade
.. group-tab:: Fedora
.. code-block:: console
sudo dnf upgrade
.. group-tab:: Clear Linux
.. code-block:: console
sudo swupd update
.. group-tab:: Arch Linux
.. code-block:: console
sudo pacman -Syu
.. _linux_requirements:
Install Requirements and Dependencies
*************************************
.. NOTE FOR DOCS AUTHORS: DO NOT PUT DOCUMENTATION BUILD DEPENDENCIES HERE.
This section is for dependencies to build Zephyr binaries, *NOT* this
documentation. If you need to add a dependency only required for building
the docs, add it to doc/README.rst. (This change was made following the
introduction of LaTeX->PDF support for the docs, as the texlive footprint is
massive and not needed by users not building PDF documentation.)
Note that both Ninja and Make are installed with these instructions; you only
need one.
.. tabs::
.. group-tab:: Ubuntu
.. code-block:: console
sudo apt-get 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
.. group-tab:: Fedora
.. code-block:: console
sudo dnf group install "Development Tools" "C Development Tools and Libraries"
sudo dnf install cmake ninja-build gperf dfu-util dtc wget which \
python3-pip python3-tkinter xz file python3-devel SDL2-devel
.. group-tab:: Clear Linux
.. code-block:: console
sudo swupd bundle-add c-basic dev-utils dfu-util dtc \
os-core-dev python-basic python3-basic python3-tcl
The Clear Linux focus is on *native* performance and security and not
cross-compilation. For that reason it uniquely exports by default to the
:ref:`environment <env_vars>` of all users a list of compiler and linker
flags. Zephyr's CMake build system will either warn or fail because of
these. To clear the C/C++ flags among these and fix the Zephyr build, run
the following command as root then log out and back in:
.. code-block:: console
echo 'unset CFLAGS CXXFLAGS' >> /etc/profile.d/unset_cflags.sh
Note this command unsets the C/C++ flags for *all users on the
system*. Each Linux distribution has a unique, relatively complex and
potentially evolving sequence of bash initialization files sourcing each
other and Clear Linux is no exception. If you need a more flexible
solution, start by looking at the logic in
``/usr/share/defaults/etc/profile``.
.. group-tab:: Arch Linux
.. code-block:: console
sudo pacman -S git cmake ninja gperf ccache dfu-util dtc wget \
python-pip python-setuptools python-wheel tk xz file make
CMake
=====
A :ref:`recent CMake version <install-required-tools>` 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:
* On Ubuntu, you can follow the instructions for adding the
`kitware third-party apt repository <https://apt.kitware.com/>`_
to get an updated version of cmake using apt.
* Download and install a packaged cmake from the CMake project site.
(Note this won't uninstall the previous version of cmake.)
.. code-block:: console
cd ~
wget https://github.com/Kitware/CMake/releases/download/v3.21.1/cmake-3.21.1-Linux-x86_64.sh
chmod +x cmake-3.21.1-Linux-x86_64.sh
sudo ./cmake-3.21.1-Linux-x86_64.sh --skip-license --prefix=/usr/local
hash -r
The ``hash -r`` command may be necessary if the installation script
put cmake into a new location on your PATH.
* 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.21.1 in :file:`~/bin/cmake`:
.. code-block:: console
mkdir $HOME/bin/cmake && cd $HOME/bin/cmake
wget https://github.com/Kitware/CMake/releases/download/v3.21.1/cmake-3.21.1-Linux-x86_64.sh
yes | sh cmake-3.21.1-Linux-x86_64.sh | cat
echo "export PATH=$PWD/cmake-3.21.1-Linux-x86_64/bin:\$PATH" >> $HOME/.zephyrrc
* Use ``pip3``:
.. code-block:: console
pip3 install --user cmake
Note this won't uninstall the previous version of cmake and will
install the new cmake into your ~/.local/bin folder so
you'll need to add ~/.local/bin to your PATH. (See :ref:`python-pip`
for details.)
* Check your distribution's beta or unstable release package library for an
update.
* On Ubuntu you can also use snap to get the latest version available:
.. code-block:: console
sudo snap install cmake
After updating cmake, verify that the newly installed cmake is found
using ``cmake --version``.
You might also want to uninstall the CMake provided by your package manager to
avoid conflicts. (Use ``whereis cmake`` to find other installed
versions.)
DTC (Device Tree Compiler)
==========================
A :ref:`recent DTC version <install-required-tools>` is required. Check what
version you have by using ``dtc --version``. 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 :ref:`Zephyr SDK <toolchain_zephyr_sdk>` by installing it.
Python
======
A :ref:`modern Python 3 version <install-required-tools>` is required. Check
what version you have by using ``python3 --version``.
If you have an older version, you will need to install a more recent Python 3.
You can build from source, or use a backport from your distribution's package
manager channels if one is available. Isolating this Python in a virtual
environment is recommended to avoid interfering with your system Python.
.. _pyenv: https://github.com/pyenv/pyenv
Install the Zephyr Software Development Kit (SDK)
*************************************************
The Zephyr Software Development Kit (SDK) contains toolchains for each of
Zephyr's supported architectures. It also includes additional host tools, such
as custom QEMU and OpenOCD.
Use of the Zephyr SDK is highly recommended and may even be required under
certain conditions (for example, running tests in QEMU for some architectures).
The Zephyr SDK supports the following target architectures:
* ARC (32-bit and 64-bit; ARCv1, ARCv2, ARCv3)
* ARM (32-bit and 64-bit; ARMv6, ARMv7, ARMv8; A/R/M Profiles)
* MIPS (32-bit and 64-bit)
* Nios II
* RISC-V (32-bit and 64-bit; RV32I, RV32E, RV64I)
* x86 (32-bit and 64-bit)
* Xtensa
Follow these steps to install the Zephyr SDK:
#. Download and verify the `Zephyr SDK bundle`_:
.. parsed-literal::
wget |sdk-url-linux|
wget -O - |sdk-url-linux-sha| | shasum --check --ignore-missing
You can change |sdk-version-literal| to another version if needed; the
`Zephyr SDK Releases`_ page contains all available SDK releases.
If your host architecture is 64-bit ARM (for example, Raspberry Pi), replace
``x86_64`` with ``aarch64`` in order to download the 64-bit ARM Linux SDK.
#. Extract the Zephyr SDK bundle archive:
.. parsed-literal::
cd <sdk download directory>
tar xvf zephyr-sdk- |sdk-version-trim| _linux-x86_64.tar.xz
#. Run the Zephyr SDK bundle setup script:
.. parsed-literal::
cd zephyr-sdk- |sdk-version-ltrim|
./setup.sh
If this fails, make sure Zephyr's dependencies were installed as described
in `Install Requirements and Dependencies`_.
If you want to uninstall the SDK, remove the directory where you installed it.
If you relocate the SDK directory, you need to re-run the setup script.
.. note::
It is recommended to extract the Zephyr SDK bundle at one of the following locations:
* ``$HOME``
* ``$HOME/.local``
* ``$HOME/.local/opt``
* ``$HOME/bin``
* ``/opt``
* ``/usr/local``
The Zephyr SDK bundle archive contains the ``zephyr-sdk-<version>``
directory and, when extracted under ``$HOME``, the resulting installation
path will be ``$HOME/zephyr-sdk-<version>``.
If you install the Zephyr SDK outside any of these locations, you must
register the Zephyr SDK in the CMake package registry by running the setup
script, or set :envvar:`ZEPHYR_SDK_INSTALL_DIR` to point to the Zephyr SDK
installation directory.
You can also use :envvar:`ZEPHYR_SDK_INSTALL_DIR` for pointing to a
directory containing multiple Zephyr SDKs, allowing for automatic toolchain
selection. For example, ``ZEPHYR_SDK_INSTALL_DIR=/company/tools``, where
the ``company/tools`` folder contains the following subfolders:
* ``/company/tools/zephyr-sdk-0.13.2``
* ``/company/tools/zephyr-sdk-a.b.c``
* ``/company/tools/zephyr-sdk-x.y.z``
This allows the Zephyr build system to choose the correct version of the
SDK, while allowing multiple Zephyr SDKs to be grouped together at a
specific path.
.. _sdkless_builds:
Building on Linux without the Zephyr SDK
****************************************
The Zephyr SDK is provided for convenience and ease of use. It provides
toolchains for all Zephyr target architectures, and does not require any extra
flags when building applications or running tests. In addition to
cross-compilers, the Zephyr SDK also provides prebuilt host tools. It is,
however, possible to build without the SDK's toolchain by using another
toolchain as described in the :ref:`toolchains` section.
As already noted above, the SDK also includes prebuilt host tools. To use the
SDK's prebuilt host tools with a toolchain from another source, you must set the
:envvar:`ZEPHYR_SDK_INSTALL_DIR` environment variable to the Zephyr SDK
installation directory. To build without the Zephyr SDK's prebuilt host tools,
the :envvar:`ZEPHYR_SDK_INSTALL_DIR` environment variable must be unset.
To make sure this variable is unset, run:
.. code-block:: console
unset ZEPHYR_SDK_INSTALL_DIR
.. _Zephyr SDK Releases: https://github.com/zephyrproject-rtos/sdk-ng/tags
.. _CMake Downloads: https://cmake.org/download
Part 3
한국어 전문 번역
Linux host dependency 설치
이 문서는 다음 Linux distribution을 대상으로 합니다.
- Ubuntu
- Fedora
- Clear Linux
- Arch Linux
Rolling release 기반이 아닌 distribution에서는 package manager가 일부 requirement나 dependency의 필요한 version을 제공하지 않을 수 있습니다. 이 경우 package manager 이외의 source에서 software를 구하는 추가 지침을 따르십시오.
운영체제 갱신
Host system을 최신 상태로 갱신합니다.
Ubuntu
sudo apt-get update
sudo apt-get upgradeFedora
sudo dnf upgradeClear Linux
sudo swupd updateArch Linux
sudo pacman -SyuRequirement와 dependency 설치
아래 지침은 Ninja와 Make를 모두 설치하지만 실제 build에는 둘 중 하나만 있으면 됩니다.
Ubuntu
sudo apt-get 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 libmagic1Fedora
sudo dnf group install "Development Tools" "C Development Tools and Libraries"
sudo dnf install cmake ninja-build gperf dfu-util dtc wget which \
python3-pip python3-tkinter xz file python3-devel SDL2-develClear Linux
sudo swupd bundle-add c-basic dev-utils dfu-util dtc \
os-core-dev python-basic python3-basic python3-tclClear Linux는 cross-compilation보다 native 성능과 보안에 초점을 둡니다. 이 때문에 모든 사용자의 환경에 compiler·linker flag 목록을 기본으로 export하며, Zephyr CMake build system은 이 flag 때문에 warning을 내거나 실패할 수 있습니다. C/C++ flag를 지워 Zephyr build를 바로잡으려면 root로 다음 command를 실행하고 logout한 뒤 다시 login합니다.
echo 'unset CFLAGS CXXFLAGS' >> /etc/profile.d/unset_cflags.sh이 command는 system의 모든 사용자에게서 C/C++ flag를 해제합니다. Linux distribution마다 bash initialization file이 서로를 불러오는 순서가 복잡하고 계속 바뀔 수 있으며 Clear Linux도 마찬가지입니다. 더 유연한 방법이 필요하면 /usr/share/defaults/etc/profile의 logic부터 살펴보십시오.
Arch Linux
sudo pacman -S git cmake ninja gperf ccache dfu-util dtc wget \
python-pip python-setuptools python-wheel tk xz file makeCMake
최근 CMake version이 필요합니다. cmake --version으로 설치된 version을 확인하십시오. 오래된 version이라면 다음 방법 가운데 하나로 최신 version을 설치할 수 있습니다.
- Ubuntu에서는 Kitware third-party apt repository 추가 지침을 따라 apt로 갱신된 CMake를 받을 수 있습니다.
- CMake project site에서 packaged CMake를 내려받아 설치합니다. 이전 CMake version은 제거되지 않습니다.
설치 script가 CMake를 PATH의 새 위치에 넣었다면cd ~ wget https://github.com/Kitware/CMake/releases/download/v3.21.1/cmake-3.21.1-Linux-x86_64.sh chmod +x cmake-3.21.1-Linux-x86_64.sh sudo ./cmake-3.21.1-Linux-x86_64.sh --skip-license --prefix=/usr/local hash -rhash -r이 필요할 수 있습니다. - CMake Downloads 페이지에서 CMake project가 제공하는 pre-built binary를 내려받아 설치합니다. Version 3.21.1을
~/bin/cmake에 설치하는 예입니다.mkdir $HOME/bin/cmake && cd $HOME/bin/cmake wget https://github.com/Kitware/CMake/releases/download/v3.21.1/cmake-3.21.1-Linux-x86_64.sh yes | sh cmake-3.21.1-Linux-x86_64.sh | cat echo "export PATH=$PWD/cmake-3.21.1-Linux-x86_64/bin:\$PATH" >> $HOME/.zephyrrc pip3를 사용합니다.
이 방법도 이전 CMake를 제거하지 않습니다. 새 CMake는pip3 install --user cmake~/.local/bin에 설치되므로 이 directory를 PATH에 추가해야 합니다. 자세한 내용은 Python과 pip를 참고하십시오.- Distribution의 beta 또는 unstable release package library에 update가 있는지 확인합니다.
- Ubuntu에서는 snap으로 제공되는 최신 version을 설치할 수도 있습니다.
sudo snap install cmake
cmake --version으로 갱신한 CMake가 실제로 선택되는지 검증합니다. 충돌을 피하려면 package manager가 설치한 CMake를 제거하는 편이 좋을 수도 있습니다. whereis cmake로 다른 설치 version을 찾을 수 있습니다.
DTC(Device Tree Compiler)
최근 DTC version이 필요합니다. dtc --version으로 version을 확인하십시오. 오래되었다면 source에서 최신 version을 build해 설치하거나, Zephyr SDK에 포함된 DTC를 사용하십시오.
Python
최신 Python 3 version이 필요합니다. python3 --version으로 version을 확인하십시오.
Version이 오래되었다면 더 최신 Python 3를 설치해야 합니다. Source에서 build하거나 distribution package manager channel에 backport가 있다면 그것을 사용할 수 있습니다. System Python을 방해하지 않도록 이 Python을 virtual environment에 격리하는 방법을 권장합니다.
Zephyr Software Development Kit(SDK) 설치
Zephyr SDK에는 Zephyr가 지원하는 각 architecture용 toolchain이 들어 있습니다. Custom QEMU와 OpenOCD 같은 추가 host tool도 포함됩니다.
Zephyr SDK 사용을 적극 권장하며, 일부 architecture의 QEMU test 실행 같은 조건에서는 SDK가 필수일 수도 있습니다.
Zephyr SDK가 지원하는 target architecture:
- ARC(32-bit·64-bit, ARCv1·ARCv2·ARCv3)
- ARM(32-bit·64-bit, ARMv6·ARMv7·ARMv8, A/R/M Profile)
- MIPS(32-bit·64-bit)
- Nios II
- RISC-V(32-bit·64-bit, RV32I·RV32E·RV64I)
- x86(32-bit·64-bit)
- Xtensa
다음 순서로 Zephyr SDK를 설치합니다.
- Zephyr SDK bundle을 내려받고 검증합니다.
필요하면wget https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.16.8/zephyr-sdk-0.16.8_linux-x86_64.tar.xz wget -O - https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.16.8/sha256.sum | shasum --check --ignore-missing0.16.8을 다른 version으로 바꿀 수 있습니다. 모든 release는 Zephyr SDK Releases 페이지에 있습니다. Host architecture가 64-bit ARM(예: Raspberry Pi)이면 64-bit ARM Linux SDK를 받도록x86_64를aarch64로 바꿉니다. - Zephyr SDK bundle archive를 풉니다.
cd <sdk download directory> tar xvf zephyr-sdk-0.16.8_linux-x86_64.tar.xz - Zephyr SDK bundle setup script를 실행합니다.
실패한다면 앞의 Requirement와 dependency 설치 절대로 Zephyr dependency를 설치했는지 확인하십시오.cd zephyr-sdk-0.16.8 ./setup.sh
SDK를 제거하려면 설치 directory를 삭제합니다. SDK directory를 다른 위치로 옮겼다면 setup script를 다시 실행해야 합니다.
Zephyr SDK 없이 Linux에서 build
Zephyr SDK는 편의성과 사용 편의를 위해 제공됩니다. 모든 Zephyr target architecture용 toolchain을 제공하고 application build나 test 실행 시 추가 flag가 필요하지 않습니다. Cross-compiler뿐 아니라 pre-built host tool도 포함합니다. 하지만 Toolchain 절의 다른 toolchain을 사용하면 SDK toolchain 없이도 build할 수 있습니다.
다른 source의 toolchain과 SDK의 pre-built host tool을 함께 사용하려면 ZEPHYR_SDK_INSTALL_DIR 환경 변수를 Zephyr SDK 설치 directory로 설정해야 합니다. Zephyr SDK의 pre-built host tool도 사용하지 않고 build하려면 이 환경 변수가 설정되어 있지 않아야 합니다.
변수가 해제되었는지 확실히 하려면 다음 command를 실행합니다.
unset ZEPHYR_SDK_INSTALL_DIR
Source
출처
영어 원문에는 문단, 문서 지시문, 표, 코드, 코드 심벌, 경로를 그대로 보존했습니다.