Part 1
요약·해설
Build, Linux attach, RTT debug, Direction Finding, USB UART와 공식 note 불일치를 설명합니다.
H:5 · 3-wire
1 Mbit/s
Disabled
Part 2
접을 수 있는 영어 원문 전체
영어 원문 전체 펼치기
694855955416FE20A8D9FFD6EE87A8FCF030244E5E3005B0F9F2A713AC52AC77
.. _bluetooth-hci-uart-3wire-sample:
Bluetooth: HCI UART 3WIRE
#########################
Overview
*********
Expose the Zephyr Bluetooth controller support over UART to another device/CPU
using the H:5 HCI transport protocol.
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) disabled
Building and Running
********************
This sample can be found under :zephyr_file:`samples/bluetooth/hci_uart_3wire` in the
Zephyr tree, and it 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. This can be very useful for testing
the Zephyr Link Layer with the BlueZ Host. The Zephyr BLE controller can also
provide a modern BLE 5.0 controller to a Linux-based machine for native
BLE support or QEMU-based development.
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 nRF52840 Development Kit:
.. zephyr-app-commands::
:zephyr-app: samples/bluetooth/hci_uart_3wire
:board: nrf52840dk/nrf52840
:goals: build flash
.. _bluetooth-hci-uart-3wire-qemu-posix:
Using the controller with QEMU or native_sim
============================================
In order to use the HCI UART H:5 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 hciattach -n /dev/ttyACM0 3wire 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.
.. note::
If using the BBC micro:bit you will need to modify the baudrate argument
from ``1000000`` to ``115200``.
.. 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-3wire-bluez:
Using the controller with BlueZ
===============================
In order to use the HCI UART H:5 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 hciattach -n /dev/ttyACM0 3wire 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.
.. note::
If using the BBC micro:bit you will need to modify the baudrate argument
from ``1000000`` to ``115200``.
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 otherwise 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_3wire -- -DEXTRA_CONF_FILE='debug.conf'
Then attach RTT as described here: :ref:`Using Segger J-Link <Using Segger J-Link>`
Support for the Direction Finding
=================================
The sample can be built with the support for the BLE Direction Finding.
To enable this feature build this sample for specific board variants that provide
required hardware configuration for the Radio.
.. code-block:: console
west build samples/bluetooth/hci_uart_3wire -b nrf52833dk/nrf52833@df -- -DCONFIG_BT_CTLR_DF=y
You can use following targets:
* ``nrf5340dk/nrf5340/cpunet@df``
* ``nrf52833dk/nrf52833@df``
Check the :ref:`bluetooth_direction_finding_connectionless_rx` and the :ref:`bluetooth_direction_finding_connectionless_tx` for more details.
Using a USB CDC ACM UART
========================
The sample can be configured to use a USB UART instead. See :zephyr_file:`samples/bluetooth/hci_uart_3wire/boards/nrf52840dongle_nrf52840.conf` and :zephyr_file:`samples/bluetooth/hci_uart_3wire/boards/nrf52840dongle_nrf52840.overlay`.
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 H5
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-3wire-uart";
status = "okay";
};
};
Part 3
한국어 전문 번역
개요
H:5 3-wire HCI transport protocol을 사용해 UART를 통해 다른 device 또는 CPU에 Zephyr Bluetooth Controller 지원을 노출합니다.
요구사항
- BLE를 지원하는 board
기본 UART 설정
Controller build는 기본적으로 다음 설정을 사용합니다.
- Baudrate: 1 Mbit/s
- 8 data bits, parity 없음, 1 stop bit
- Hardware Flow Control(RTS/CTS): 비활성화
Build와 실행
Zephyr tree의 samples/bluetooth/hci_uart_3wire에서 이 sample을 찾을 수 있으며 표준 Zephyr application으로 build합니다.
예를 들어 nRF52840 Development Kit용으로 build하고 flash하려면 다음 명령을 실행합니다.
west build -b nrf52840dk/nrf52840 samples/bluetooth/hci_uart_3wire
west flash
Emulator와 BlueZ에서 Controller 사용
아래 절차는 Nordic nRF5x device를 Zephyr BLE Controller로 사용하고 Linux BlueZ에 노출하는 방법을 설명합니다. Zephyr Link Layer를 BlueZ Host와 시험하거나 Linux machine에 BLE 5.0 Controller를 제공해 native BLE 또는 QEMU 개발에 사용할 수 있습니다.
먼저 최신 BlueZ를 설치하십시오. Nordic Development Kit에는 debugger interface와 CDC ACM serial port bridge를 제공하는 Segger IC가 있으므로 선택한 nRF5x board용 sample을 build하고 flash합니다.
QEMU 또는 native_sim에서 사용
HCI UART H:5 Controller를 QEMU 또는 native_sim에서 사용하려면 먼저 UART를 Linux machine에 연결하고 다음 명령으로 Linux Host에 attach합니다.
sudo hciattach -n /dev/ttyACM0 3wire 1000000
사용 중인 serial port에 맞게 /dev/ttyACM0을 controller가 연결된 serial device로 바꾸십시오. BBC micro:bit를 사용한다면 baudrate를 1000000에서 115200으로 바꿉니다.
공식 H:5 문서의 다음 note는 btattach -R가 kernel의 controller 직접 사용을 막고 QEMU proxy용으로 인식만 시킨다고 설명하지만, 위 H:5 명령은 hciattach를 사용하며 -R가 없습니다. 제공된 명령과 설명의 차이를 확인해 적용해야 합니다.
btmon을 실행 중이면 Linux kernel이 attach된 controller를 식별하는 짧은 log가 나타납니다. Attach 후에는 QEMU Bluetooth native 절차를 따르십시오.
BlueZ에서 사용
HCI UART H:5 Controller를 BlueZ에서 사용하려면 UART를 Linux machine에 연결한 뒤 다음 명령으로 Linux Host에 attach합니다.
sudo hciattach -n /dev/ttyACM0 3wire 1000000
Serial device가 다르면 /dev/ttyACM0을 바꾸고, BBC micro:bit에서는 baudrate를 115200으로 바꾸십시오.
btmon을 실행 중이면 BlueZ가 attach된 controller를 load하고 initialize하는 자세한 log가 나타납니다. Attach 후에는 BlueZ Controller 사용 절차를 따르십시오.
Controller debugging
UART는 application이 사용하므로 RTT를 통해 sample을 debug할 수 있습니다. RTT debug configuration을 활성화하려면 다음 명령을 사용합니다.
west build samples/bluetooth/hci_uart_3wire -- -DEXTRA_CONF_FILE='debug.conf'
그런 다음 Segger J-Link 사용 절차에 따라 RTT를 attach합니다.
Direction Finding 지원
BLE Direction Finding을 지원하도록 sample을 build할 수 있습니다. 필요한 Radio hardware configuration을 제공하는 특정 board variant를 사용해 다음과 같이 활성화합니다.
west build samples/bluetooth/hci_uart_3wire -b nrf52833dk/nrf52833@df -- -DCONFIG_BT_CTLR_DF=y
nrf5340dk/nrf5340/cpunet@dfnrf52833dk/nrf52833@df
자세한 내용은 Direction Finding Connectionless RX와 TX sample을 참조하십시오.
USB CDC ACM UART 사용
USB UART를 사용하도록 configuration할 수도 있습니다. samples/bluetooth/hci_uart_3wire/boards/nrf52840dongle_nrf52840.conf와 samples/bluetooth/hci_uart_3wire/boards/nrf52840dongle_nrf52840.overlay를 참조하십시오.
Zephyr Host와 Controller 연결
이 sample을 실행하는 board를 Zephyr Host application을 실행하는 board에 연결하는 방법입니다.
Controller 쪽에서는 chosen block의 zephyr,bt-c2h-uart DTS property로 사용할 UART device를 선택합니다. Console log는 uart0에 두고 HCI는 uart1에 둘 수 있습니다.
/ {
chosen {
zephyr,console = &uart0;
zephyr,shell-uart = &uart0;
zephyr,bt-c2h-uart = &uart1;
};
};
Host application에서는 built-in controller 대신 H:5 driver를 선택하도록 다음 configuration을 사용합니다.
CONFIG_BT_HCI=y
CONFIG_BT_CTLR=n
마찬가지로 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-3wire-uart";
status = "okay";
};
};
Source
출처
영어 원문에는 문단, 문서 지시문, 표, 코드, 코드 심벌, 경로를 그대로 보존했습니다.