develop/getting_started/index.html · develop/getting_started/index.rst 공식 원문 ↗

Zephyr 3.7.0 · Develop · Getting Started

Zephyr 시작 안내서

개발 host 준비부터 Zephyr source와 SDK 설치, 첫 sample build·flash까지 운영체제별로 안내합니다.

Official pathdevelop/getting_started/index.html
Source filedevelop/getting_started/index.rst
Source versionZephyr 3.7.0
TranslationFull · reviewed

본문 기준: Zephyr 3.7.0 LTS3 · 이후 유지보수 패치는 별도입니다.

Part 1

요약·해설

Ubuntu·macOS·Windows별 dependency와 Python 환경, west workspace, SDK 0.16.8 설치, Blinky 검증, 설치 문제 해결과 community 지원을 단계별로 설명합니다.

Host

OS · Dependencies · Python

Zephyr

West · Source · SDK

검증

Build · Flash · Blinky

Part 2

접을 수 있는 영어 원문 전체

영어 원문 전체 펼치기
원문 SHA-256 1505566263C68712DF6F03F6F0EB1C8714F55FD5C49E11EDCF5B9E86E8B34243
.. _getting_started:

Getting Started Guide
#####################

Follow this guide to:

- Set up a command-line Zephyr development environment on Ubuntu, macOS, or
  Windows (instructions for other Linux distributions are discussed in
  :ref:`installation_linux`)
- Get the source code
- Build, flash, and run a sample application

.. _host_setup:

Select and Update OS
********************

Click the operating system you are using.

.. tabs::

   .. group-tab:: Ubuntu

      This guide covers Ubuntu version 20.04 LTS and later.

      .. code-block:: bash

         sudo apt update
         sudo apt upgrade

   .. group-tab:: macOS

      On macOS Mojave or later, select *System Preferences* >
      *Software Update*. Click *Update Now* if necessary.

      On other versions, see `this Apple support topic
      <https://support.apple.com/en-us/HT201541>`_.

   .. group-tab:: Windows

      Select *Start* > *Settings* > *Update & Security* > *Windows Update*.
      Click *Check for updates* and install any that are available.

.. _install-required-tools:

Install dependencies
********************

Next, you'll install some host dependencies using your package manager.

The current minimum required version for the main dependencies are:

.. list-table::
   :header-rows: 1

   * - Tool
     - Min. Version

   * - `CMake <https://cmake.org/>`_
     - 3.20.5

   * - `Python <https://www.python.org/>`_
     - 3.10

   * - `Devicetree compiler <https://www.devicetree.org/>`_
     - 1.4.6

