From 73a7568b6fa6920725b6eceb8e651084a2d7b341 Mon Sep 17 00:00:00 2001 From: Graham Wacey Date: Mon, 10 Mar 2025 08:40:32 +0000 Subject: [PATCH] applications: nrf5340_audio: Buildprog transport mandatory OCT-3328 Now forces the -t/--transport option in buildprog as mandatory Signed-off-by: Graham Wacey --- applications/nrf5340_audio/CMakeLists.txt | 5 ++++ .../overlay-broadcast_sink.conf | 1 + .../overlay-broadcast_source.conf | 1 + applications/nrf5340_audio/doc/building.rst | 26 ++++++++++++------- .../nrf5340_audio/doc/configuration.rst | 15 +---------- .../tools/buildprog/buildprog.py | 15 ++++++----- .../overlay-unicast_client.conf | 1 + .../overlay-unicast_server.conf | 2 ++ .../migration/migration_guide_3.0.rst | 8 +++++- 9 files changed, 44 insertions(+), 30 deletions(-) diff --git a/applications/nrf5340_audio/CMakeLists.txt b/applications/nrf5340_audio/CMakeLists.txt index cf697cd609c0..43af81f77014 100644 --- a/applications/nrf5340_audio/CMakeLists.txt +++ b/applications/nrf5340_audio/CMakeLists.txt @@ -12,6 +12,11 @@ add_compile_definitions(GATEWAY=2) find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) +# Test a configuration file option has been given +if(NOT DEFINED EXTRA_CONF_FILE) + message(FATAL_ERROR "No configuration file specified, set -- -DEXTRA_CONF_FILE=") +endif() + project(NRF5340_AUDIO) string(TIMESTAMP NRF5340_AUDIO_CORE_APP_COMP_DATE "%a %b %d %H:%M:%S %Y") diff --git a/applications/nrf5340_audio/broadcast_sink/overlay-broadcast_sink.conf b/applications/nrf5340_audio/broadcast_sink/overlay-broadcast_sink.conf index b8b095bc194d..aaf1544f58ff 100644 --- a/applications/nrf5340_audio/broadcast_sink/overlay-broadcast_sink.conf +++ b/applications/nrf5340_audio/broadcast_sink/overlay-broadcast_sink.conf @@ -5,6 +5,7 @@ # CONFIG_TRANSPORT_BIS=y +CONFIG_AUDIO_DEV=1 ## ACL related configs ## CONFIG_BT_OBSERVER=y diff --git a/applications/nrf5340_audio/broadcast_source/overlay-broadcast_source.conf b/applications/nrf5340_audio/broadcast_source/overlay-broadcast_source.conf index 814436987c20..cb2bf56aa3e6 100644 --- a/applications/nrf5340_audio/broadcast_source/overlay-broadcast_source.conf +++ b/applications/nrf5340_audio/broadcast_source/overlay-broadcast_source.conf @@ -5,6 +5,7 @@ # CONFIG_TRANSPORT_BIS=y +CONFIG_AUDIO_DEV=2 CONFIG_BT_CAP_INITIATOR=y CONFIG_BT_AUDIO=y diff --git a/applications/nrf5340_audio/doc/building.rst b/applications/nrf5340_audio/doc/building.rst index f706c3cf09b5..8386432f7634 100644 --- a/applications/nrf5340_audio/doc/building.rst +++ b/applications/nrf5340_audio/doc/building.rst @@ -98,6 +98,10 @@ The building command for running the script requires providing the following par - ``release``, ``debug`` - | :ref:`nrf53_audio_app_configuration_files` | **Note:** For FOTA DFU, you must use :ref:`nrf53_audio_app_building_standard`. + * - Transport type (``-t``) + - Specifies the transport type. + - ``broadcast``, ``unicast`` + - :ref:`nrf53_audio_app_overview_architecture` * - Device type (``-d``) - Specifies the device type. - ``headset``, ``gateway``, ``both`` @@ -107,7 +111,7 @@ For example, the following command builds headset and gateway applications using .. code-block:: console - python buildprog.py -c app -b debug -d both + python buildprog.py -c app -b debug -d both -t unicast The command can be run from any location, as long as the correct path to :file:`buildprog.py` is given. @@ -132,9 +136,9 @@ The command for programming can look as follows: .. code-block:: console - python buildprog.py -c both -b debug -d both -p + python buildprog.py -c both -b debug -d both -t unicast -p -This command builds the headset and the gateway applications with ``debug`` version of both the application core binary and the network core binary - and programs each to its respective core. +This command builds the unicast headset and the gateway applications with ``debug`` version of both the application core binary and the network core binary - and programs each to its respective core. If you want to rebuild from scratch, you can add the ``--pristine`` parameter to the command (west's ``-p`` for cannot be used for a pristine build with the script). .. note:: @@ -143,7 +147,7 @@ If you want to rebuild from scratch, you can add the ``--pristine`` parameter to .. code-block:: console - python buildprog.py -c both -b debug -d both -p --recover_on_fail + python buildprog.py -c both -b debug -d both -t unicast -p --recover_on_fail Getting help ------------ @@ -247,6 +251,8 @@ The application supports the following custom configurations: - | Builds the debug version of the application with the features needed to perform DFU over Bluetooth LE, and includes bootloaders so that the applications on both the application core and network core can be updated. | See :ref:`nrf53_audio_app_fota` for more information. +.. _nrf53_audio_app_configuration_select_build: + Building the application ======================== @@ -254,10 +260,12 @@ Complete the following steps to build the application: 1. Choose the combination of build flags: - a. Choose the device type by using one of the following options: + a. Choose the device type by using one of the following :ref:`CMake options for extra Kconfig fragments `: - * For headset device: ``-DCONFIG_AUDIO_DEV=1`` - * For gateway device: ``-DCONFIG_AUDIO_DEV=2`` + * For unicast headset: ``-DEXTRA_CONF_FILE=".\unicast_server\overlay-unicast_server.conf"`` + * For unicast gateway: ``-DEXTRA_CONF_FILE=".\unicast_client\overlay-unicast_client.conf"`` + * For broadcast headset: ``-DEXTRA_CONF_FILE=".\broadcast_sink\overlay-broadcast_sink.conf"`` + * For broadcast gateway: ``-DEXTRA_CONF_FILE=".\broadcast_source\overlay-broadcast_source.conf"`` #. Choose the application version (:ref:`nrf53_audio_app_building_config_files`) by using one of the following options: @@ -269,7 +277,7 @@ Complete the following steps to build the application: .. code-block:: console - west build -b nrf5340_audio_dk/nrf5340/cpuapp --pristine -- -DCONFIG_AUDIO_DEV=1 -DFILE_SUFFIX=release + west build -b nrf5340_audio_dk/nrf5340/cpuapp --pristine -- -DEXTRA_CONF_FILE=".\unicast_server\overlay-unicast_server.conf" -DFILE_SUFFIX=release This command creates the build files for headset device directly in the :file:`build` directory. What this means is that you cannot create build files for all devices you want to program, because the subsequent commands will overwrite the files in the :file:`build` directory. @@ -285,7 +293,7 @@ The following command example builds the application for :ref:`nrf53_audio_app_f .. code-block:: console - west build -b nrf5340_audio_dk/nrf5340/cpuapp --pristine -- -DCONFIG_AUDIO_DEV=1 -DFILE_SUFFIX=fota + west build -b nrf5340_audio_dk/nrf5340/cpuapp --pristine -- -DEXTRA_CONF_FILE=".\unicast_server\overlay-unicast_server.conf" -DFILE_SUFFIX=fota The command uses ``-DFILE_SUFFIX=fota`` to pick :file:`prj_fota.conf` instead of the default :file:`prj.conf`. It also uses the ``--pristine`` to clean the existing directory before starting the build process. diff --git a/applications/nrf5340_audio/doc/configuration.rst b/applications/nrf5340_audio/doc/configuration.rst index 3e99a992a336..0444d5681b01 100644 --- a/applications/nrf5340_audio/doc/configuration.rst +++ b/applications/nrf5340_audio/doc/configuration.rst @@ -9,19 +9,6 @@ Configuring the nRF5340 Audio applications |config| -By default, if you have not made any changes to :file:`.conf` files at :file:`applications/nrf5340_audio/`, the nRF5340 :ref:`build script ` builds the :ref:`unicast server (CIS) ` application in the CIS unidirectional mode as a headset (with :kconfig:option:`CONFIG_TRANSPORT_CIS` set to ``y`` and :kconfig:option:`CONFIG_AUDIO_DEV` set to ``1``). - -.. _nrf53_audio_app_configuration_select_build: - -Selecting gateway or headset build -********************************** - -Given the nRF5340 Audio :ref:`application architecture `, the nRF5340 Audio applications can be built for :ref:`either the gateway or the headset role `: - -* The headset build is identified with :kconfig:option:`CONFIG_AUDIO_DEV` Kconfig option set to ``1``. - This is the default configuration. -* The gateway build can be selected by adding :kconfig:option:`CONFIG_AUDIO_DEV` Kconfig option set to ``2`` to the :file:`prj.conf` file. - .. _nrf53_audio_app_configuration_select_bidirectional: Selecting the CIS bidirectional communication @@ -93,7 +80,7 @@ You can use one of the following options, depending on how you decide to build t .. code-block:: console - west build -b nrf5340_audio_dk/nrf5340/cpuapp --pristine -- -DCONFIG_AUDIO_DEV=1 -Dnrf5340_audio_SHIELD=nrf21540ek -Dipc_radio_SHIELD=nrf21540ek + west build -b nrf5340_audio_dk/nrf5340/cpuapp --pristine -- -DEXTRA_CONF_FILE=".\unicast_server\overlay-unicast_server.conf" -Dnrf5340_audio_SHIELD=nrf21540ek -Dipc_radio_SHIELD=nrf21540ek To set the TX power output, use the ``CONFIG_BT_CTLR_TX_PWR_ANTENNA`` and ``CONFIG_MPSL_FEM_NRF21540_TX_GAIN_DB`` Kconfig options in :file:`applications/nrf5340_audio/sysbuild/ipc_radio/prj.conf`. diff --git a/applications/nrf5340_audio/tools/buildprog/buildprog.py b/applications/nrf5340_audio/tools/buildprog/buildprog.py index ce7c2deafb68..5c1ab83720b0 100644 --- a/applications/nrf5340_audio/tools/buildprog/buildprog.py +++ b/applications/nrf5340_audio/tools/buildprog/buildprog.py @@ -107,13 +107,12 @@ def __build_cmd_get(cores: Core, device: AudioDevice, build: BuildType, raise Exception("Invalid core!") if device == AudioDevice.headset: - device_flag = "-DCONFIG_AUDIO_DEV=1" dest_folder = TARGET_DEV_HEADSET_FOLDER elif device == AudioDevice.gateway: - device_flag = "-DCONFIG_AUDIO_DEV=2" dest_folder = TARGET_DEV_GATEWAY_FOLDER else: raise Exception("Invalid device!") + if build == BuildType.debug: release_flag = "" dest_folder /= TARGET_DEBUG_FOLDER @@ -122,6 +121,9 @@ def __build_cmd_get(cores: Core, device: AudioDevice, build: BuildType, dest_folder /= TARGET_RELEASE_FOLDER else: raise Exception("Invalid build type!") + + device_flag = "" + if options.nrf21540: device_flag += " -Dnrf5340_audio_SHIELD=nrf21540ek" device_flag += " -Dipc_radio_SHIELD=nrf21540ek" @@ -139,13 +141,14 @@ def __build_cmd_get(cores: Core, device: AudioDevice, build: BuildType, if options.transport == Transport.broadcast.name: if device == AudioDevice.headset: overlay_flag = f" -DEXTRA_CONF_FILE={BROADCAST_SINK_OVERLAY}" - elif device == AudioDevice.gateway: + else: overlay_flag = f" -DEXTRA_CONF_FILE={BROADCAST_SOURCE_OVERLAY}" - elif options.transport == Transport.unicast.name: + else: if device == AudioDevice.headset: overlay_flag = f" -DEXTRA_CONF_FILE={UNICAST_SERVER_OVERLAY}" - elif device == AudioDevice.gateway: + else: overlay_flag = f" -DEXTRA_CONF_FILE={UNICAST_CLIENT_OVERLAY}" + if os.name == 'nt': release_flag = release_flag.replace('\\', '/') if pristine: @@ -312,7 +315,7 @@ def __main(): parser.add_argument( "-t", "--transport", - type=str, + required = True, choices=[i.name for i in Transport], default=Transport.unicast.name, help="Select the transport type", diff --git a/applications/nrf5340_audio/unicast_client/overlay-unicast_client.conf b/applications/nrf5340_audio/unicast_client/overlay-unicast_client.conf index 36c6c85696d2..69c279d1b283 100644 --- a/applications/nrf5340_audio/unicast_client/overlay-unicast_client.conf +++ b/applications/nrf5340_audio/unicast_client/overlay-unicast_client.conf @@ -5,6 +5,7 @@ # CONFIG_BT_CENTRAL=y +CONFIG_AUDIO_DEV=2 CONFIG_BT_GATT_DYNAMIC_DB=y CONFIG_BT_GATT_CLIENT=y diff --git a/applications/nrf5340_audio/unicast_server/overlay-unicast_server.conf b/applications/nrf5340_audio/unicast_server/overlay-unicast_server.conf index 314361e52b03..dac80b132e0a 100644 --- a/applications/nrf5340_audio/unicast_server/overlay-unicast_server.conf +++ b/applications/nrf5340_audio/unicast_server/overlay-unicast_server.conf @@ -4,6 +4,8 @@ # SPDX-License-Identifier: LicenseRef-Nordic-5-Clause # +CONFIG_AUDIO_DEV=1 + CONFIG_BT_GATT_AUTO_DISCOVER_CCC=y CONFIG_BT_GATT_AUTO_RESUBSCRIBE=n CONFIG_BT_GATT_AUTO_SEC_REQ=n diff --git a/doc/nrf/releases_and_maturity/migration/migration_guide_3.0.rst b/doc/nrf/releases_and_maturity/migration/migration_guide_3.0.rst index 749b15b15c62..121d82d8d6cc 100644 --- a/doc/nrf/releases_and_maturity/migration/migration_guide_3.0.rst +++ b/doc/nrf/releases_and_maturity/migration/migration_guide_3.0.rst @@ -29,7 +29,13 @@ Samples and applications This section describes the changes related to samples and applications. -|no_changes_yet_note| +nRF5340 Audio applications +-------------------------- + +.. toggle:: + + * The :ref:`nrf53_audio_app` :ref:`nrf53_audio_app_building_script` now requires the transport (``-t/--transport``) type to be included. + * The :ref:`nrf53_audio_app` :ref:`nrf53_audio_app_building_standard` now requires an extra :ref:`CMake option to provide extra Kconfig fragments ` to select the device type. Libraries =========