Skip to content

Commit 5257a20

Browse files
gWaceykoffes
authored andcommitted
applications: nrf5340_audio: Buildprog, pristine and flashing issue
Buildprog issues with building and programming single cores. Signed-off-by: Graham Wacey <[email protected]>
1 parent c7651e0 commit 5257a20

File tree

5 files changed

+74
-68
lines changed

5 files changed

+74
-68
lines changed

applications/nrf5340_audio/doc/building.rst

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ This eases the process of building and programming images for multiple developme
4848

4949
The script is located in the :file:`applications/nrf5340_audio/tools/buildprog` directory.
5050

51+
.. note::
52+
The :file:`buildprog.py` script is an app-specific script for building and programming multiple kits and cores with various audio application configurations. The script will be deprecated in a future release. The audio applications will gradually shift only to using standard tools for building and programming development kits.
53+
5154
Preparing the JSON file
5255
=======================
5356

@@ -115,9 +118,9 @@ For example, the following command builds headset and gateway applications using
115118
116119
The command can be run from any location, as long as the correct path to :file:`buildprog.py` is given.
117120

118-
The build files are saved in separate subdirectories in the :file:`applications/nrf5340_audio/build` directory.
119-
The script creates a directory for each application version and device type combination.
120-
For example, when running the command above, the script creates the :file:`dev_gateway/build_debug` and :file:`dev_headset/build_debug` directories.
121+
The build files are saved in separate subdirectories in the :file:`applications/nrf5340_audio/tools/build` directory.
122+
The script creates a directory for each transport, device type, core, and version combination.
123+
For example, when running the command above, the script creates the :file:`unicast/gateway/app/debug`, :file:`unicast/gateway/net/debug`, :file:`unicast/headset/app/debug`, :file:`unicast/headset/net/debug` files and directories.
121124

122125
Script parameters for programming
123126
---------------------------------

applications/nrf5340_audio/tools/buildprog/buildprog.py

Lines changed: 37 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,8 @@
4242
os.getenv("AUDIO_KIT_SERIAL_NUMBERS_JSON"))
4343
TARGET_BOARD_NRF5340_AUDIO_DK_APP_NAME = "nrf5340_audio_dk/nrf5340/cpuapp"
4444

45-
TARGET_CORE_APP_FOLDER = NRF5340_AUDIO_FOLDER
46-
TARGET_DEV_HEADSET_FOLDER = NRF5340_AUDIO_FOLDER / "build/dev_headset"
47-
TARGET_DEV_GATEWAY_FOLDER = NRF5340_AUDIO_FOLDER / "build/dev_gateway"
45+
TARGET_AUDIO_FOLDER = NRF5340_AUDIO_FOLDER
46+
TARGET_AUDIO_BUILD_FOLDER = TARGET_AUDIO_FOLDER / "tools/build"
4847

4948
UNICAST_SERVER_OVERLAY = NRF5340_AUDIO_FOLDER / "unicast_server/overlay-unicast_server.conf"
5049
UNICAST_CLIENT_OVERLAY = NRF5340_AUDIO_FOLDER / "unicast_client/overlay-unicast_client.conf"
@@ -90,35 +89,24 @@ def __print_dev_conf(device_list):
9089
print(table)
9190

9291

93-
def __build_cmd_get(cores: Core, device: AudioDevice, build: BuildType,
92+
def __build_cmd_get(core: Core, device: AudioDevice, build: BuildType,
9493
pristine, options):
9594

96-
build_cmd = (f"west build {TARGET_CORE_APP_FOLDER} "
95+
build_cmd = (f"west build {TARGET_AUDIO_FOLDER} "
9796
f"-b {TARGET_BOARD_NRF5340_AUDIO_DK_APP_NAME} "
9897
f"--sysbuild")
99-
if Core.app in cores and Core.net in cores:
100-
# No changes to build command, build both cores
101-
pass
102-
elif Core.app in cores:
98+
99+
if core == Core.app:
103100
build_cmd += " --domain nrf5340_audio"
104-
elif Core.net in cores:
101+
elif core == Core.net:
105102
build_cmd += " --domain ipc_radio"
106103
else:
107104
raise Exception("Invalid core!")
108105

109-
if device == AudioDevice.headset:
110-
dest_folder = TARGET_DEV_HEADSET_FOLDER
111-
elif device == AudioDevice.gateway:
112-
dest_folder = TARGET_DEV_GATEWAY_FOLDER
113-
else:
114-
raise Exception("Invalid device!")
115-
116106
if build == BuildType.debug:
117107
release_flag = ""
118-
dest_folder /= TARGET_DEBUG_FOLDER
119108
elif build == BuildType.release:
120109
release_flag = " -DFILE_SUFFIX=release"
121-
dest_folder /= TARGET_RELEASE_FOLDER
122110
else:
123111
raise Exception("Invalid build type!")
124112

@@ -152,7 +140,9 @@ def __build_cmd_get(cores: Core, device: AudioDevice, build: BuildType,
152140
if os.name == 'nt':
153141
release_flag = release_flag.replace('\\', '/')
154142
if pristine:
155-
build_cmd += " -p"
143+
build_cmd += " --pristine"
144+
145+
dest_folder = TARGET_AUDIO_BUILD_FOLDER / options.transport / device / core / build
156146

157147
return build_cmd, dest_folder, device_flag, release_flag, overlay_flag
158148

@@ -199,12 +189,11 @@ def __find_snr():
199189
def __populate_hex_paths(dev, options):
200190
"""Poplulate hex paths where relevant"""
201191

202-
_, temp_dest_folder, _, _, _ = __build_cmd_get(
203-
Core.app, dev.nrf5340_audio_dk_dev, options.build, options.pristine, options
204-
)
192+
_, temp_dest_folder, _, _, _ = __build_cmd_get(Core.app, dev.nrf5340_audio_dk_dev, options.build, options.pristine, options)
193+
dev.hex_path_app = temp_dest_folder / "nrf5340_audio/zephyr/zephyr.hex"
205194

206-
dev.hex_path_app = temp_dest_folder / "merged.hex"
207-
dev.hex_path_net = temp_dest_folder / "merged_CPUNET.hex"
195+
_, temp_dest_folder, _, _, _ = __build_cmd_get(Core.net, dev.nrf5340_audio_dk_dev, options.build, options.pristine, options)
196+
dev.hex_path_net = temp_dest_folder / "ipc_radio/zephyr/zephyr.hex"
208197

209198

210199
def __finish(device_list):
@@ -248,7 +237,10 @@ def __main():
248237
help="Select which cores to include in build",
249238
)
250239
parser.add_argument(
251-
"--pristine", default=False, action="store_true", help="Will build cleanly"
240+
"--pristine",
241+
default=False,
242+
action="store_true",
243+
help="Will build cleanly"
252244
)
253245
parser.add_argument(
254246
"-b",
@@ -315,7 +307,7 @@ def __main():
315307
parser.add_argument(
316308
"-t",
317309
"--transport",
318-
required = True,
310+
required=True,
319311
choices=[i.name for i in Transport],
320312
default=Transport.unicast.name,
321313
help="Select the transport type",
@@ -384,23 +376,25 @@ def __main():
384376
build_configs = []
385377

386378
if AudioDevice.headset in devices:
387-
build_configs.append(
388-
BuildConf(
389-
core=cores,
390-
device=AudioDevice.headset,
391-
pristine=options.pristine,
392-
build=options.build,
379+
for c in cores:
380+
build_configs.append(
381+
BuildConf(
382+
core=c,
383+
device=AudioDevice.headset,
384+
pristine=options.pristine,
385+
build=options.build,
386+
)
393387
)
394-
)
395388
if AudioDevice.gateway in devices:
396-
build_configs.append(
397-
BuildConf(
398-
core=cores,
399-
device=AudioDevice.gateway,
400-
pristine=options.pristine,
401-
build=options.build,
402-
)
403-
)
389+
for c in cores:
390+
build_configs.append(
391+
BuildConf(
392+
core=c,
393+
device=AudioDevice.gateway,
394+
pristine=options.pristine,
395+
build=options.build,
396+
)
397+
)
404398

405399
for build_cfg in build_configs:
406400
__build_module(build_cfg, options)
@@ -412,6 +406,7 @@ def __main():
412406
for dev in device_list:
413407
if dev.snr_connected:
414408
__populate_hex_paths(dev, options)
409+
415410
program_threads_run(device_list, sequential=options.sequential_prog)
416411

417412
# Program step finished

applications/nrf5340_audio/tools/buildprog/nrf5340_audio_dk_devices.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class SelectFlags(str, Enum):
2424
class Core(str, Enum):
2525
"""SoC core"""
2626
app = "app"
27-
net = "network"
27+
net = "net"
2828
both = "both"
2929

3030

applications/nrf5340_audio/tools/buildprog/program.py

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -41,31 +41,35 @@ def __populate_uicr(dev):
4141
def _program_cores(dev: DeviceConf) -> int:
4242
if dev.core_net_programmed == SelectFlags.TBD:
4343
if not path.isfile(dev.hex_path_net):
44-
print("NET core hex not found. Built as APP core image.")
45-
return 1
46-
47-
print(f"Programming net core on: {dev}")
48-
cmd = (f"nrfjprog --program {dev.hex_path_net} -f NRF53 -q "
49-
f"--snr {dev.nrf5340_audio_dk_snr} --sectorerase --coprocessor CP_NETWORK")
50-
ret_val = system(cmd)
51-
if ret_val != 0:
52-
if not dev.recover_on_fail:
53-
dev.core_net_programmed = SelectFlags.FAIL
54-
return ret_val
44+
print(f"NET core hex not found. Built only for APP core. {dev.hex_path_net}")
5545
else:
56-
dev.core_net_programmed = SelectFlags.DONE
46+
print(f"Programming net core on: {dev}")
47+
cmd = (f"nrfjprog --program {dev.hex_path_net} -f NRF53 -q "
48+
f"--snr {dev.nrf5340_audio_dk_snr} --sectorerase --coprocessor CP_NETWORK")
49+
ret_val = system(cmd)
50+
if ret_val != 0:
51+
if not dev.recover_on_fail:
52+
dev.core_net_programmed = SelectFlags.FAIL
53+
return ret_val
54+
else:
55+
dev.core_net_programmed = SelectFlags.DONE
5756

5857
if dev.core_app_programmed == SelectFlags.TBD:
59-
print(f"Programming app core on: {dev}")
60-
cmd = (f"nrfjprog --program {dev.hex_path_app} -f NRF53 -q "
61-
f"--snr {dev.nrf5340_audio_dk_snr} --chiperase --coprocessor CP_APPLICATION")
62-
ret_val = system(cmd)
63-
if ret_val != 0:
64-
if not dev.recover_on_fail:
65-
dev.core_app_programmed = SelectFlags.FAIL
66-
return ret_val
58+
if not path.isfile(dev.hex_path_app):
59+
print(f"APP core hex not found. Built only for NET core. {dev.hex_path_app}")
60+
return 1
6761
else:
68-
dev.core_app_programmed = SelectFlags.DONE
62+
print(f"Programming app core on: {dev}")
63+
cmd = (f"nrfjprog --program {dev.hex_path_app} -f NRF53 -q "
64+
f"--snr {dev.nrf5340_audio_dk_snr} --chiperase --coprocessor CP_APPLICATION")
65+
ret_val = system(cmd)
66+
if ret_val != 0:
67+
if not dev.recover_on_fail:
68+
dev.core_app_programmed = SelectFlags.FAIL
69+
return ret_val
70+
else:
71+
dev.core_app_programmed = SelectFlags.DONE
72+
6973
# Populate UICR data matching the JSON file
7074
if not __populate_uicr(dev):
7175
dev.core_app_programmed = SelectFlags.FAIL

doc/nrf/releases_and_maturity/releases/release-notes-changelog.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,11 @@ Matter Bridge
285285
nRF5340 Audio
286286
-------------
287287

288-
|no_changes_yet_note|
288+
* Updated:
289+
290+
* The documentation for :ref:`nrf53_audio_app_building` with cross-links and additional information.
291+
* The :file:`buildprog.py` is an app-specific script for building and programming multiple kits and cores with various audio application configurations. The script will be deprecated in a future release. The audio applications will gradually shift only to using standard tools for building and programming development kits.
292+
* The :ref:`nrf53_audio_app` :ref:`nrf53_audio_app_building_script` now builds into a directory for each transport, device type, core, and version combination.
289293

290294
nRF Desktop
291295
-----------

0 commit comments

Comments
 (0)