.. tabs::

   .. group-tab:: Ubuntu

      .. _install_dependencies_ubuntu:

      #. If using an Ubuntu version older than 22.04, it is necessary to add extra
         repositories to meet the minimum required versions for the main
         dependencies listed above. In that case, download, inspect and execute
         the Kitware archive script to add the Kitware APT repository to your
         sources list.
         A detailed explanation of ``kitware-archive.sh`` can be found here
         `kitware third-party apt repository <https://apt.kitware.com/>`_:

         .. code-block:: bash

            wget https://apt.kitware.com/kitware-archive.sh
            sudo bash kitware-archive.sh

      #. Use ``apt`` to install the required dependencies:

         .. code-block:: bash

            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 libmagic1

      #. Verify the versions of the main dependencies installed on your system by entering:

         .. code-block:: bash

            cmake --version
            python3 --version
            dtc --version

         Check those against the versions in the table in the beginning of this section.
         Refer to the :ref:`installation_linux` page for additional information on updating
         the dependencies manually.

   .. group-tab:: macOS

      .. _install_dependencies_macos:

      #. Install `Homebrew <https://brew.sh/>`_:

         .. code-block:: bash

            /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

      #. After the Homebrew installation script completes, follow the on-screen
         instructions to add the Homebrew installation to the path.

         * On macOS running on Apple Silicon, this is achieved with:

           .. code-block:: bash

              (echo; echo 'eval "$(/opt/homebrew/bin/brew shellenv)"') >> ~/.zprofile
              source ~/.zprofile

         * On macOS running on Intel, use the command for Apple Silicon, but replace ``/opt/homebrew/`` with ``/usr/local/``.

      #. Use ``brew`` to install the required dependencies:

         .. code-block:: bash

            brew install cmake ninja gperf python3 ccache qemu dtc libmagic wget openocd

      #. Add the Homebrew Python folder to the path, in order to be able to
         execute ``python`` and ``pip`` as well ``python3`` and ``pip3``.

           .. code-block:: bash

              (echo; echo 'export PATH="'$(brew --prefix)'/opt/python/libexec/bin:$PATH"') >> ~/.zprofile
              source ~/.zprofile

   .. group-tab:: Windows

      .. note::

         Due to issues finding executables, the Zephyr Project doesn't
         currently support application flashing using the `Windows Subsystem
         for Linux (WSL)
         <https://msdn.microsoft.com/en-us/commandline/wsl/install_guide>`_
         (WSL).

         Therefore, we don't recommend using WSL when getting started.

      These instructions must be run in a ``cmd.exe`` command prompt terminal window.
      In modern version of Windows (10 and later) it is recommended to install the Windows Terminal
      application from the Microsoft Store. The required commands differ on PowerShell.

      These instructions rely on `Chocolatey`_. If Chocolatey isn't an option,
      you can install dependencies from their respective websites and ensure
      the command line tools are on your :envvar:`PATH` :ref:`environment
      variable <env_vars>`.

      |p|

      .. _install_dependencies_windows:

      #. `Install chocolatey`_.

      #. Open a ``cmd.exe`` terminal window as **Administrator**. To do so, press the Windows key,
         type ``cmd.exe``, right-click the :guilabel:`Command Prompt` search result, and choose
         :guilabel:`Run as Administrator`.

      #. Disable global confirmation to avoid having to confirm the
         installation of individual programs:

         .. code-block:: bat

            choco feature enable -n allowGlobalConfirmation

      #. Use ``choco`` to install the required dependencies:

         .. code-block:: bat

            choco install cmake --installargs 'ADD_CMAKE_TO_PATH=System'
            choco install ninja gperf python311 git dtc-msys2 wget 7zip

         .. warning::

            As of November 2023, Python 3.12 is not recommended for Zephyr development on Windows,
            as some required Python dependencies may be difficult to install.

      #. Close the terminal window.

.. _Chocolatey: https://chocolatey.org/
.. _Install chocolatey: https://chocolatey.org/install

.. _get_the_code:
.. _clone-zephyr:
.. _install_py_requirements:
.. _gs_python_deps:

Get Zephyr and install Python dependencies
******************************************

Next, clone Zephyr and its :ref:`modules <modules>` into a new :ref:`west
<west>` workspace named :file:`zephyrproject`. You'll also install Zephyr's
additional Python dependencies.


.. note::

    It is easy to run into Python package incompatibilities when installing
    dependencies at a system or user level. This situation can happen,
    for example, if working on multiple Zephyr versions or other projects
    using Python on the same machine.

    For this reason it is suggested to use `Python virtual environments`_.

.. _Python virtual environments: https://docs.python.org/3/library/venv.html

