connectivity/bluetooth/bluetooth-arch.html · connectivity/bluetooth/bluetooth-arch.rst 공식 원문 ↗

Zephyr 3.7.0 · Connectivity · Bluetooth

Bluetooth Stack Architecture

표준 HCI를 경계로 single-chip과 dual-chip Bluetooth system을 구성합니다.

Official pathconnectivity/bluetooth/bluetooth-arch.html
Source fileconnectivity/bluetooth/bluetooth-arch.rst
Source versionZephyr 3.7.0
TranslationFull · reviewed

Part 1

요약·해설

BLE stack의 Host, Controller, Radio 세 layer와 HCI 경계, Controller-only·Host-only·Combined build를 source tree까지 연결합니다.

Layers

Host · Controller · Radio

Boundary

HCI

Builds

Controller · Host · Combined

Part 2

접을 수 있는 영어 원문 전체

영어 원문 전체 펼치기
원문 SHA-256 D87005A6BA3018AB40D8C8B0E4175F49C3A1C72EF6D85E725EFC4DDA82EE2A99
.. _bluetooth-arch:

Stack Architecture
##################

Overview
********

This page describes the software architecture of Zephyr's Bluetooth protocol
stack.

.. note::
   Zephyr supports mainly Bluetooth Low Energy (BLE), the low-power
   version of the Bluetooth specification. Zephyr also has limited support
   for portions of the BR/EDR Host. Throughout this architecture document we
   use BLE interchangeably for Bluetooth except when noted.

.. _bluetooth-layers:

BLE Layers
==========

There are 3 main layers that together constitute a full Bluetooth Low Energy
protocol stack:

* **Host**: This layer sits right below the application, and is comprised of
  multiple (non real-time) network and transport protocols enabling
  applications to communicate with peer devices in a standard and interoperable
  way.
* **Controller**: The Controller implements the Link Layer (LE LL), the
  low-level, real-time protocol which provides, in conjunction with the Radio
  Hardware, standard-interoperable over-the-air communication. The LL schedules
  packet reception and transmission, guarantees the delivery of data, and
  handles all the LL control procedures.
* **Radio Hardware**: Hardware implements the required analog and digital
  baseband functional blocks that permit the Link Layer firmware to send and
  receive in the 2.4GHz band of the spectrum.

.. _bluetooth-hci:

Host Controller Interface
=========================

The `Bluetooth Specification`_ describes the format in which a Host must
communicate with a Controller. This is called the Host Controller Interface
(HCI) protocol. HCI can be implemented over a range of different physical
transports like UART, SPI, or USB. This protocol defines the commands that a Host
can send to a Controller and the events that it can expect in return, and also
the format for user and protocol data that needs to go over the air. The HCI
ensures that different Host and Controller implementations can communicate
in a standard way making it possible to combine Hosts and Controllers from
different vendors.

.. _bluetooth-configs:

Configurations
==============

The three separate layers of the protocol and the standardized interface make
it possible to implement the Host and Controller on different platforms. The two
following configurations are commonly used:

* **Single-chip configuration**: In this configuration, a single microcontroller
  implements all three layers and the application itself. This can also be called a
  system-on-chip (SoC) implementation. In this case the BLE Host and the BLE
  Controller communicate directly through function calls and queues in RAM. The
  Bluetooth specification does not specify how HCI is implemented in this
  single-chip configuration and so how HCI commands, events, and data flows between
  the two can be implementation-specific. This configuration is well suited for
  those applications and designs that require a small footprint and the lowest
  possible power consumption, since everything runs on a single IC.
* **Dual-chip configuration**: This configuration uses two separate ICs,
  one running the Application and the Host, and a second one with the Controller
  and the Radio Hardware. This is sometimes also called a connectivity-chip
  configuration. This configuration allows for a wider variety of combinations of
  Hosts when using the Zephyr OS as a Controller. Since HCI ensures
  interoperability among Host and Controller implementations, including of course
  Zephyr's very own BLE Host and Controller, users of the Zephyr Controller can
  choose to use whatever Host running on any platform they prefer. For example,
  the host can be the Linux BLE Host stack (BlueZ) running on any processor
  capable of supporting Linux. The Host processor may of course also run Zephyr
  and the Zephyr OS BLE Host. Conversely, combining an IC running the Zephyr
  Host with an external Controller that does not run Zephyr is also supported.

.. _bluetooth-build-types:

Build Types
===========

The Zephyr software stack as an RTOS is highly configurable, and in particular,
the BLE subsystem can be configured in multiple ways during the build process to
include only the features and layers that are required to reduce RAM and ROM
footprint as well as power consumption. Here's a short list of the different
BLE-enabled builds that can be produced from the Zephyr project codebase:

