Skip to content

Commit

Permalink
cmd_image: Remove legacy commands
Browse files Browse the repository at this point in the history
Remove legacy commands from the SUIT generator commands.

Ref: NCSDK-NONE

Signed-off-by: Tomasz Chyrowicz <[email protected]>
  • Loading branch information
tomchy committed May 15, 2024
1 parent 18967ff commit 9a44b9c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 112 deletions.
125 changes: 14 additions & 111 deletions suit_generator/cmd_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,25 +51,11 @@ def add_arguments(parser):
f"Default: 0x{ImageCreator.default_update_candidate_info_address:08X}",
)
cmd_image_boot.add_argument(
"--envelope-address",
"--storage-address",
required=False,
type=lambda x: int(x, 0),
default=ImageCreator.default_envelope_address,
help=f"Address of installed envelope in SUIT storage. Default: 0x{ImageCreator.default_envelope_address:08X}",
)
cmd_image_boot.add_argument(
"--envelope-slot-size",
required=False,
type=lambda x: int(x, 0),
default=ImageCreator.default_envelope_slot_size,
help=f"Envelope slot size in SUIT storage. Default: 0x{ImageCreator.default_envelope_slot_size:08X}",
)
cmd_image_boot.add_argument(
"--envelope-slot-count",
required=False,
type=lambda x: int(x, 0),
default=ImageCreator.default_envelope_slot_count,
help=f"Max number of envelope slots in SUIT storage. Default: {ImageCreator.default_envelope_slot_count}",
default=ImageCreator.default_storage_address,
help=f"Address of SUIT storage. Default: 0x{ImageCreator.default_storage_address:08X}",
)
cmd_image_boot.add_argument(
"--dfu-max-caches",
Expand Down Expand Up @@ -137,51 +123,14 @@ class ManifestDomain(Enum):


class EnvelopeStorage:
"""Class generating SUIT storage binary in legacy format."""
"""Base class for generating SUIT storage binary."""

ENVELOPE_SLOT_VERSION = 1
ENVELOPE_SLOT_VERSION_KEY = 0
ENVELOPE_SLOT_CLASS_ID_OFFSET_KEY = 1
ENVELOPE_SLOT_ENVELOPE_BSTR_KEY = 2

_LAYOUT = [
{
"role": ManifestRole.APP_ROOT,
"offset": 2048 * 0,
"size": 2048,
"domain": ManifestDomain.APPLICATION,
},
{
"role": ManifestRole.APP_LOCAL_1,
"offset": 2048 * 1,
"size": 2048,
"domain": ManifestDomain.APPLICATION,
},
{
"role": ManifestRole.RAD_LOCAL_1,
"offset": 2048 * 2,
"size": 2048,
"domain": ManifestDomain.RADIO,
},
{
"role": ManifestRole.SEC_TOP,
"offset": 2048 * 3,
"size": 2048,
"domain": ManifestDomain.SECURE,
},
{
"role": ManifestRole.SEC_SDFW,
"offset": 2048 * 4,
"size": 2048,
"domain": ManifestDomain.SECURE,
},
{
"role": ManifestRole.SEC_SYSCTRL,
"offset": 2048 * 5,
"size": 2048,
"domain": ManifestDomain.SECURE,
},
]
_LAYOUT = []

# Default manifest role assignments
_CLASS_ROLE_ASSIGNMENTS = [
Expand Down Expand Up @@ -414,10 +363,8 @@ class EnvelopeStorageNrf54h20(EnvelopeStorage):
class ImageCreator:
"""Helper class for extracting data from SUIT envelope and creating hex files."""

default_update_candidate_info_address = 0x0E1E9340
default_envelope_address = 0x0E1E7000
default_envelope_slot_size = 2048
default_envelope_slot_count = 8
default_update_candidate_info_address = 0x0E1ED340
default_storage_address = 0x0E1EB000
default_dfu_partition_address = 0x0E155000
default_dfu_max_caches = 6

Expand Down Expand Up @@ -484,38 +431,11 @@ def _create_single_domain_storage_file_for_boot(
combined_hex.merge(envelopes_hex)
combined_hex.write_hex_file(dir_name + "/storage_" + domain.name.lower() + ".hex")

def _create_suit_storage_file_for_boot_legacy(
envelopes: list[SuitEnvelope],
update_candidate_info_address: int,
installed_envelope_address: int,
envelope_slot_size: int,
envelope_slot_count: int,
dir_name: str,
dfu_max_caches: int,
) -> None:
# Update candidate info
# In the boot path it is used to inform no update candidate is pending.
uci_hex = IntelHex()
uci_hex.frombytes(
ImageCreator._prepare_update_candidate_info_for_boot(dfu_max_caches), update_candidate_info_address
)

combined_hex = IntelHex(uci_hex)

storage = EnvelopeStorageNrf54h20(installed_envelope_address)
for envelope in envelopes:
storage.add_envelope(envelope)
combined_hex.merge(storage.as_intelhex())

combined_hex.write_hex_file(dir_name + "/storage.hex")

@staticmethod
def _create_suit_storage_files_for_boot(
envelopes: list[SuitEnvelope],
update_candidate_info_address: int,
installed_envelope_address: int,
envelope_slot_size: int,
envelope_slot_count: int,
storage_address: int,
dir_name: str,
dfu_max_caches: int,
) -> None:
Expand All @@ -526,7 +446,7 @@ def _create_suit_storage_files_for_boot(
ImageCreator._prepare_update_candidate_info_for_boot(dfu_max_caches), update_candidate_info_address
)

storage = EnvelopeStorageNrf54h20(installed_envelope_address)
storage = EnvelopeStorageNrf54h20(storage_address)
for envelope in envelopes:
storage.add_envelope(envelope)

Expand Down Expand Up @@ -564,19 +484,15 @@ def create_files_for_boot(
input_files: list[str],
storage_output_directory: str,
update_candidate_info_address: int,
envelope_address: int,
envelope_slot_size: int,
envelope_slot_count: int,
storage_address: int,
dfu_max_caches: int,
) -> None:
"""Create storage and payload hex files allowing boot execution path.
:param input_file: file path to SUIT envelope
:param storage_output_directory: directory path to store hex files with SUIT storage contents
:param update_candidate_info_address: address of SUIT storage update candidate info
:param envelope_address: address of installed envelope in SUIT storage
:param envelope_slot_size: number of bytes, reserved to store a single envelope,
:param envelope_slot_count: number of envelope slots in SUIT storage,
:param storage_address: address of SUIT storage
:param dfu_max_caches: maximum number of caches, allowed to be passed inside update candidate info,
"""
try:
Expand All @@ -588,21 +504,10 @@ def create_files_for_boot(
envelope.sever()
envelopes.append(envelope)

ImageCreator._create_suit_storage_file_for_boot_legacy(
envelopes,
update_candidate_info_address,
envelope_address,
envelope_slot_size,
envelope_slot_count,
storage_output_directory,
dfu_max_caches,
)
ImageCreator._create_suit_storage_files_for_boot(
envelopes,
update_candidate_info_address,
envelope_address,
envelope_slot_size,
envelope_slot_count,
storage_address,
storage_output_directory,
dfu_max_caches,
)
Expand Down Expand Up @@ -650,7 +555,7 @@ def main(**kwargs) -> None:
* **storage_output_file** - file path to hex file with SUIT storage contents - for "update" command
* **storage_output_directory** - directory path to store hex files with storage contents - for "boot" command
* **update_candidate_info_address** - address of SUIT storage update candidate info
* **envelope_address** - address of installed envelope in SUIT storage
* **storage_address** - address of SUIT storage
* **dfu_partition_output_file** - file path to hex file with DFU partition contents (the SUIT envelope)
* **dfu_partition_address** - address of partition where DFU update candidate is stored
"""
Expand All @@ -659,9 +564,7 @@ def main(**kwargs) -> None:
kwargs["input_file"],
kwargs["storage_output_directory"],
kwargs["update_candidate_info_address"],
kwargs["envelope_address"],
kwargs["envelope_slot_size"],
kwargs["envelope_slot_count"],
kwargs["storage_address"],
kwargs["dfu_max_caches"],
)
elif kwargs["image"] == ImageCreator.IMAGE_CMD_UPDATE:
Expand Down
2 changes: 1 addition & 1 deletion suit_generator/cmd_mpi.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def add_arguments(parser):


class MpiGenerator:
"""Class geenrating SUIT Manifest Provisioning Information."""
"""Class generating SUIT Manifest Provisioning Information."""

BYTE_ORDER = "little"

Expand Down

0 comments on commit 9a44b9c

Please sign in to comment.