.. tabs::

   .. group-tab:: Ubuntu

      .. tabs::

         .. group-tab:: Install within virtual environment

            #. Use ``apt`` to install Python ``venv`` package:

               .. code-block:: bash

                  sudo apt install python3-venv

            #. Create a new virtual environment:

               .. code-block:: bash

                  python3 -m venv ~/zephyrproject/.venv

            #. Activate the virtual environment:

               .. code-block:: bash

                  source ~/zephyrproject/.venv/bin/activate

               Once activated your shell will be prefixed with ``(.venv)``. The
               virtual environment can be deactivated at any time by running
               ``deactivate``.

               .. note::

                  Remember to activate the virtual environment every time you
                  start working.

            #. Install west:

               .. code-block:: bash

                  pip install west

            #. Get the Zephyr source code:

               .. code-block:: bash

                 west init ~/zephyrproject
                 cd ~/zephyrproject
                 west update

            #. Export a :ref:`Zephyr CMake package <cmake_pkg>`. This allows CMake to
               automatically load boilerplate code required for building Zephyr
               applications.

               .. code-block:: bash

                  west zephyr-export

            #. Zephyr's ``scripts/requirements.txt`` file declares additional Python
               dependencies. Install them with ``pip``.

               .. code-block:: bash

                  pip install -r ~/zephyrproject/zephyr/scripts/requirements.txt

         .. group-tab:: Install globally

            #. Install west, and make sure :file:`~/.local/bin` is on your
               :envvar:`PATH` :ref:`environment variable <env_vars>`:

               .. code-block:: bash

                  pip3 install --user -U west
                  echo 'export PATH=~/.local/bin:"$PATH"' >> ~/.bashrc
                  source ~/.bashrc

            #. Get the Zephyr source code:

               .. code-block:: bash

                  west init ~/zephyrproject
                  cd ~/zephyrproject
                  west update

            #. Export a :ref:`Zephyr CMake package <cmake_pkg>`. This allows CMake to
               automatically load boilerplate code required for building Zephyr
               applications.

               .. code-block:: bash

                  west zephyr-export

            #. Zephyr's ``scripts/requirements.txt`` file declares additional Python
               dependencies. Install them with ``pip3``.

               .. code-block:: bash

                  pip3 install --user -r ~/zephyrproject/zephyr/scripts/requirements.txt

   .. group-tab:: macOS

      .. tabs::

         .. group-tab:: Install within virtual environment

            #. Create a new virtual environment:

               .. code-block:: bash

                  python3 -m venv ~/zephyrproject/.venv

            #. Activate the virtual environment:

               .. code-block:: bash

                  source ~/zephyrproject/.venv/bin/activate

               Once activated your shell will be prefixed with ``(.venv)``. The
               virtual environment can be deactivated at any time by running
               ``deactivate``.

               .. note::

                  Remember to activate the virtual environment every time you
                  start working.

            #. Install west:

               .. code-block:: bash

                  pip install west

            #. Get the Zephyr source code:

               .. code-block:: bash

                  west init ~/zephyrproject
                  cd ~/zephyrproject
                  west update

            #. Export a :ref:`Zephyr CMake package <cmake_pkg>`. This allows CMake to
               automatically load boilerplate code required for building Zephyr
               applications.

               .. code-block:: bash

                  west zephyr-export

            #. Zephyr's ``scripts/requirements.txt`` file declares additional Python
               dependencies. Install them with ``pip``.

               .. code-block:: bash

                  pip install -r ~/zephyrproject/zephyr/scripts/requirements.txt

         .. group-tab:: Install globally

            #. Install west:

               .. code-block:: bash

                  pip3 install -U west

            #. Get the Zephyr source code:

               .. code-block:: bash

                  west init ~/zephyrproject
                  cd ~/zephyrproject
                  west update

            #. Export a :ref:`Zephyr CMake package <cmake_pkg>`. This allows CMake to
               automatically load boilerplate code required for building Zephyr
               applications.

               .. code-block:: bash

                  west zephyr-export

            #. Zephyr's ``scripts/requirements.txt`` file declares additional Python
               dependencies. Install them with ``pip3``.

               .. code-block:: bash

                  pip3 install -r ~/zephyrproject/zephyr/scripts/requirements.txt

   .. group-tab:: Windows

      .. tabs::

         .. group-tab:: Install within virtual environment

            #. Open a ``cmd.exe`` terminal window **as a regular user**

            #. Create a new virtual environment:

               .. code-block:: bat

                  cd %HOMEPATH%
                  python -m venv zephyrproject\.venv

            #. Activate the virtual environment:

               .. code-block:: bat

                  zephyrproject\.venv\Scripts\activate.bat

               Once activated your shell will be prefixed with ``(.venv)``. The
               virtual environment can be deactivated at any time by running
               ``deactivate``.

               .. note::

                  Remember to activate the virtual environment every time you
                  start working.

            #. Install west:

               .. code-block:: bat

                  pip install west

            #. Get the Zephyr source code:

               .. code-block:: bat

                  west init zephyrproject
                  cd zephyrproject
                  west update

            #. Export a :ref:`Zephyr CMake package <cmake_pkg>`. This allows CMake to
               automatically load boilerplate code required for building Zephyr
               applications.

               .. code-block:: bat

                  west zephyr-export

            #. Zephyr's ``scripts\requirements.txt`` file declares additional Python
               dependencies. Install them with ``pip``.

               .. code-block:: bat

                  pip install -r %HOMEPATH%\zephyrproject\zephyr\scripts\requirements.txt

         .. group-tab:: Install globally

            #. Open a ``cmd.exe`` terminal window **as a regular user**

            #. Install west:

               .. code-block:: bat

                  pip3 install -U west

            #. Get the Zephyr source code:

               .. code-block:: bat

                  cd %HOMEPATH%
                  west init zephyrproject
                  cd zephyrproject
                  west update

            #. Export a :ref:`Zephyr CMake package <cmake_pkg>`. This allows CMake to
               automatically load boilerplate code required for building Zephyr
               applications.

               .. code-block:: bat

                  west zephyr-export

            #. Zephyr's ``scripts\requirements.txt`` file declares additional Python
               dependencies. Install them with ``pip3``.

               .. code-block:: bat

                  pip3 install -r %HOMEPATH%\zephyrproject\zephyr\scripts\requirements.txt


