Skip to content

Commit

Permalink
Applications: nrf5340_audio: Removed bt_ll_acs_nrf53 from buildprog
Browse files Browse the repository at this point in the history
Only the Nordic Softdevice is officially supported.
OCT-2907

Signed-off-by: Kristoffer Rist Skøien <[email protected]>
  • Loading branch information
koffes committed Apr 4, 2024
1 parent 01c5bdf commit 38b1ae1
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 118 deletions.
99 changes: 8 additions & 91 deletions applications/nrf5340_audio/tools/buildprog/buildprog.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
AudioDevice,
SelectFlags,
Core,
Controller,
)
from program import program_threads_run
from pathlib import Path
Expand Down Expand Up @@ -86,7 +85,7 @@ def __print_dev_conf(device_list):
print(table)


def __build_cmd_get(core: Core, device: AudioDevice, build: BuildType, pristine, controller: Controller, child_image, options):
def __build_cmd_get(core: Core, device: AudioDevice, build: BuildType, pristine, child_image, options):
if core == Core.app:
build_cmd = f"west build {TARGET_CORE_APP_FOLDER} -b {TARGET_BOARD_NRF5340_AUDIO_DK_APP_NAME}"
if device == AudioDevice.headset:
Expand All @@ -107,25 +106,12 @@ def __build_cmd_get(core: Core, device: AudioDevice, build: BuildType, pristine,
else:
raise Exception("Invalid build type!")

if options.mcuboot == 'internal':
device_flag += " -DCONFIG_AUDIO_DFU=1"
elif options.mcuboot == 'external':
device_flag += " -DCONFIG_AUDIO_DFU=2"
if options.min_b0n:
device_flag += " -DCONFIG_B0N_MINIMAL=y"

if options.controller == Controller.acs_nrf53:
device_flag += " -DCONFIG_BT_LL_ACS_NRF53=y"
if not child_image:
device_flag += " -DCONFIG_NCS_INCLUDE_RPMSG_CHILD_IMAGE=n"

if options.controller == Controller.sdc:
if not child_image:
device_flag += " -DCONFIG_NCS_INCLUDE_RPMSG_CHILD_IMAGE=n"

if options.nrf21540:
device_flag += " -DSHIELD=nrf21540ek_fwd"
if options.controller == Controller.sdc:
device_flag += " -Dhci_ipc_SHIELD=nrf21540ek"
device_flag += " -Dhci_ipc_SHIELD=nrf21540ek"

if options.custom_bt_name is not None and options.user_bt_name:
raise Exception(
Expand Down Expand Up @@ -168,7 +154,6 @@ def __build_module(build_config, options):
build_config.device,
build_config.build,
build_config.pristine,
build_config.controller,
build_config.child_image,
options,
)
Expand Down Expand Up @@ -207,38 +192,11 @@ def __populate_hex_paths(dev, options, child_image):
"""Poplulate hex paths where relevant"""

_, temp_dest_folder, _, _ = __build_cmd_get(
Core.app, dev.nrf5340_audio_dk_dev, options.build, options.pristine, options.controller, child_image, options
Core.app, dev.nrf5340_audio_dk_dev, options.build, options.pristine, child_image, options
)

dest_folder = temp_dest_folder

if options.controller == Controller.sdc:
dev.hex_path_app = dest_folder / "zephyr/zephyr.hex"
dev.hex_path_net = dest_folder / "hci_ipc/zephyr/zephyr.hex"
return

if dev.core_app_programmed == SelectFlags.TBD:
if options.mcuboot != '':
dev.hex_path_app = dest_folder / "zephyr/merged.hex"
else:
dev.hex_path_app = dest_folder / "zephyr/zephyr.hex"

if dev.core_net_programmed == SelectFlags.TBD:
hex_files_found = 0
for hex_path in glob.glob(str(NRF_FOLDER) + "/lib/bin/bt_ll_acs_nrf53/bin/" + "ble5-ctr-rpmsg_" + "[0-9]" + "*" + ".hex"):
dev.hex_path_net = hex_path
hex_files_found += 1

if options.mcuboot != '':
dev.hex_path_net = dest_folder / "zephyr/net_core_app_signed.hex"
else:
dest_folder = NRF_FOLDER / "lib/bin/bt_ll_acs_nrf53/bin"

if hex_files_found != 1:
raise Exception(
f"Found zero or multiple NET hex files in folder: {dest_folder}")
else:
print(f"Using NET hex: {dev.hex_path_net} for {dev}")
dev.hex_path_app = temp_dest_folder / "zephyr/zephyr.hex"
dev.hex_path_net = temp_dest_folder / "hci_ipc/zephyr/zephyr.hex"


def __finish(device_list):
Expand Down Expand Up @@ -322,34 +280,6 @@ def __main():
default=False,
help="Recover device if programming fails",
)
parser.add_argument(
# Deprecated argument
"--ctlr",
type=str,
choices=[i.value for i in Controller],
dest="controller",
default=Controller.sdc.value,
help=Controller.acs_nrf53.value + \
" is deprecated. Use the SoftDevice Controller instead (enabled by default).",
)
# DFU relative option
parser.add_argument(
"-M",
"--min_b0n",
dest="min_b0n",
action='store_true',
default=False,
help="net core bootloader use minimal size build. Only for controller: " +
Controller.acs_nrf53,
)
parser.add_argument(
"-m",
"--mcuboot",
required=("-M" in sys.argv or "--min_b0n" in sys.argv),
choices=["external", "internal"],
default='',
help="MCUBOOT with external, internal flash. Only for controller: " + Controller.acs_nrf53,
)
parser.add_argument(
"--nrf21540",
action="store_true",
Expand All @@ -376,14 +306,6 @@ def __main():

options = parser.parse_args(args=sys.argv[1:])

if options.controller == Controller.acs_nrf53:
print(Fore.YELLOW +
"Deprecated app - controller combination" + Style.RESET_ALL)
if options.controller == Controller.sdc:
if options.mcuboot != '' or options.min_b0n:
raise Exception("DFU arguments only accepted when using controller: " +
Controller.acs_nrf53 + ". Please use standard tools.")

# Post processing for Enums
if options.core is None:
cores = []
Expand Down Expand Up @@ -424,7 +346,6 @@ def __main():
cores=cores,
devices=devices,
_only_reboot=options.only_reboot,
controller=options.controller,
)
for dev in dev_arr
]
Expand All @@ -435,8 +356,7 @@ def __main():
# Reboot step start