* **Controller-only build**: When built as a BLE Controller, Zephyr includes
  the Link Layer and a special application. This application is different
  depending on the physical transport chosen for HCI:

  * :ref:`hci_uart <bluetooth-hci-uart-sample>`
  * :ref:`hci_usb <bluetooth-hci-usb-sample>`
  * :ref:`hci_spi <bluetooth-hci-spi-sample>`

  This application acts as a bridge between the UART, SPI or USB peripherals and
  the Controller subsystem, listening for HCI commands, sending application data
  and responding with events and received data.  A build of this type sets the
  following Kconfig option values:

  * :kconfig:option:`CONFIG_BT` ``=y``
  * :kconfig:option:`CONFIG_BT_HCI` ``=y``
  * :kconfig:option:`CONFIG_BT_HCI_RAW` ``=y``
  * :kconfig:option:`CONFIG_BT_CTLR` ``=y``
  * :kconfig:option:`CONFIG_BT_LL_SW_SPLIT` ``=y`` (if using the open source Link Layer)

* **Host-only build**: A Zephyr OS Host build will contain the Application and
  the BLE Host, along with an HCI driver (UART or SPI) to interface with an
  external Controller chip.
  A build of this type sets the following Kconfig option values:

  * :kconfig:option:`CONFIG_BT` ``=y``
  * :kconfig:option:`CONFIG_BT_HCI` ``=y``
  * :kconfig:option:`CONFIG_BT_CTLR` ``=n``

  All of the samples located in ``samples/bluetooth`` except for the ones
  used for Controller-only builds can be built as Host-only

* **Combined build**: This includes the Application, the Host and the
  Controller, and it is used exclusively for single-chip (SoC) configurations.
  A build of this type sets the following Kconfig option values:

  * :kconfig:option:`CONFIG_BT` ``=y``
  * :kconfig:option:`CONFIG_BT_HCI` ``=y``
  * :kconfig:option:`CONFIG_BT_CTLR` ``=y``
  * :kconfig:option:`CONFIG_BT_LL_SW_SPLIT` ``=y`` (if using the open source Link Layer)

  All of the samples located in ``samples/bluetooth`` except for the ones
  used for Controller-only builds can be built as Combined

The picture below shows the SoC or single-chip configuration when using a Zephyr
combined build (a build that includes both a BLE Host and a Controller in the
same firmware image that is programmed onto the chip):

.. figure:: ../../../../connectivity/bluetooth/img/ble_cfg_single.png
   :align: center
   :alt: BLE Combined build on a single chip

   A Combined build on a Single-Chip configuration

When using connectivity or dual-chip configurations, several Host and Controller
combinations are possible, some of which are depicted below:

.. figure:: ../../../../connectivity/bluetooth/img/ble_cfg_dual.png
   :align: center
   :alt: BLE dual-chip configuration builds

   Host-only and Controller-only builds on dual-chip configurations

When using a Zephyr Host (left side of image), two instances of Zephyr OS
must be built with different configurations, yielding two separate images that
must be programmed into each of the chips respectively. The Host build image
contains the application, the BLE Host and the selected HCI driver (UART or
SPI), while the Controller build runs either the
:ref:`hci_uart <bluetooth-hci-uart-sample>`, or the
:ref:`hci_spi <bluetooth-hci-spi-sample>` app to provide an interface to
the BLE Controller.

This configuration is not limited to using a Zephyr OS Host, as the right side
of the image shows. One can indeed take one of the many existing GNU/Linux
distributions, most of which include Linux's own BLE Host (BlueZ), to connect it
via UART or USB to one or more instances of the Zephyr OS Controller build.
BlueZ as a Host supports multiple Controllers simultaneously for applications
that require more than one BLE radio operating at the same time but sharing the
same Host stack.

Source tree layout
******************

The stack is split up as follows in the source tree:

``subsys/bluetooth/host``
  :ref:`The host stack <bluetooth_le_host>`. This is where the HCI command and
  event handling as well as connection tracking happens. The implementation of
  the core protocols such as L2CAP, ATT, and SMP is also here.

``subsys/bluetooth/controller``
  :ref:`Bluetooth LE Controller <bluetooth-ctlr-arch>` implementation.
  Implements the controller-side of HCI, the Link Layer as well as access to the
  radio transceiver.

``include/bluetooth/``
  :ref:`Public API <bluetooth_api>` header files. These are the header files
  applications need to include in order to use Bluetooth functionality.

``drivers/bluetooth/``
  HCI transport drivers. Every HCI transport needs its own driver. For example,
  the two common types of UART transport protocols (3-Wire and 5-Wire)
  have their own drivers.

``samples/bluetooth/``
  :ref:`Sample Bluetooth code <bluetooth-samples>`. This is a good reference to
  get started with Bluetooth application development.

``tests/bluetooth/``
  Test applications. These applications are used to verify the
  functionality of the Bluetooth stack, but are not necessary the best
  source for sample code (see ``samples/bluetooth`` instead).

``doc/connectivity/bluetooth/``
  Extra documentation, such as PICS documents.

.. _Bluetooth Specification: https://www.bluetooth.com/specifications/bluetooth-core-specification

Part 3

한국어 전문 번역

Stack architecture 개요

Zephyr Bluetooth protocol stack의 software architecture를 설명합니다.

BLE layer