Install the Zephyr SDK
**********************

The :ref:`Zephyr Software Development Kit (SDK) <toolchain_zephyr_sdk>`
contains toolchains for each of Zephyr's supported architectures, which
include a compiler, assembler, linker and other programs required to build
Zephyr applications.

It also contains additional host tools, such as custom QEMU and OpenOCD builds
that are used to emulate, flash and debug Zephyr applications.

.. include:: ../../../../develop/toolchains/zephyr_sdk.rst
   :start-after: toolchain_zephyr_sdk_install_start
   :end-before: toolchain_zephyr_sdk_install_end

.. _getting_started_run_sample:

Build the Blinky Sample
***********************

.. note::

   :zephyr:code-sample:`blinky` is compatible with most, but not all, :ref:`boards`. If your board
   does not meet Blinky's :ref:`blinky-sample-requirements`, then
   :ref:`hello_world` is a good alternative.

   If you are unsure what name west uses for your board, ``west boards``
   can be used to obtain a list of all boards Zephyr supports.

Build the :zephyr:code-sample:`blinky` with :ref:`west build <west-building>`, changing
``<your-board-name>`` appropriately for your board:

.. tabs::

   .. group-tab:: Ubuntu

      .. code-block:: bash

         cd ~/zephyrproject/zephyr
         west build -p always -b <your-board-name> samples/basic/blinky

   .. group-tab:: macOS

      .. code-block:: bash

         cd ~/zephyrproject/zephyr
         west build -p always -b <your-board-name> samples/basic/blinky

   .. group-tab:: Windows

      .. code-block:: bat

         cd %HOMEPATH%\zephyrproject\zephyr
         west build -p always -b <your-board-name> samples\basic\blinky

The ``-p always`` option forces a pristine build, and is recommended for new
users. Users may also use the ``-p auto`` option, which will use
heuristics to determine if a pristine build is required, such as when building
another sample.

.. note::

   A board may contain one or multiple SoCs, Also, each SoC may contain one or
   more CPU clusters.
   When building for such boards it is necessary to specify the SoC or CPU
   cluster for which the sample must be built.
   For example to build :zephyr:code-sample:`blinky` for the ``cpuapp`` core on
   the :ref:`nRF5340DK <nrf5340dk_nrf5340>` the board must be provided as:
   ``nrf5340dk/nrf5340/cpuapp``. See also :ref:`board_terminology` for more
   details.

Flash the Sample
****************

Connect your board, usually via USB, and turn it on if there's a power switch.
If in doubt about what to do, check your board's page in :ref:`boards`.

