Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions ncs/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -51,7 +51,8 @@ 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 "
f"image {image_name}: {binary} and {existing_binary}"
)

data[image_name] = {
Expand All @@ -63,6 +64,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

Expand Down Expand Up @@ -186,6 +189,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)

Expand All @@ -199,7 +203,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."
)
Expand Down Expand Up @@ -266,7 +270,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:
Expand Down
2 changes: 1 addition & 1 deletion suit_generator/cmd_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ def as_intelhex(self, storage_domain: ManifestDomain = None):
raise GeneratorError(
f"Unable to fit envelope with role {role} inside the envelope slot (max: {max_size} bytes)"
)
envelope_bytes = self._envelopes[role].ljust(max_size, b"\xFF")
envelope_bytes = self._envelopes[role].ljust(max_size, b"\xff")
envelope_count += 1
else:
continue
Expand Down
4 changes: 2 additions & 2 deletions suit_generator/cmd_mpi.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,13 @@ def generate(
+ downgrade_prevention_enabled_bytes
+ independent_updates_bytes
+ signature_verification_bytes
+ b"\xFF" * 12 # Reserved for future use
+ b"\xff" * 12 # Reserved for future use
+ vid.bytes
+ cid.bytes
)

mpi_hex = IntelHex()
mpi_hex.frombytes(mpi.ljust(size, b"\xFF"), address)
mpi_hex.frombytes(mpi.ljust(size, b"\xff"), address)
mpi_hex.write_hex_file(output_file)

@staticmethod
Expand Down
6 changes: 3 additions & 3 deletions tests/test_cmd_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@

MAX_CACHE_COUNT = 16

addresses = {0x00000000: b"\x00\x00\x00\x00", 0xDEADBEEF: b"\xEF\xBE\xAD\xDE", 0xFFFFFFFF: b"\xFF\xFF\xFF\xFF"}
sizes = {0x00000000: b"\x00\x00\x00\x00", 0x01020304: b"\x04\x03\x02\x01", 0xFFFFFFFF: b"\xFF\xFF\xFF\xFF"}
addresses = {0x00000000: b"\x00\x00\x00\x00", 0xDEADBEEF: b"\xef\xbe\xad\xde", 0xFFFFFFFF: b"\xff\xff\xff\xff"}
sizes = {0x00000000: b"\x00\x00\x00\x00", 0x01020304: b"\x04\x03\x02\x01", 0xFFFFFFFF: b"\xff\xff\xff\xff"}

signed_envelope_without_class_id_input = (
b"\xd8k\xa4\x02X'\x81X$\x82/X 7d\x90\xc1\xa5\x84\xc1\xed\xeeO\x0f\xd6\xad\xc5t\xb0\x1dr\xb5r"
Expand Down Expand Up @@ -346,7 +346,7 @@ def test_update_candidate_info_verify_class_id_offset():
@pytest.mark.parametrize("address", addresses)
@pytest.mark.parametrize("size", sizes)
def test_update_candidate_info_for_update(address, size, nb_of_caches):
magic_bytes = b"\xAA\x55\xAA\x55"
magic_bytes = b"\xaa\x55\xaa\x55"
nregions_bytes = b"\x01\x00\x00\x00"
address_bytes = addresses[address]
size_bytes = sizes[size]
Expand Down
2 changes: 1 addition & 1 deletion tests/test_ncs_sign_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def test_ncs_cose(setup_and_teardown):
def test_ncs_auth_block(setup_and_teardown):
"""Test if is possible to create authentication block using ncs sign_script.py."""
signer = suit_signer_factory()
auth_block = signer.create_authentication_block({}, {}, b"\xDE\xAD\xBE\xEF")
auth_block = signer.create_authentication_block({}, {}, b"\xde\xad\xbe\xef")
assert isinstance(auth_block, cbor2.CBORTag)


Expand Down