Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 81c6c1b

Browse files
committedMar 25, 2025·
applications: nrf5340_audio: Buildprog, pristine and flashing issue
Buildprog issues with building and programming single cores. Signed-off-by: Graham Wacey <graham.wacey@nordicsemi.no>
1 parent 8798f86 commit 81c6c1b

File tree

2 files changed

+61
-63
lines changed

2 files changed

+61
-63
lines changed
 

‎applications/nrf5340_audio/tools/buildprog/buildprog.py

+36-42
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,7 @@
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
4846

4947
UNICAST_SERVER_OVERLAY = NRF5340_AUDIO_FOLDER / "unicast_server/overlay-unicast_server.conf"
5048
UNICAST_CLIENT_OVERLAY = NRF5340_AUDIO_FOLDER / "unicast_client/overlay-unicast_client.conf"
@@ -90,35 +88,24 @@ def __print_dev_conf(device_list):
9088
print(table)
9189

9290

93-
def __build_cmd_get(cores: Core, device: AudioDevice, build: BuildType,
91+
def __build_cmd_get(core: Core, device: AudioDevice, build: BuildType,
9492
pristine, options):
9593

96-
build_cmd = (f"west build {TARGET_CORE_APP_FOLDER} "
94+
build_cmd = (f"west build {TARGET_AUDIO_FOLDER} "
9795
f"-b {TARGET_BOARD_NRF5340_AUDIO_DK_APP_NAME} "
9896
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:
97+
98+
if core == Core.app:
10399
build_cmd += " --domain nrf5340_audio"
104-
elif Core.net in cores:
100+
elif core == Core.net:
105101
build_cmd += " --domain ipc_radio"
106102
else:
107103
raise Exception("Invalid core!")
108104

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-
116105
if build == BuildType.debug:
117106
release_flag = ""
118-
dest_folder /= TARGET_DEBUG_FOLDER
119107
elif build == BuildType.release:
120108
release_flag = " -DFILE_SUFFIX=release"
121-
dest_folder /= TARGET_RELEASE_FOLDER
122109
else:
123110
raise Exception("Invalid build type!")
124111

@@ -152,7 +139,9 @@ def __build_cmd_get(cores: Core, device: AudioDevice, build: BuildType,
152139
if os.name == 'nt':
153140
release_flag = release_flag.replace('\\', '/')
154141
if pristine:
155-
build_cmd += " -p"
142+
build_cmd += " --pristine=auto"
143+
144+
dest_folder = TARGET_AUDIO_FOLDER / "build" / options.transport / device / core / build
156145

157146
return build_cmd, dest_folder, device_flag, release_flag, overlay_flag
158147

@@ -199,12 +188,11 @@ def __find_snr():
199188
def __populate_hex_paths(dev, options):
200189
"""Poplulate hex paths where relevant"""
201190

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

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

209197

210198
def __finish(device_list):
@@ -248,7 +236,10 @@ def __main():
248236
help="Select which cores to include in build",
249237
)
250238
parser.add_argument(
251-
"--pristine", default=False, action="store_true", help="Will build cleanly"
239+
"--pristine",
240+
default=False,
241+
action="store_true",
242+
help="Will build cleanly"
252243
)
253244
parser.add_argument(
254245
"-b",
@@ -315,7 +306,7 @@ def __main():
315306
parser.add_argument(
316307
"-t",
317308
"--transport",
318-
required = True,
309+
required=True,
319310
choices=[i.name for i in Transport],
320311
default=Transport.unicast.name,
321312
help="Select the transport type",
@@ -384,23 +375,25 @@ def __main():
384375
build_configs = []
385376

386377
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,
378+
for c in cores:
379+
build_configs.append(
380+
BuildConf(
381+
core=c,
382+
device=AudioDevice.headset,
383+
pristine=options.pristine,
384+
build=options.build,
385+
)
393386
)
394-
)
395387
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-
)
388+
for c in cores:
389+
build_configs.append(
390+
BuildConf(
391+
core=c,
392+
device=AudioDevice.gateway,
393+
pristine=options.pristine,
394+
build=options.build,
395+
)
396+
)
404397

405398
for build_cfg in build_configs:
406399
__build_module(build_cfg, options)
@@ -412,6 +405,7 @@ def __main():
412405
for dev in device_list:
413406
if dev.snr_connected:
414407
__populate_hex_paths(dev, options)
408+
415409
program_threads_run(device_list, sequential=options.sequential_prog)
416410

417411
# Program step finished

‎applications/nrf5340_audio/tools/buildprog/program.py

+25-21
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 as APP core image. {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 as NET core image. {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

0 commit comments

Comments
 (0)
Please sign in to comment.