Skip to content

Commit

Permalink
ncs: Add command and Kconfigs for SDFW update (#69)
Browse files Browse the repository at this point in the history
Ref: NCSDK-24780

Signed-off-by: Adam Szczygieł <[email protected]>
  • Loading branch information
adsz-nordic authored Dec 8, 2023
1 parent 98d5782 commit 425d339
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 15 deletions.
18 changes: 3 additions & 15 deletions ncs/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -118,23 +118,11 @@ config SUIT_ENVELOPE_SIGN_SCRIPT
config SUIT_PREPARE_SECDOM_UPDATE
bool "Create SUIT envelope for SDFW update"
depends on IS_SECURE_DOMAIN_FW
default n
default y if !HW_REVISION_SOC1

config SUIT_ENVELOPE_CREATE_SECDOM_UPDATE_YAML_SCRIPT
string "Location of script for preparing secdom yaml envelope"
depends on SUIT_PREPARE_SECDOM_UPDATE
help
Python script called to generate yaml file for secure domain update.
Script requires parameters:
- --secdom-update-payload-uri - URI to be used in the yaml
- --secdom-update-payload-file - path to secure domain update payload
- --template-file - jinja2 template file for creating the yaml file
- --envelope-yaml-file - the yaml file to be generated
default "${ZEPHYR_SUIT_GENERATOR_MODULE_DIR}/ncs/create_secdom_update_envelope_yaml.py"

config SUIT_ENVELOPE_SECDOM_YAML_TEMPLATE_FILE
config SUIT_ENVELOPE_SECDOM_TEMPLATE
string "Location of template file for preparing secdom yaml envelope"
depends on SUIT_PREPARE_SECDOM_UPDATE
depends on !HW_REVISION_SOC1
help
Jinja2 template file used to generate yaml file for secure domain update.
default "${ZEPHYR_SUIT_GENERATOR_MODULE_DIR}/ncs/secdom_update_envelope.yaml.jinja2"
Expand Down
25 changes: 25 additions & 0 deletions ncs/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

TEMPLATE_CMD = "template"
STORAGE_CMD = "storage"
UPDATE_CMD = "update"


def convert(edt_object):
Expand Down Expand Up @@ -88,6 +89,21 @@ def get_absolute_address(node):
)
cmd_storage_arg_parser.add_argument("--storage-output-file", required=True, help="Input binary SUIT envelope.")

cmd_update_arg_parser = subparsers.add_parser(
UPDATE_CMD, help="Generate files needed for Secure Domain update", parents=[parent_parser]
)

cmd_update_arg_parser.add_argument("--input-file", required=True, help="SUIT envelope in binary format")
cmd_update_arg_parser.add_argument(
"--storage-output-file", required=True, help="SUIT storage output file in HEX format"
)
cmd_update_arg_parser.add_argument(
"--dfu-partition-output-file", required=True, help="DFU partition output file in HEX format"
)
cmd_update_arg_parser.add_argument(
"--dfu-partition-address", required=True, type=lambda x: int(x, 0), help="Start address of DFU partition"
)

arguments = parser.parse_args()

sys.path.insert(0, os.path.join(arguments.zephyr_base, "scripts", "dts", "python-devicetree", "src"))
Expand All @@ -112,3 +128,12 @@ def get_absolute_address(node):
update_candidate_info_address=ImageCreator.default_update_candidate_info_address,
dfu_max_caches=ImageCreator.default_dfu_max_caches,
)
elif arguments.command == UPDATE_CMD:
ImageCreator.create_files_for_update(
input_file=arguments.input_file,
storage_output_file=arguments.storage_output_file,
dfu_partition_output_file=arguments.dfu_partition_output_file,
update_candidate_info_address=ImageCreator.default_update_candidate_info_address,
dfu_partition_address=arguments.dfu_partition_address,
dfu_max_caches=ImageCreator.default_dfu_max_caches,
)

0 comments on commit 425d339

Please sign in to comment.