build/flashing/configuration.html · build/flashing/configuration.rst 공식 원문 ↗

Zephyr 3.7.0 · Build · Flashing

Flashing configuration

여러 image를 programming할 때 erase·recover·reset을 안전한 시점에 한 번만 실행합니다.

Official pathbuild/flashing/configuration.html
Source filebuild/flashing/configuration.rst
Source versionZephyr 3.7.0
TranslationFull · reviewed

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

Part 1

요약·해설

soc.yml과 board.yml의 priority, runner group, first·last 실행 시점을 설명합니다.

Scope

Sysbuild

Files

soc.yml · board.yml

Groups

Qualifier · board

Run

first · last

Part 2

접을 수 있는 영어 원문 전체

영어 원문 전체 펼치기
원문 SHA-256 9DE9CE61DBBEA09D4E043646B3C5D3217728D7DBFDEFE1262F77139C57A2BAE8
.. _flashing-soc-board-config:

Flashing configuration
######################

Zephyr supports setting up configuration for flash runners (invoked from
:ref:`west flash<west-flashing>`) which allows for customising how commands are used when
programming boards. This configuration is used for :ref:`sysbuild` projects and allows for
configuring when commands are ran for groups of board targets. As an example: a multi-core SoC
might want to only allow the ``--erase`` argument to be used once for all of the cores in the SoC
which would prevent multiple erase tasks running in a single ``west flash`` invocation, which
could wrongly clear the memory which is used by the other images being programmed.

Priority
********

Flashing configuration is singular, it will only be read from a single location, this
configuration can reside in the following files starting with the highest priority:

 * ``soc.yml`` (in soc folder)
 * ``board.yml`` (in board folder)

Configuration
*************

Configuration is applied in the yml file by using a ``runners`` map with a single ``run_once``
child, this then contains a map of commands as they would be provided to the flash runner e.g.
``--reset`` followed by a list which specifies the settings for each of these commands (these
are grouped by flash runner, and by qualifiers/boards). Commands have associated runners that
they apply to using a ``runners`` list value, this can contain ``all`` if it applies to all
runners, otherwise must contain each runner that it applies to using the runner-specific name.
Groups of board targets can be specified using the ``groups`` key which has a list of board
target sets. Board targets are regular expression matches, for ``soc.yml`` files each set of
board targets must be in a ``qualifiers`` key (only regular expression matches for board
qualifiers are allowed, board names must be omitted from these entries). For ``board.yml``
files each set of board targets must be in a ``boards`` key, these are lists containing the
matches which form a singular group. A final parameter ``run`` can be set to ``first`` which
means that the command will be ran once with the first image flashing process per set of board
targets, or to ``last`` which will be ran once for the final image flash per set of board targets.

An example flashing configuration for a ``soc.yml`` is shown below in which the ``--recover``
command will only be used once for any board targets which used the nRF5340 SoC application or
network CPU cores, and will only reset the network or application core after all images for the
respective core have been flashed.

.. code-block:: yaml

  runners:
    run_once:
      '--recover':
        - run: first
          runners:
            - nrfjprog
          groups:
            - qualifiers:
                - nrf5340/cpunet
                - nrf5340/cpuapp
                - nrf5340/cpuapp/ns
      '--reset':
        - run: last
          runners:
            - nrfjprog
            - jlink
          groups:
            - qualifiers:
                - nrf5340/cpunet
            - qualifiers:
                - nrf5340/cpuapp
                - nrf5340/cpuapp/ns
        # Made up non-real world example to show how to specify different options for different
        # flash runners
        - run: first
          runners:
            - some_other_runner
          groups:
            - qualifiers:
                - nrf5340/cpunet
            - qualifiers:
                - nrf5340/cpuapp
                - nrf5340/cpuapp/ns

Usage
*****

Commands that are supported by flash runners can be used as normal when flashing non-sysbuild
applications, the run once configuration will not be used. When flashing a sysbuild project with
multiple images, the flash runner run once configuration will be applied.