Then flash the sample using :ref:`west flash <west-flashing>`:

.. code-block:: shell

   west flash

You may need to install additional :ref:`host tools <flash-debug-host-tools>`
required by your board. The ``west flash`` command will print an error if any
required dependencies are missing.

If you're using blinky, the LED will start to blink as shown in this figure:

.. figure:: ../../../../develop/getting_started/img/ReelBoard-Blinky.png
   :width: 400px
   :name: reelboard-blinky

   Phytec :ref:`reel_board <reel_board>` running blinky

Next Steps
**********

Here are some next steps for exploring Zephyr:

* Try other :ref:`samples-and-demos`
* Learn about :ref:`application` and the :ref:`west <west>` tool
* Find out about west's :ref:`flashing and debugging <west-build-flash-debug>`
  features, or more about :ref:`flashing_and_debugging` in general
* Check out :ref:`beyond-GSG` for additional setup alternatives and ideas
* Discover :ref:`project-resources` for getting help from the Zephyr
  community

.. _troubleshooting_installation:

Troubleshooting Installation
****************************

Here are some tips for fixing some issues related to the installation process.

.. _toolchain_zephyr_sdk_update:

Double Check the Zephyr SDK Variables When Updating
===================================================

When updating Zephyr SDK, check whether the :envvar:`ZEPHYR_TOOLCHAIN_VARIANT`
or :envvar:`ZEPHYR_SDK_INSTALL_DIR` environment variables are already set.
See :ref:`gs_toolchain_update` for more information.

For more information about these environment variables in Zephyr, see :ref:`env_vars_important`.

.. _help:

Asking for Help
***************

You can ask for help on a mailing list or on Discord. Please send bug reports and
feature requests to GitHub.

* **Mailing Lists**: [email protected] is usually the right list to
  ask for help. `Search archives and sign up here`_.
* **Discord**: You can join with this `Discord invite`_.
* **GitHub**: Use `GitHub issues`_ for bugs and feature requests.

How to Ask
==========

.. important::

   Please search this documentation and the mailing list archives first. Your
   question may have an answer there.

Don't just say "this isn't working" or ask "is this working?". Include as much
detail as you can about:

#. What you want to do
#. What you tried (commands you typed, etc.)
#. What happened (output of each command, etc.)

Use Copy/Paste
==============

Please **copy/paste text** instead of taking a picture or a screenshot of it.
Text includes source code, terminal commands, and their output.

Doing this makes it easier for people to help you, and also helps other users
search the archives. Unnecessary screenshots exclude vision impaired
developers; some are major Zephyr contributors. `Accessibility`_ has been
recognized as a basic human right by the United Nations.

When copy/pasting more than 5 lines of computer text into Discord or Github,
create a snippet using three backticks to delimit the snippet.

.. _Search archives and sign up here: https://lists.zephyrproject.org/g/users
.. _Discord invite: https://chat.zephyrproject.org
.. _GitHub issues: https://github.com/zephyrproject-rtos/zephyr/issues
.. _Accessibility: https://www.w3.org/standards/webdesign/accessibility

Part 3

한국어 전문 번역

시작 안내서

이 guide에서는 다음 작업을 수행합니다.

  • Ubuntu, macOS, Windows에 command-line Zephyr 개발 환경을 구성합니다. 다른 Linux distribution은 Linux 설치 대안에서 설명합니다.
  • Source code를 가져옵니다.
  • Sample application을 build·flash·실행합니다.

운영체제 선택과 갱신

사용하는 운영체제에 맞는 절차를 따릅니다.

Ubuntu: 이 guide는 Ubuntu 20.04 LTS 이상을 다룹니다.

sudo apt update
sudo apt upgrade

macOS: Mojave 이상에서는 System Preferences > Software Update를 선택하고 필요하면 Update Now를 누릅니다. 다른 version은 Apple support를 참고하십시오.

Windows: Start > Settings > Update & Security > Windows Update에서 Check for updates를 누르고 사용할 수 있는 update를 설치합니다.

Dependency 설치

Package manager를 사용해 host dependency를 설치합니다. 주요 dependency의 현재 최소 version:

