Skip to content

Commit 0d208fb

Browse files
committed
tests: Bluetooth: tester: Add info on running with native_sim
Add a few useful commands and information when running the BT Tester with native_sim, either with or without the Zephyr controller. Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
1 parent 5679689 commit 0d208fb

File tree

2 files changed

+132
-67
lines changed

2 files changed

+132
-67
lines changed

doc/connectivity/bluetooth/autopts/autopts-linux.rst

Lines changed: 73 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -26,36 +26,18 @@ For running with QEMU or :zephyr:board:`native_sim <native_sim>`, see :ref:`blue
2626
Setup Linux
2727
***********
2828

29-
Install nrftools (only required in the actual hardware test mode)
30-
*****************************************************************
29+
Please follow :ref:`getting_started` on how to setup Linux for building and flashing applications.
3130

32-
Download latest nrftools (version >= 10.12.1) from site
33-
https://www.nordicsemi.com/Software-and-tools/Development-Tools/nRF-Command-Line-Tools/Download.
34-
35-
.. image:: download_nrftools_linux.png
36-
:height: 350
37-
:width: 600
38-
:align: center
39-
40-
After you extract archive, you will see 2 .deb files, e.g.:
41-
42-
- JLink_Linux_V688a_x86_64.deb
43-
44-
- nRF-Command-Line-Tools_10_12_1_Linux-amd64.deb
45-
46-
and README.md. To install the tools, double click on each .deb file or follow
47-
instructions from README.md.
48-
49-
Setup Windows 10 virtual machine
50-
********************************
31+
Setup Windows 10/11 virtual machine
32+
***********************************
5133

5234
Choose and install your hypervisor like VMWare Workstation(preferred) or
5335
VirtualBox. On VirtualBox could be some issues, if your host has fewer than 6 CPU.
5436

5537
Create Windows virtual machine instance. Make sure it has at least 2 cores and
5638
installed guest extensions.
5739

58-
Setup tested with VirtualBox 7.1.4 and VMWare Workstation 16.1.1 Pro.
40+
Setup tested with VirtualBox 7.2.4 and VMWare Workstation 16.1.1 Pro.
5941

6042
Update Windows
6143
==============
@@ -186,10 +168,10 @@ consoles. We will use Git Bash as Windows terminal.
186168
:width: 400
187169
:align: center
188170

189-
Install PTS 8
190-
=============
171+
Install PTS
172+
===========
191173

192-
On Windows virtual machine, install latest PTS from https://www.bluetooth.org.
174+
On Windows virtual machine, install the latest PTS from https://pts.bluetooth.com/download.
193175
Remember to install drivers from installation directory
194176
"C:/Program Files (x86)/Bluetooth SIG/Bluetooth PTS/PTS Driver/win64/CSRBlueCoreUSB.inf"
195177

@@ -245,16 +227,6 @@ Connect devices (only required in the actual hardware test mode)
245227
:width: 500
246228
:align: center
247229

248-
Flash board (only required in the actual hardware test mode)
249-
************************************************************
250-
251-
On Linux, go to ~/zephyrproject. There should be already ~/zephyrproject/build
252-
directory. Flash board:
253-
254-
.. code-block::
255-
256-
west flash
257-
258230
Setup auto-pts project
259231
**********************
260232

@@ -279,7 +251,6 @@ Install required python modules:
279251
.. code-block::
280252
281253
cd auto-pts
282-
pip3 install --user wheel
283254
pip3 install --user -r autoptsclient_requirements.txt
284255
285256
Autopts server on Windows virtual machine
@@ -301,9 +272,14 @@ Install required python modules:
301272
Restart virtual machine.
302273

303274
Running AutoPTS
304-
****************
275+
***************
276+
277+
Please follow the information from
278+
https://github.com/zephyrproject-rtos/zephyr/tree/main/tests/bluetooth/tester on how to build,
279+
flash and run the Bluetooth Tester application.
305280

306-
Server and client by default will run on localhost address. Run server:
281+
Server and client by default will run on localhost address.
282+
Run the server in the Windows virtual machine:
307283

308284
.. code-block::
309285
@@ -314,59 +290,89 @@ Server and client by default will run on localhost address. Run server:
314290
:width: 700
315291
:align: center
316292

317-
Testing Zephyr Host Stack on QEMU:
293+
See also https://github.com/auto-pts/auto-pts for additional information on how to run auto-pts.
294+
295+
Testing Zephyr Host Stack on hardware
296+
=====================================
318297

319298
.. code-block::
320299
321-
# A Bluetooth controller needs to be mounted.
322-
# For running with HCI UART, please visit: https://docs.zephyrproject.org/latest/samples/bluetooth/hci_uart/README.html#bluetooth-hci-uart
300+
python ./autoptsclient-zephyr.py zephyr-master -t /dev/ttyACM0 -b BOARD -i SERVER_IP -l LOCAL_IP
323301
324-
python ./autoptsclient-zephyr.py "C:\Users\USER_NAME\Documents\Profile Tuning Suite\PTS_PROJECT\PTS_PROJECT.pqw6" \
325-
~/zephyrproject/build/zephyr/zephyr.elf -i SERVER_IP -l LOCAL_IP
302+
Where ``/dev/ttyACM0`` is the tty for the board,
303+
``BOARD`` is the board to use (e.g. ``nrf53_audio``),
304+
``SERVER_IP`` is the IP of the AutoPTS server,
305+
``LOCAL_IP`` is the local IP of the Linux machine.
326306

307+
Testing Zephyr Host Stack on QEMU
308+
=================================
327309

328-
Testing Zephyr Host Stack on :zephyr:board:`native_sim <native_sim>`:
310+
A Bluetooth controller needs to be mounted.
311+
For running with HCI UART, please visit :zephyr:code-sample:`bluetooth_hci_uart`.
329312

330313
.. code-block::
331314
332-
# A Bluetooth controller needs to be mounted.
333-
# For running with HCI UART, please visit: https://docs.zephyrproject.org/latest/samples/bluetooth/hci_uart/README.html#bluetooth-hci-uart
315+
python ./autoptsclient-zephyr.py zephyr-master BUILD_DIR/zephyr/zephyr.elf -i SERVER_IP -l LOCAL_IP
334316
335-
west build -b native_sim zephyr/tests/bluetooth/tester/ -DEXTRA_CONF_FILE=overlay-native.conf
317+
Where ``BUILD_DIR`` is the build directory,
318+
``SERVER_IP`` is the IP of the AutoPTS server,
319+
``LOCAL_IP`` is the local IP of the Linux machine.
336320

337-
sudo python ./autoptsclient-zephyr.py "C:\Users\USER_NAME\Documents\Profile Tuning Suite\PTS_PROJECT\PTS_PROJECT.pqw6" \
338-
~/zephyrproject/build/zephyr/zephyr.exe -i SERVER_IP -l LOCAL_IP --hci 0
321+
Testing Zephyr Host Stack on :zephyr:board:`native_sim <native_sim>`
322+
====================================================================
339323

324+
When tester application has been built for :zephyr:board:`native_sim <native_sim>` it produces a
325+
``zephyr.exe`` file, that can be run as a native Linux application.
326+
Depending on your system,
327+
you may need to perform the following steps to successfully run ``zephyr.exe``.
340328

341-
Testing Zephyr combined (controller + host) build on nRF52:
329+
Setting capabilities
330+
--------------------
342331

343-
.. note::
332+
Since the application will need access to connect to a socket for HCI,
333+
you may need to perform the following
344334

345-
If the error "ImportError: No module named pywintypes" appeared after the fresh setup,
346-
uninstall and install the pywin32 module:
335+
.. code-block::
347336
348-
.. code-block::
337+
setcap cap_net_raw,cap_net_admin,cap_sys_admin+ep zephyr.exe
349338
350-
pip install --upgrade --force-reinstall pywin32
339+
This is not required if you run ``zephyr.exe`` or ``./autoptsclient-zephyr.py`` with e.g. ``sudo``.
351340

352-
Run client:
341+
Downing the HCI controller
342+
--------------------------
343+
344+
You may also need to "down" or "power off" the HCI controller before running ``zephyr.exe``.
345+
This can be done either with ``hciconfig`` as
353346

354347
.. code-block::
355348
356-
python ./autoptsclient-zephyr.py zephyr-master ~/zephyrproject/build/zephyr/zephyr.elf -t /dev/ACM0 \
357-
-b nrf52 -l 192.168.2.1 -i 192.168.2.2
349+
hciconfig hciX down
358350
359-
.. image:: autoptsclient_run_2.png
360-
:height: 100
361-
:width: 800
362-
:align: center
351+
Where ``hciX`` is a value like ``hci0``. You may run ``hciconfig`` to get a list of your HCI devices.
363352

364-
At the first run, when Windows asks, enable connection through firewall:
353+
Since ``hciconfig`` is deprecated on some systems, you may need to use
365354

366-
.. image:: allow_firewall_2.png
367-
:height: 450
368-
:width: 600
369-
:align: center
355+
.. code-block::
356+
357+
btmgmt -i hciX power off
358+
359+
Similar to ``hciconfig``, ``btmgmt info`` may be used to list current controllers and their states.
360+
361+
Both ``hciconfig`` and ``btmgmt`` may require ``sudo`` when powering down a controller.
362+
363+
Running the client
364+
------------------
365+
366+
The application can be run as
367+
368+
.. code-block::
369+
370+
python ./autoptsclient-zephyr.py zephyr-master --hci HCI BUILD_DIR/zephyr/zephyr.exe -i SERVER_IP -l LOCAL_IP
371+
372+
Where ``HCI`` is the HCI index, e.g. ``0`` or ``1``,
373+
``BUILD_DIR`` is the build directory,
374+
``SERVER_IP`` is the IP of the AutoPTS server,
375+
``LOCAL_IP`` is the local IP of the Linux machine.
370376

371377
Troubleshooting
372378
****************

tests/bluetooth/tester/README.rst

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,72 @@ target.
8888
Use serial client, e.g. PUTTY to communicate over the serial port
8989
(typically /dev/ttyUSBx) with the tester using BTP.
9090

91+
Building and running on :zephyr:board:`native_sim <native_sim>` on Linux
92+
************************************************************************
93+
94+
It is possible to build and run the tester application using the
95+
:zephyr:board:`native_sim <native_sim>` board, and any compatible HCI controller.
96+
This has the advantage of allowing the use of Linux debugging tools like valgrind and gdb,
97+
as well as tools like btmon.
98+
It is also faster to apply changes to the code,
99+
as building for :zephyr:board:`native_sim <native_sim>` is usually faster,
100+
and there is no flashing step involved.
101+
102+
Building for :zephyr:board:`native_sim <native_sim>` is just
103+
104+
.. code-block::
105+
106+
west build -b native_sim
107+
108+
Which will generate a zephyr.exe file that can be executed as
109+
110+
.. code-block::
111+
112+
zephyr.exe --bt-dev=hciX
113+
114+
Where ``hciX`` is the HCI controller (like ``hci0``).
115+
However for the purpose of running the tester application with auto-pts,
116+
running the application is left to the auto-pts client.
117+
118+
119+
Building the Zephyr controller for a :zephyr:board:`native_sim <native_sim>` host on Linux
120+
==========================================================================================
121+
122+
To build and flash the Zephyr controller as an HCI controller usable by Linux,
123+
either the :zephyr:code-sample:`bluetooth_hci_uart` or :zephyr:code-sample:`bluetooth_hci_usb`
124+
samples can be used.
125+
See also :ref:`bluetooth-tools`.
126+
When building these samples, the tester application controller overlay should be supplied.
127+
For example
128+
129+
.. code-block::
130+
131+
west build -b nrf5340_audio_dk/nrf5340/cpunet -d ${ZEPHYR_BASE}/build/nrf5340_audio_dk_nrf5340_cpunet ${ZEPHYR_BASE}/samples/bluetooth/hci_ipc/ -- -DEXTRA_CONF_FILE=${ZEPHYR_BASE}/tests/bluetooth/tester/overlay-bt_ll_sw_split.conf
132+
west flash -d ${ZEPHYR_BASE}/build/nrf5340_audio_dk_nrf5340_cpunet
133+
west build -b nrf5340_audio_dk/nrf5340/cpuapp -d ${ZEPHYR_BASE}/build/nrf5340_audio_dk_nrf5340_cpuapp ${ZEPHYR_BASE}/samples/bluetooth/hci_uart/
134+
west flash -d ${ZEPHYR_BASE}/build/nrf5340_audio_dk_nrf5340_cpuapp
135+
136+
Will build and prepare a nRF5340 Audio DK to be an HCI controller over UART.
137+
138+
For single core boards like the nRF52840 DK it is a bit simpler and can be done like
139+
140+
.. code-block::
141+
142+
west build -b nrf52840dk/nrf52840 ${ZEPHYR_BASE}/samples/bluetooth/hci_uart/ -- -DEXTRA_CONF_FILE=${ZEPHYR_BASE}/tests/bluetooth/tester/overlay-bt_ll_sw_split.conf
143+
west flash
144+
145+
The :zephyr:code-sample:`bluetooth_hci_usb` sample can also be used,
146+
but support for Bluetooth Isochronous channels is not yet fully supported.
147+
91148
Building for LE Audio
92149
*********************
93150

94151
The tester application can be built with support for BT LE Audio by applying the
95152
the ``overlay-le-audio.conf`` and ``hci_ipc.conf`` with ``--sysbuild`` for the supported boards,
96153
e.g.:
97154

155+
.. code-block::
156+
98157
west build -b nrf5340dk/nrf5340/cpuapp --sysbuild \
99158
-- -DEXTRA_CONF_FILE=overlay-le-audio.conf;hci_ipc.conf
100159

0 commit comments

Comments
 (0)