For example, building the :zephyr:code-sample:`smp-svr` sample for the nrf5340dk which will
include MCUboot as a secondary image:

.. code-block:: console

   cmake -GNinja -Sshare/sysbuild/ -Bbuild -DBOARD=nrf5340dk/nrf5340/cpuapp -DAPP_DIR=samples/subsys/mgmt/mcumgr/smp_svr
   cmake --build build

Once built with an nrf5340dk connected, the following command can be used to flash the board with
both applications and will only perform a single device recovery operation when programming the
first image:

.. code-block:: console

   west flash --recover

If the above was ran without the flashing configuration, the recovery process would be ran twice
and the device would be unbootable.

Part 3

한국어 전문 번역

Flashing configuration

Zephyr는 west flash가 호출하는 flash runner 명령을 board programming 방식에 맞게 설정할 수 있습니다. Sysbuild project에서 여러 board target group에 명령을 언제 한 번만 실행할지 정합니다.

예를 들어 multi-core SoC에서 --erase를 core마다 반복하면 앞서 programming한 다른 image의 memory까지 지울 수 있습니다. Run-once 설정으로 전체 core group에 erase를 한 번만 허용해 이를 막습니다.

우선순위

Flashing configuration은 한 위치에서만 읽습니다. 우선순위는 다음과 같습니다.

  • SoC folder의 soc.yml
  • Board folder의 board.yml

Configuration 구조

YAML의 runners map 아래에 run_once를 두고, 그 아래에 --reset 같은 flash runner command를 map key로 씁니다. 각 command에는 적용할 runner와 board target group, 실행 시점을 정의한 설정 목록이 있습니다.

  • runners: 적용할 runner-specific 이름 목록. 모든 runner면 all
  • groups: 함께 처리할 board target set 목록
  • soc.yml: 각 target set은 qualifiers 아래 regular expression match를 사용하며 board 이름은 쓰지 않음
  • board.yml: 각 target set은 boards 아래 match 목록
  • run: first: group의 첫 image flash에서 한 번 실행
  • run: last: group의 마지막 image flash에서 한 번 실행

다음 soc.yml 예제는 nRF5340 application 또는 network CPU core를 쓰는 target group 전체에서 --recover를 한 번만 실행합니다. --reset은 해당 core의 모든 image가 flash된 뒤 한 번 실행합니다.

runners:
 run_once:
   '--recover':
     - run: first
       runners:
         - nrfjprog
       groups:
         - qualifiers:
             - nrf5340/cpunet
             - nrf5340/cpuapp
             - nrf5340/cpuapp/ns
   '--reset':
     - run: last
       runners:
         - nrfjprog
         - jlink
       groups:
         - qualifiers:
             - nrf5340/cpunet
         - qualifiers:
             - nrf5340/cpuapp
             - nrf5340/cpuapp/ns
     # Made up non-real world example to show how to specify different options for different
     # flash runners
     - run: first
       runners:
         - some_other_runner
       groups:
         - qualifiers:
             - nrf5340/cpunet
         - qualifiers:
             - nrf5340/cpuapp
             - nrf5340/cpuapp/ns

사용 방법

Sysbuild가 아닌 application을 flash할 때는 runner가 지원하는 command를 평소처럼 사용하며 run-once 설정은 적용되지 않습니다. 여러 image가 있는 sysbuild project를 flash할 때만 적용됩니다.

nRF5340 DK용 smp-svr sample을 MCUboot secondary image와 함께 build하는 예입니다.

cmake -GNinja -Sshare/sysbuild/ -Bbuild -DBOARD=nrf5340dk/nrf5340/cpuapp -DAPP_DIR=samples/subsys/mgmt/mcumgr/smp_svr
cmake --build build

Board를 연결한 뒤 다음 명령은 두 application을 모두 flash하되 첫 image programming 때 device recovery를 한 번만 수행합니다.

west flash --recover

이 flashing configuration이 없으면 recovery가 두 번 실행되어 device가 boot할 수 없는 상태가 됩니다.

Source

출처

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