완전한 Bluetooth Low Energy protocol stack은 세 layer로 구성됩니다.

  • Host: Application 바로 아래의 non-real-time network·transport protocol 집합입니다. Application이 peer와 표준적이고 상호 운용 가능한 방식으로 통신하게 합니다.
  • Controller: Radio hardware와 함께 표준 over-the-air 통신을 제공하는 low-level real-time Link Layer(LE LL)입니다. Packet 수신·송신 scheduling, data delivery와 LL control procedure를 처리합니다.
  • Radio Hardware: Link Layer firmware가 2.4 GHz band에서 송수신하도록 필요한 analog·digital baseband block을 구현합니다.

Host Controller Interface

Bluetooth Specification은 Host와 Controller가 통신할 형식인 Host Controller Interface(HCI)를 정의합니다. HCI는 UART, SPI, USB 같은 물리 transport 위에 구현할 수 있고 Host가 보낼 command, Controller가 반환할 event, over-the-air user/protocol data 형식을 규정합니다. 덕분에 서로 다른 vendor의 Host와 Controller를 표준 방식으로 조합할 수 있습니다. 원문 기준 specification은 Bluetooth Core Specification입니다.

구성 방식

  • Single-chip configuration: Microcontroller 하나가 application, Host, Controller와 Radio Hardware를 모두 구현하는 SoC 방식입니다. Host와 Controller는 RAM의 function call과 queue로 직접 통신하며 내부 HCI 흐름은 implementation-specific일 수 있습니다. Footprint와 power consumption을 최소화해야 하는 설계에 적합합니다.
  • Dual-chip configuration: 한 IC는 application+Host, 다른 IC는 Controller+Radio를 실행하는 connectivity-chip 방식입니다. 표준 HCI 덕분에 Zephyr Controller에 Linux BlueZ 등 원하는 Host를 조합하거나, 반대로 Zephyr Host에 외부 non-Zephyr Controller를 연결할 수 있습니다.

Build type

Zephyr BLE subsystem은 필요한 layer와 feature만 build해 RAM·ROM footprint와 power consumption을 줄일 수 있습니다.

Controller-only build

Link Layer와 HCI transport bridge application을 포함합니다. 선택 transport에 따라 hci_uart, hci_usb 또는 hci_spi application이 peripheral과 Controller 사이에서 HCI command, application data, event와 수신 data를 전달합니다.

  • CONFIG_BT=y
  • CONFIG_BT_HCI=y
  • CONFIG_BT_HCI_RAW=y
  • CONFIG_BT_CTLR=y
  • CONFIG_BT_LL_SW_SPLIT=y (open-source Link Layer 사용 시)

Host-only build

Application과 BLE Host, 외부 Controller chip에 연결할 UART/SPI HCI driver를 포함합니다. Controller-only sample을 제외한 samples/bluetooth sample을 Host-only로 build할 수 있습니다.

  • CONFIG_BT=y
  • CONFIG_BT_HCI=y
  • CONFIG_BT_CTLR=n

Combined build

Application, Host와 Controller를 모두 포함하며 single-chip SoC에서만 사용합니다. Controller-only sample을 제외한 samples/bluetooth sample을 Combined로 build할 수 있습니다.

  • CONFIG_BT=y
  • CONFIG_BT_HCI=y
  • CONFIG_BT_CTLR=y
  • CONFIG_BT_LL_SW_SPLIT=y (open-source Link Layer 사용 시)

다음 그림은 한 firmware image에 BLE Host와 Controller를 함께 넣어 chip에 program하는 single-chip Combined build입니다.

Single chip BLE Combined build
Single-chip configuration의 Combined build.

Dual-chip에서는 Host-only와 Controller-only image를 각각 다른 chip에 program하며 다양한 조합이 가능합니다.

Dual chip BLE Host and Controller builds
Dual-chip configuration의 Host-only와 Controller-only build.

Zephyr Host를 쓰면 서로 다른 configuration으로 Zephyr를 두 번 build합니다. Host image는 application, BLE Host와 UART/SPI HCI driver를 포함하고 Controller image는 hci_uart 또는 hci_spi application으로 BLE Controller interface를 제공합니다.

Zephyr Host로 제한되지 않습니다. GNU/Linux의 BlueZ Host를 UART 또는 USB로 하나 이상의 Zephyr Controller build에 연결할 수 있으며, BlueZ는 같은 Host stack을 공유하면서 여러 BLE radio를 동시에 운용하는 multiple Controller도 지원합니다.

Source tree layout

subsys/bluetooth/host
HCI command/event 처리, connection tracking, L2CAP·ATT·SMP core protocol 구현.
subsys/bluetooth/controller
HCI Controller 쪽, Link Layer와 radio transceiver 접근 구현.
include/bluetooth/
Application이 Bluetooth 기능을 사용할 때 include하는 public API header.
drivers/bluetooth/
HCI transport driver. 3-Wire와 5-Wire UART처럼 transport protocol마다 별도 driver가 필요합니다.
samples/bluetooth/
Bluetooth application 개발을 시작할 때 참고할 sample code.
tests/bluetooth/
Stack 기능 검증용 test application이며 sample code의 최적 출처는 아닙니다.
doc/connectivity/bluetooth/
PICS 등 추가 문서.

Source

출처

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