Part 1
요약·해설
1 Mbit/s RTS/CTS, btattach, RTT debug와 dual-board Devicetree 연결을 설명합니다.
UART_ASYNC_API
H:4
1 Mbit/s
Part 2
접을 수 있는 영어 원문 전체
영어 원문 전체 펼치기
02690F45D64AB306196D4EA317D4DE20D849FE2A66D65A9BB94B34688196DF6D
.. _bluetooth-hci-uart-async-sample:
Bluetooth: HCI UART based on ASYNC UART
#######################################
Expose a Zephyr Bluetooth Controller over a standard Bluetooth HCI UART interface.
This sample performs the same basic function as the HCI UART sample, but it uses the UART_ASYNC_API
instead of UART_INTERRUPT_DRIVEN API. Not all boards implement both UART APIs, so the board support
of the HCI UART sample may be different.
Requirements
************
* A board with BLE support
Default UART settings
*********************
By default the controller builds use the following settings:
* Baudrate: 1Mbit/s
* 8 bits, no parity, 1 stop bit
* Hardware Flow Control (RTS/CTS) enabled
Building and Running
********************
This sample can be found under :zephyr_file:`samples/bluetooth/hci_uart_async`
in the Zephyr tree and is built as a standard Zephyr application.
Using the controller with emulators and BlueZ
*********************************************
The instructions below show how to use a Nordic nRF5x device as a Zephyr BLE
controller and expose it to Linux's BlueZ.
First, make sure you have a recent BlueZ version installed by following the
instructions in the :ref:`bluetooth_bluez` section.
Now build and flash the sample for the Nordic nRF5x board of your choice.
All of the Nordic Development Kits come with a Segger IC that provides a
debugger interface and a CDC ACM serial port bridge. More information can be
found in :ref:`nordic_segger`.
For example, to build for the nRF52832 Development Kit:
.. zephyr-app-commands::
:zephyr-app: samples/bluetooth/hci_uart_async
:board: nrf52dk/nrf52832
:goals: build flash
.. _bluetooth-hci-uart-async-qemu-posix:
Using the controller with QEMU or native_sim
============================================
In order to use the HCI UART controller with QEMU or :ref:`native_sim <native_sim>` you will need
to attach it to the Linux Host first. To do so simply build the sample and
connect the UART to the Linux machine, and then attach it with this command:
.. code-block:: console
sudo btattach -B /dev/ttyACM0 -S 1000000 -R
.. note::
Depending on the serial port you are using you will need to modify the
``/dev/ttyACM0`` string to point to the serial device your controller is
connected to.
.. note::
The ``-R`` flag passed to ``btattach`` instructs the kernel to avoid
interacting with the controller and instead just be aware of it in order
to proxy it to QEMU later.
If you are running :file:`btmon` you should see a brief log showing how the
Linux kernel identifies the attached controller.
Once the controller is attached follow the instructions in the
:ref:`bluetooth_qemu_native` section to use QEMU with it.
.. _bluetooth-hci-uart-async-bluez:
Using the controller with BlueZ
===============================
In order to use the HCI UART controller with BlueZ you will need to attach it
to the Linux Host first. To do so simply build the sample and connect the
UART to the Linux machine, and then attach it with this command:
.. code-block:: console
sudo btattach -B /dev/ttyACM0 -S 1000000
.. note::
Depending on the serial port you are using you will need to modify the
``/dev/ttyACM0`` string to point to the serial device your controller is
connected to.
If you are running :file:`btmon` you should see a comprehensive log showing how
BlueZ loads and initializes the attached controller.
Once the controller is attached follow the instructions in the
:ref:`bluetooth_ctlr_bluez` section to use BlueZ with it.
Debugging the controller
========================
The sample can be debugged using RTT since the UART is reserved used by this
application. To enable debug over RTT the debug configuration file can be used.
.. code-block:: console
west build samples/bluetooth/hci_uart_async -- -DEXTRA_CONFIG='debug.mixin.conf'
Then attach RTT as described here: :ref:`Using Segger J-Link <Using Segger J-Link>`
Using the controller with the Zephyr host
=========================================
This describes how to hook up a board running this sample to a board running
an application that uses the Zephyr host.
On the controller side, the `zephyr,bt-c2h-uart` DTS property (in the `chosen`
block) is used to select which uart device to use. For example if we want to
keep the console logs, we can keep console on uart0 and the HCI on uart1 like
so:
.. code-block:: dts
/ {
chosen {
zephyr,console = &uart0;
zephyr,shell-uart = &uart0;
zephyr,bt-c2h-uart = &uart1;
};
};
On the host application, some config options need to be used to select the H4
driver instead of the built-in controller:
.. code-block:: cfg
CONFIG_BT_HCI=y
CONFIG_BT_CTLR=n
Similarly, the `zephyr,bt-hci` DTS property selects which HCI instance to use.
The UART needs to have as its child node a HCI UART node:
.. code-block:: dts
/ {
chosen {
zephyr,console = &uart0;
zephyr,shell-uart = &uart0;
zephyr,bt-hci = &bt_hci_uart;
};
};
&uart1 {
status = "okay";
bt_hci_uart: bt_hci_uart {
compatible = "zephyr,bt-hci-uart";
status = "okay";
};
};
Part 3
한국어 전문 번역
개요
표준 Bluetooth HCI UART interface를 통해 Zephyr Bluetooth Controller를 외부에 노출하는 sample입니다.
기본 역할은 HCI UART sample과 같지만 UART_INTERRUPT_DRIVEN API 대신 UART_ASYNC_API를 사용합니다. 모든 board가 두 UART API를 모두 구현하는 것은 아니므로, 일반 HCI UART sample과 이 sample이 지원하는 board 목록은 서로 다를 수 있습니다.
요구사항
- BLE를 지원하는 board
기본 UART 설정
Controller build는 기본적으로 다음 설정을 사용합니다.
- Baudrate: 1 Mbit/s
- 8 data bits, parity 없음, 1 stop bit
- Hardware Flow Control(RTS/CTS): 활성화
Build와 실행
이 sample은 Zephyr tree의 samples/bluetooth/hci_uart_async에 있으며 표준 Zephyr application으로 build합니다.
Nordic nRF5x board에 build
아래 절차는 Nordic nRF5x device를 Zephyr BLE Controller로 사용해 Linux BlueZ에 노출합니다. 먼저 최신 BlueZ를 설치하십시오. Nordic Development Kit의 Segger IC는 debugger interface와 CDC ACM serial port bridge를 제공합니다.
예를 들어 nRF52832 Development Kit용으로 build하고 flash하려면 다음 명령을 실행합니다.
# From the root of the zephyr repository
west build -b nrf52dk/nrf52832 samples/bluetooth/hci_uart_async
west flash
QEMU 또는 native_sim에서 사용
HCI UART Controller를 QEMU 또는 native_sim에서 사용하려면 sample을 build한 뒤 UART를 Linux machine에 연결하고 먼저 Linux Host에 attach해야 합니다.
sudo btattach -B /dev/ttyACM0 -S 1000000 -R
사용 중인 serial port에 맞게 /dev/ttyACM0을 controller가 연결된 serial device로 바꾸십시오.
-R flag는 kernel이 controller와 직접 상호작용하지 않고, 나중에 QEMU로 proxy할 수 있도록 controller를 인식만 하게 합니다. btmon을 실행 중이면 Linux kernel이 attach된 controller를 식별하는 짧은 log가 보입니다. 그 뒤 QEMU Bluetooth native 절차를 따릅니다.
BlueZ에서 사용과 debugging
BlueZ에서 사용하려면 UART를 Linux machine에 연결한 뒤 다음과 같이 attach합니다.
sudo btattach -B /dev/ttyACM0 -S 1000000
Serial device가 다르면 /dev/ttyACM0을 바꾸십시오. btmon에서는 BlueZ가 controller를 load하고 initialize하는 자세한 log를 볼 수 있습니다. 그 뒤 BlueZ Controller 사용 절차를 따릅니다.
Application이 UART를 전용으로 사용하므로 RTT로 debug할 수 있습니다. RTT debug configuration을 활성화하려면 다음 명령을 사용한 뒤 Segger J-Link 절차에 따라 RTT를 attach합니다.
west build samples/bluetooth/hci_uart_async -- -DEXTRA_CONFIG='debug.mixin.conf'
Zephyr Host와 Controller 연결
이 sample을 실행하는 board를 Zephyr Host application board에 연결할 수 있습니다. Controller 쪽에서는 chosen block의 zephyr,bt-c2h-uart DTS property로 사용할 UART를 선택합니다. 예를 들어 console은 uart0에 유지하고 HCI는 uart1에 둘 수 있습니다.
/ {
chosen {
zephyr,console = &uart0;
zephyr,shell-uart = &uart0;
zephyr,bt-c2h-uart = &uart1;
};
};
Host application에서는 built-in controller 대신 H:4 driver를 선택합니다.
CONFIG_BT_HCI=y
CONFIG_BT_CTLR=n
Host의 zephyr,bt-hci DTS property는 사용할 HCI instance를 선택합니다. UART에는 HCI UART child node가 있어야 합니다.
/ {
chosen {
zephyr,console = &uart0;
zephyr,shell-uart = &uart0;
zephyr,bt-hci = &bt_hci_uart;
};
};
&uart1 {
status = "okay";
bt_hci_uart: bt_hci_uart {
compatible = "zephyr,bt-hci-uart";
status = "okay";
};
};
Source
출처
영어 원문에는 문단, 문서 지시문, 표, 코드, 코드 심벌, 경로를 그대로 보존했습니다.