Tool최소 version
CMake3.20.5
Python3.10
Devicetree compiler1.4.6

Ubuntu:

  1. Ubuntu 22.04보다 오래된 version은 위 최소 version을 충족하도록 추가 repository가 필요합니다. Kitware archive script를 내려받아 검토한 뒤 실행해 APT source에 Kitware third-party repository를 추가합니다.
    wget https://apt.kitware.com/kitware-archive.sh
    sudo bash kitware-archive.sh
  2. apt로 필요한 dependency를 설치합니다.
    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 libmagic1
  3. 주요 dependency version을 확인하고 위 표와 비교합니다. 수동 update 정보는 Linux 설치 대안을 참고하십시오.
    cmake --version
    python3 --version
    dtc --version

macOS:

  1. Homebrew를 설치합니다.
    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
  2. 설치 script가 끝나면 화면 안내에 따라 Homebrew를 PATH에 추가합니다.
    • Apple Silicon macOS:
      (echo; echo 'eval "$(/opt/homebrew/bin/brew shellenv)"') >> ~/.zprofile
      source ~/.zprofile
    • Intel macOS에서는 같은 command를 사용하되 /opt/homebrew/를 /usr/local/로 바꿉니다.
  3. brew로 dependency를 설치합니다.
    brew install cmake ninja gperf python3 ccache qemu dtc libmagic wget openocd
  4. python/pip과 python3/pip3를 모두 실행할 수 있도록 Homebrew Python folder를 PATH에 추가합니다.
    (echo; echo 'export PATH="'$(brew --prefix)'/opt/python/libexec/bin:$PATH"') >> ~/.zprofile
    source ~/.zprofile

Windows:

다음 지침은 cmd.exe command prompt에서 실행해야 합니다. Windows 10 이상에서는 Microsoft Store의 Windows Terminal 설치를 권장하지만 PowerShell command는 여기와 다릅니다.

Chocolatey를 사용하는 절차입니다. 사용할 수 없다면 각 website에서 dependency를 설치하고 command-line tool이 PATH에 있는지 확인하십시오.

  1. Chocolatey 설치 지침을 따릅니다.
  2. Windows key를 누르고 cmd.exe를 입력한 뒤 Command Prompt 검색 결과를 right-click하고 Run as Administrator를 선택합니다.
  3. 각 program 설치 확인을 반복하지 않도록 global confirmation을 disable합니다.
    choco feature enable -n allowGlobalConfirmation
  4. choco로 dependency를 설치합니다.
    choco install cmake --installargs 'ADD_CMAKE_TO_PATH=System'
    choco install ninja gperf python311 git dtc-msys2 wget 7zip
  5. Terminal window를 닫습니다.

Zephyr와 Python dependency 설치

Zephyr module과 Zephyr를 zephyrproject라는 새 west workspace로 clone하고 추가 Python dependency를 설치합니다.

Ubuntu, virtual environment 사용:

  1. apt로 Python venv package를 설치합니다.
    sudo apt install python3-venv
  2. 새 virtual environment를 만듭니다.
    python3 -m venv ~/zephyrproject/.venv
  3. Virtual environment를 activate합니다.
    source ~/zephyrproject/.venv/bin/activate
    Activate되면 shell prompt 앞에 (.venv)가 붙습니다. deactivate로 언제든 비활성화할 수 있습니다.
  4. west를 설치합니다.
    pip install west
  5. Zephyr source code를 가져옵니다.
    west init ~/zephyrproject
    cd ~/zephyrproject
    west update
  6. Zephyr CMake package를 export해 CMake가 application build에 필요한 boilerplate를 자동 load하게 합니다.
    west zephyr-export
  7. scripts/requirements.txt가 선언한 Python dependency를 pip로 설치합니다.
    pip install -r ~/zephyrproject/zephyr/scripts/requirements.txt

