From d17bd71f476bbb3b5ed410eabffe300a828012c5 Mon Sep 17 00:00:00 2001 From: Robert Stypa Date: Tue, 4 Feb 2025 11:21:02 +0100 Subject: [PATCH] feat: Add target parameter to specify primary image Add --target parameter that allows specifying the primary image in SUIT configuration. Also improve error message for duplicate image names to be more descriptive. Signed-off-by: Robert Stypa --- ncs/build.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/ncs/build.py b/ncs/build.py index 329a7ce..a63888e 100755 --- a/ncs/build.py +++ b/ncs/build.py @@ -29,7 +29,7 @@ dir_path = pathlib.Path(__file__).parent.absolute() -def read_configurations(configurations): +def read_configurations(configurations, target): """Read configuration stored in the pickled devicetree.""" data = {} for config in configurations: @@ -51,7 +51,7 @@ def read_configurations(configurations): if image_name in data: existing_binary = data[image_name]["binary"] raise ValueError( - "Two images have the same CONFIG_SUIT_ENVELOPE_TARGET value: " f"{binary} and {existing_binary}" + f"Two images have the same CONFIG_SUIT_ENVELOPE_TARGET value for image {image_name}: {binary} and {existing_binary}" ) data[image_name] = { @@ -63,6 +63,8 @@ def read_configurations(configurations): if binary: data[image_name]["filename"] = pathlib.Path(binary).name data[image_name]["binary"] = binary + if target == image_name: + data["target"] = data[image_name] data["get_absolute_address"] = get_absolute_address return data @@ -186,6 +188,7 @@ def get_absolute_address(node, use_offset: bool = True): help="Configuration of sample name:location of binaries:location of edt", ) parent_parser.add_argument("--zephyr-base", required=True, help="Location of zephyr directory.") + parent_parser.add_argument("--target", required=False, default=None, help="Target name.") parser = ArgumentParser(add_help=False) @@ -199,7 +202,7 @@ def get_absolute_address(node, use_offset: bool = True): cmd_template_arg_parser.add_argument("--artifacts-folder", required=True, help="Output artifact folder.") cmd_template_arg_parser.add_argument("--template-suit", required=True, help="Input SUIT jinja2 template.") - cmd_template_arg_parser.add_argument("--output-suit", required=True, help="Output SUIT configuration.") + cmd_template_arg_parser.add_argument("--output-suit", required=True, help="Output SUIT file.") cmd_template_arg_parser.add_argument( "--version_file", required=False, default=None, help="Path to the VERSION file to use." ) @@ -266,7 +269,7 @@ def get_absolute_address(node, use_offset: bool = True): sys.path.insert(0, os.path.join(arguments.zephyr_base, "scripts", "dts", "python-devicetree", "src")) - configuration = read_configurations(arguments.core) + configuration = read_configurations(arguments.core, arguments.target) if arguments.command == TEMPLATE_CMD: if arguments.version_file is not None: