← Zephyr Documents build/dts/dt-vs-kconfig.html · build/dts/dt-vs-kconfig.rst 공식 원문 ↗

Zephyr 3.7.0 · Build · Devicetree · Kconfig

Devicetree와 Kconfig 역할 구분

UART와 multi-protocol radio 예제로 Devicetree와 Kconfig 중 어디에 설정을 둘지 판단합니다.

Official pathbuild/dts/dt-vs-kconfig.html
Source filebuild/dts/dt-vs-kconfig.rst
Source versionZephyr 3.7.0
TranslationFull · reviewed

Part 1

요약·해설

Devicetree=hardware·boot-time, Kconfig=software support 원칙과 instance별 driver 설정·chosen 예외를 보존했습니다.

Devicetree

Hardware · boot

Kconfig

Software build

Instance

status

Exception

zephyr, · chosen

Part 2

접을 수 있는 영어 원문 전체

영어 원문 전체 펼치기
원문 SHA-256 D6CE5771F46B431C70151ECD06447B5CCD9248FBB4F397DFD7D0DF72DB4A6DF5
.. _dt_vs_kconfig:

Devicetree versus Kconfig
#########################

Along with devicetree, Zephyr also uses the Kconfig language to configure the
source code. Whether to use devicetree or Kconfig for a particular purpose can
sometimes be confusing. This section should help you decide which one to use.

In short:

* Use devicetree to describe **hardware** and its **boot-time configuration**.
  Examples include peripherals on a board, boot-time clock frequencies,
  interrupt lines, etc.
* Use Kconfig to configure **software support** to build into the final
  image. Examples include whether to add networking support, which drivers are
  needed by the application, etc.

In other words, devicetree mainly deals with hardware, and Kconfig with
software.

For example, consider a board containing a SoC with 2 UART, or serial port,
instances.

* The fact that the board has this UART **hardware** is described with two UART
  nodes in the devicetree. These provide the UART type (via the ``compatible``
  property) and certain settings such as the address range of the hardware
  peripheral registers in memory (via the ``reg`` property).
* Additionally, the UART **boot-time configuration** is also described with
  devicetree. This could include configuration such as the RX IRQ line's
  priority and the UART baud rate. These may be modifiable at runtime, but
  their boot-time configuration is described in devicetree.
* Whether or not to include **software support** for UART in the build is
  controlled via Kconfig. Applications which do not need to use the UARTs can
  remove the driver source code from the build using Kconfig, even though the
  board's devicetree still includes UART nodes.

As another example, consider a device with a 2.4GHz, multi-protocol radio
supporting both the Bluetooth Low Energy and 802.15.4 wireless technologies.

* Devicetree should be used to describe the presence of the radio **hardware**,
  what driver or drivers it's compatible with, etc.
* **Boot-time configuration** for the radio, such as TX power in dBm, should
  also be specified using devicetree.
* Kconfig should determine which **software features** should be built for the
  radio, such as selecting a BLE or 802.15.4 protocol stack.

As another example, Kconfig options that formerly enabled a particular
instance of a driver (that is itself enabled by Kconfig) have been
removed.  The devices are selected individually using devicetree's
:ref:`status <dt-important-props>` keyword on the corresponding hardware
instance.

There are **exceptions** to these rules:

* Because Kconfig is unable to flexibly control some instance-specific driver
  configuration parameters, such as the size of an internal buffer, these
  options may be defined in devicetree.  However, to make clear that they are
  specific to Zephyr drivers and not hardware description or configuration these
  properties should be prefixed with ``zephyr,``,
  e.g. ``zephyr,random-mac-address`` in the common Ethernet devicetree
  properties.
* Devicetree's ``chosen`` keyword, which allows the user to select a specific
  instance of a hardware device to be used for a particular purpose. An example
  of this is selecting a particular UART for use as the system's console.

Part 3

한국어 전문 번역

무엇을 어디에 설정할 것인가

Zephyr는 devicetree와 함께 source code 구성을 위한 Kconfig를 사용합니다. 기본 원칙은 명확합니다.

  • Devicetree: Board의 peripheral, boot-time clock, interrupt line 같은 hardwareboot-time configuration
  • Kconfig: Networking 포함 여부, application에 필요한 driver처럼 최종 image에 넣을 software support

즉 devicetree는 주로 hardware, Kconfig는 software를 담당합니다.

UART 두 개가 있는 SoC

  • UART hardware가 두 개 있다는 사실은 devicetree의 두 UART node로 표현합니다. compatible은 UART 종류를, reg는 peripheral register의 memory address range를 설명합니다.
  • RX interrupt priority와 baud rate 같은 UART의 초기 설정도 devicetree에 둡니다. Runtime에 바꿀 수 있는 값이어도 boot-time 값의 출처는 devicetree입니다.
  • UART software support를 build에 포함할지는 Kconfig가 정합니다. UART를 쓰지 않는 application은 devicetree에 node가 남아 있어도 Kconfig로 driver source를 제외할 수 있습니다.

BLE와 802.15.4를 지원하는 2.4GHz radio

  • Radio hardware 존재와 호환 driver는 devicetree에 기술합니다.
  • dBm 단위 TX power 같은 boot-time radio 설정도 devicetree에 둡니다.
  • BLE stack 또는 802.15.4 stack 중 어떤 software feature를 build할지는 Kconfig로 선택합니다.

과거에는 이미 Kconfig로 켠 driver의 특정 instance까지 Kconfig option으로 enable했지만 이런 option은 제거되었습니다. 이제 각 hardware instance는 devicetree의 status로 선택합니다.

예외

  • Internal buffer size처럼 Kconfig가 instance별로 유연하게 조절하기 어려운 driver 설정은 devicetree property가 될 수 있습니다. Hardware 설명이 아니라 Zephyr software 설정임을 나타내기 위해 common Ethernet property zephyr,random-mac-address처럼 zephyr, prefix를 붙여야 합니다.
  • Devicetree의 chosen은 특정 목적에 사용할 hardware instance를 선택합니다. System console로 쓸 UART를 고르는 것이 예입니다.

Source

출처

원문 파일의 단락, directive, 표, 코드, symbol, 경로는 영어 원문 영역에 그대로 보존했습니다.