Ubuntu, global 설치:

  1. west를 설치하고 ~/.local/bin을 PATH에 추가합니다.
    pip3 install --user -U west
    echo 'export PATH=~/.local/bin:"$PATH"' >> ~/.bashrc
    source ~/.bashrc
  2. Zephyr source code를 가져옵니다.
    west init ~/zephyrproject
    cd ~/zephyrproject
    west update
  3. Zephyr CMake package를 export합니다.
    west zephyr-export
  4. 추가 Python dependency를 설치합니다.
    pip3 install --user -r ~/zephyrproject/zephyr/scripts/requirements.txt

macOS, virtual environment 사용:

  1. 새 virtual environment를 만듭니다.
    python3 -m venv ~/zephyrproject/.venv
  2. Virtual environment를 activate합니다.
    source ~/zephyrproject/.venv/bin/activate
    Prompt 앞에 (.venv)가 붙으며 deactivate로 비활성화합니다.
  3. west를 설치합니다.
    pip install west
  4. Zephyr source code를 가져옵니다.
    west init ~/zephyrproject
    cd ~/zephyrproject
    west update
  5. Zephyr CMake package를 export합니다.
    west zephyr-export
  6. 추가 Python dependency를 설치합니다.
    pip install -r ~/zephyrproject/zephyr/scripts/requirements.txt

macOS, global 설치:

  1. west를 설치합니다.
    pip3 install -U west
  2. Zephyr source code를 가져옵니다.
    west init ~/zephyrproject
    cd ~/zephyrproject
    west update
  3. Zephyr CMake package를 export합니다.
    west zephyr-export
  4. 추가 Python dependency를 설치합니다.
    pip3 install -r ~/zephyrproject/zephyr/scripts/requirements.txt

Windows, virtual environment 사용:

  1. cmd.exe terminal을 일반 사용자로 엽니다.
  2. 새 virtual environment를 만듭니다.
    cd %HOMEPATH%
    python -m venv zephyrproject\.venv
  3. Virtual environment를 activate합니다.
    zephyrproject\.venv\Scripts\activate.bat
    Prompt 앞에 (.venv)가 붙으며 deactivate로 비활성화합니다.
  4. west를 설치합니다.
    pip install west
  5. Zephyr source code를 가져옵니다.
    west init zephyrproject
    cd zephyrproject
    west update
  6. Zephyr CMake package를 export합니다.
    west zephyr-export
  7. 추가 Python dependency를 설치합니다.
    pip install -r %HOMEPATH%\zephyrproject\zephyr\scripts\requirements.txt

Windows, global 설치:

  1. cmd.exe terminal을 일반 사용자로 엽니다.
  2. west를 설치합니다.
    pip3 install -U west
  3. Zephyr source code를 가져옵니다.
    cd %HOMEPATH%
    west init zephyrproject
    cd zephyrproject
    west update
  4. Zephyr CMake package를 export합니다.
    west zephyr-export
  5. 추가 Python dependency를 설치합니다.
    pip3 install -r %HOMEPATH%\zephyrproject\zephyr\scripts\requirements.txt

Zephyr SDK 설치

Zephyr Software Development Kit(SDK)에는 지원 architecture별 compiler, assembler, linker와 Zephyr application build에 필요한 program이 포함됩니다. Application emulation·flash·debug에 사용하는 custom QEMU·OpenOCD build 같은 host tool도 포함합니다.

Ubuntu:

  1. Zephyr SDK bundle을 내려받아 검증합니다. 64-bit Arm host(예: Raspberry Pi)는 x86_64를 aarch64로 바꿉니다.
    cd ~
    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-missing
  2. Archive를 풉니다.
    tar xvf zephyr-sdk-0.16.8_linux-x86_64.tar.xz
  3. SDK setup script를 실행합니다.
    cd zephyr-sdk-0.16.8
    ./setup.sh
  4. 일반 사용자로 대부분의 Zephyr board를 flash할 수 있도록 udev rule을 설치합니다.
    sudo cp ~/zephyr-sdk-0.16.8/sysroots/x86_64-pokysdk-linux/usr/share/openocd/contrib/60-openocd.rules /etc/udev/rules.d
    sudo udevadm control --reload