if options.only_reboot == SelectFlags.TBD:
program_threads_run(device_list, options.mcuboot,
sequential=options.sequential_prog)
program_threads_run(device_list, sequential=options.sequential_prog)
__finish(device_list)

# Reboot step finished
Expand All @@ -457,7 +377,6 @@ def __main():
device=AudioDevice.headset,
pristine=options.pristine,
build=options.build,
controller=options.controller,
child_image=child_image,
)
)
Expand All @@ -468,7 +387,6 @@ def __main():
device=AudioDevice.gateway,
pristine=options.pristine,
build=options.build,
controller=options.controller,
child_image=child_image,
)
)
Expand All @@ -486,8 +404,7 @@ def __main():
for dev in device_list:
if dev.snr_connected:
__populate_hex_paths(dev, options, child_image)
program_threads_run(device_list, options.mcuboot,
sequential=options.sequential_prog)
program_threads_run(device_list, sequential=options.sequential_prog)

# Program step finished

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,6 @@ class Channel(Enum):
NA = auto()


class Controller(str, Enum):
acs_nrf53 = "ACS_nRF53"
sdc = "SDC"


@dataclass
class DeviceConf:
"""This config is populated according to connected SEGGER serial numbers
Expand All @@ -66,7 +61,6 @@ class DeviceConf:
cores: InitVar[List[Core]]
devices: InitVar[List[AudioDevice]]
_only_reboot: InitVar[SelectFlags]
controller: InitVar[List[Controller]]
# Post init variables
only_reboot: SelectFlags = field(init=False, default=SelectFlags.NOT)
hex_path_app: Path = field(init=False, default=None)
Expand All @@ -77,11 +71,10 @@ class DeviceConf:
init=False, default=SelectFlags.NOT)

def __post_init__(
self, cores: List[Core], devices: List[AudioDevice], _only_reboot: SelectFlags, controller: Controller,
self, cores: List[Core], devices: List[AudioDevice], _only_reboot: SelectFlags,
):
device_selected = self.nrf5340_audio_dk_dev in devices
self.only_reboot = _only_reboot if device_selected else SelectFlags.NOT
self.controller = controller
if self.only_reboot == SelectFlags.TBD:
return

Expand All @@ -105,5 +98,4 @@ class BuildConf:
device: AudioDevice
build: BuildType
pristine: bool
controller: Controller
child_image: bool
28 changes: 10 additions & 18 deletions applications/nrf5340_audio/tools/buildprog/program.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from threading import Thread
from os import system, path
from typing import List
from nrf5340_audio_dk_devices import DeviceConf, SelectFlags, AudioDevice, Controller
from nrf5340_audio_dk_devices import DeviceConf, SelectFlags, AudioDevice

MEM_ADDR_UICR_SNR = 0x00FF80F0
MEM_ADDR_UICR_CH = 0x00FF80F4
Expand All @@ -36,14 +36,10 @@ def __populate_UICR(dev):
return True


def _program_cores(dev: DeviceConf, mcuboot_type) -> int:
def _program_cores(dev: DeviceConf) -> int:
if dev.core_net_programmed == SelectFlags.TBD:
if not path.isfile(dev.hex_path_net):
if dev.controller == Controller.sdc:
print(
"Controller: SDC. NET core hex not found. Built as APP core child image.")
if dev.controller == Controller.acs_nrf53:
print("Controller: acs_nrf53. NET core hex not found.")
print("NET core hex not found. Built as APP core child image.")
return 1

print(f"Programming net core on: {dev}")
Expand Down Expand Up @@ -72,12 +68,8 @@ def _program_cores(dev: DeviceConf, mcuboot_type) -> int:
return 1

if dev.core_net_programmed != SelectFlags.NOT or dev.core_app_programmed != SelectFlags.NOT:
if mcuboot_type == 'external':
print(f"Hard resetting {dev}")
cmd = f"nrfjprog -p --snr {dev.nrf5340_audio_dk_snr}"
else:
print(f"Resetting {dev}")
cmd = f"nrfjprog -r --snr {dev.nrf5340_audio_dk_snr}"
print(f"Resetting {dev}")
cmd = f"nrfjprog -r --snr {dev.nrf5340_audio_dk_snr}"
ret_val = system(cmd)
if ret_val != 0:
return ret_val
Expand All @@ -99,21 +91,21 @@ def _recover(dev: DeviceConf):
dev.core_app_programmed = SelectFlags.FAIL


def __program_thread(dev: DeviceConf, mcuboot_type):
def __program_thread(dev: DeviceConf):
if dev.only_reboot == SelectFlags.TBD:
print(f"Resetting {dev}")
cmd = f"nrfjprog -r --snr {dev.nrf5340_audio_dk_snr}"
ret_val = system(cmd)
dev.only_reboot = SelectFlags.FAIL if ret_val else SelectFlags.DONE
return

return_code = _program_cores(dev, mcuboot_type)
return_code = _program_cores(dev)
if return_code != 0 and dev.recover_on_fail:
_recover(dev)
_program_cores(dev, mcuboot_type)
_program_cores(dev)


def program_threads_run(devices_list: List[DeviceConf], mcuboot_type, sequential: bool = False):
def program_threads_run(devices_list: List[DeviceConf], sequential: bool = False):
"""Program devices in parallel"""
threads = []
# First program net cores if applicable
Expand All @@ -123,7 +115,7 @@ def program_threads_run(devices_list: List[DeviceConf], mcuboot_type, sequential
dev.core_app_programmed = SelectFlags.NOT
dev.core_net_programmed = SelectFlags.NOT
continue
thread = Thread(target=__program_thread, args=(dev, mcuboot_type))
thread = Thread(target=__program_thread, args=(dev,))
threads.append(thread)
thread.start()
if sequential:
Expand Down

0 comments on commit 38b1ae1

Please sign in to comment.