macOS:

  1. SDK bundle을 내려받아 검증합니다. Apple Silicon은 x86_64를 aarch64로 바꿉니다.
    cd ~
    curl -L -O https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.16.8/zephyr-sdk-0.16.8_macos-x86_64.tar.xz
    curl -L https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.16.8/sha256.sum | shasum --check --ignore-missing
  2. Archive를 풉니다.
    tar xvf zephyr-sdk-0.16.8_macos-x86_64.tar.xz
  3. SDK setup script를 실행합니다.
    cd zephyr-sdk-0.16.8
    ./setup.sh

Windows:

  1. cmd.exe terminal을 일반 사용자로 엽니다.
  2. SDK bundle을 내려받습니다.
    cd %HOMEPATH%
    wget https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.16.8/zephyr-sdk-0.16.8_windows-x86_64.7z
  3. Archive를 풉니다.
    7z x zephyr-sdk-0.16.8_windows-x86_64.7z
  4. SDK setup script를 실행합니다.
    cd zephyr-sdk-0.16.8
    setup.cmd

Blinky sample build

<your-board-name>을 실제 board에 맞게 바꾸어 west build로 Blinky를 build합니다.

Ubuntu:

cd ~/zephyrproject/zephyr
west build -p always -b <your-board-name> samples/basic/blinky

macOS:

cd ~/zephyrproject/zephyr
west build -p always -b <your-board-name> samples/basic/blinky

Windows:

cd %HOMEPATH%\zephyrproject\zephyr
west build -p always -b <your-board-name> samples\basic\blinky

-p always는 pristine build를 강제하므로 신규 사용자에게 권장합니다. -p auto는 다른 sample을 build하는 경우처럼 pristine build 필요 여부를 heuristic으로 판단합니다.

Sample flash

보통 USB로 board를 연결하고 power switch가 있으면 켭니다. 확실하지 않다면 board 문서를 확인하십시오. 그다음 west로 sample을 flash합니다.

west flash

Board가 요구하는 추가 host tool을 설치해야 할 수 있습니다. Dependency가 없으면 west flash가 error를 출력합니다.

Blinky를 사용했다면 다음과 같이 LED가 깜박입니다.

Phytec reel_board에서 Blinky가 실행되어 LED가 깜박이는 모습
Phytec reel_board에서 실행 중인 Blinky

다음 단계

Zephyr를 더 탐색하는 방법:

설치 문제 해결

설치 과정에서 발생하는 문제를 해결할 때 다음 항목을 확인합니다.

SDK 갱신 시 Zephyr SDK variable 재확인

ZEPHYR_TOOLCHAIN_VARIANT 또는 ZEPHYR_SDK_INSTALL_DIR 환경 변수가 이미 설정되었는지 확인합니다. 자세한 내용은 Zephyr SDK toolchain 갱신과 중요 환경 변수를 참고하십시오.

도움 요청

Mailing list 또는 Discord에서 도움을 요청할 수 있습니다. Bug report와 feature request는 GitHub에 제출하십시오.

질문하는 방법

단순히 "동작하지 않는다" 또는 "동작하느냐"고 묻지 말고 가능한 한 자세히 포함하십시오.

  1. 무엇을 하려는지
  2. 무엇을 시도했는지(입력한 command 등)
  3. 무슨 일이 일어났는지(각 command의 output 등)

Copy/Paste 사용

사진이나 screenshot 대신 text를 copy/paste하십시오. Source code, terminal command, output도 text에 포함됩니다.

이 방법은 다른 사람이 돕기 쉽고 다른 사용자가 archive를 검색하는 데도 유리합니다. 불필요한 screenshot은 시각 장애 개발자를 배제하며 이들 중 일부는 주요 Zephyr contributor입니다. Accessibility는 UN이 기본적 인권으로 인정했습니다.

Discord 또는 GitHub에 computer text를 5줄 넘게 붙여 넣을 때는 backtick 세 개로 감싼 snippet을 만드십시오.

Source

출처

영어 원문에는 문단, 문서 지시문, 표, 코드, 코드 심벌, 경로를 그대로 보존했습니다.