Skip to content

Commit

Permalink
ncs: Add SysCtrl envelope template
Browse files Browse the repository at this point in the history
Additionally change cpu_id from uint to int, to support -1 indicating
lack of boot capabilities.

Signed-off-by: Adam Szczygieł <[email protected]>
  • Loading branch information
adsz-nordic committed Feb 9, 2024
1 parent 9411a49 commit 3ca62a0
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 35 deletions.
15 changes: 15 additions & 0 deletions ncs/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -161,4 +161,19 @@ config SUIT_SECDOM_VERSION
Version of Secdom FW to be logged during its startup.
default "0.0.1"

config SUIT_ENVELOPE_SYSCTRL
bool "Create SUIT files required by sysctrl"
help
Create SUIT envelope for sysctrl in case it has been included in the build
default y if INCLUDE_SYSCTRL

config SUIT_ENVELOPE_SYSCTRL_TEMPLATE
string "Location of template file for preparing sysctrl yaml envelope"
help
Path to the sysctrl template, that is used if the application directory does not
contain an input sysctrl envelope template file.
You can use either absolute or relative path.
In case relative path is used, the build system uses PROJECT_BINARY_DIR directory.
default "${ZEPHYR_SUIT_GENERATOR_MODULE_DIR}/ncs/sysctrl_envelope.yaml.jinja2"

endif # SUIT_ENVELOPE
6 changes: 4 additions & 2 deletions ncs/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,13 @@ def render_template(template_location, data):
return template.render(data)


def get_absolute_address(node):
def get_absolute_address(node, use_offset: bool = True):
"""Get absolute address of passed node."""
# fixme: hardcoded value for parent node due to bug in DTS
# return node.parent.parent.regs[0].addr + node.regs[0].addr
return 0xE000000 + node.regs[0].addr
if use_offset:
return 0xE000000 + node.regs[0].addr
return node.regs[0].addr


parent_parser = ArgumentParser(add_help=False)
Expand Down
88 changes: 56 additions & 32 deletions ncs/sysctrl_envelope.yaml.jinja2
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{# example template - need to be update #}
{# example template - need to be updated #}
{%- if sysctrl is not defined %}
{# sysctrl domain build as main application #}
{%- set sysctrl = app %}
Expand All @@ -9,45 +9,69 @@ SUIT_Envelope_Tagged:
suit-digest-algorithm-id: cose-alg-sha-256
suit-manifest:
suit-manifest-version: 1
suit-manifest-sequence-number: 1
suit-manifest-sequence-number: {{ version }}
suit-common:
suit-components:
# fixme: template copied from secdom for testing purposes - update component using valid values for sysctrl when ready
- - SOC_SPEC
- 1
# [0], RAM
- - MEM
- {{ sysctrl['dt'].label2node['cpu'].unit_addr }}
- {{ get_absolute_address(sysctrl['dt'].chosen_nodes['zephyr,flash'], use_offset=False) }}
- {{ sysctrl['dt'].chosen_nodes['zephyr,flash'].regs[0].size }}
# [1], MRAM
- - MEM
- -1
- {{ get_absolute_address(sysctrl['dt'].label2node['sysctrl_mram0'], use_offset=False) }}
- {{ sysctrl['dt'].label2node['sysctrl_mram0'].regs[0].size }}
# [2], Pseudo-component, used to verify the integrity of te incoming image.
# It is used as a target component for all fetch operations that download firmware.
- - CAND_IMG
- 0
suit-shared-sequence:
- suit-directive-set-component-index: [0, 1, 2]
- suit-directive-override-parameters:
suit-parameter-image-digest:
suit-digest-algorithm-id: cose-alg-sha-256
suit-digest-bytes:
file: {{ sysctrl['binary'] }}
suit-validate:
- suit-directive-set-component-index: 1
- suit-directive-override-parameters:
suit-parameter-image-size:
file: {{ sysctrl['binary'] }}
- suit-condition-image-match: []
suit-load:
- suit-directive-set-component-index: 1
- suit-directive-override-parameters:
suit-parameter-image-size:
file: {{ sysctrl['binary'] }}
- suit-directive-set-component-index: 0
- suit-directive-override-parameters:
suit-parameter-source-component: 1
- suit-directive-copy: []
- suit-condition-image-match: []
suit-invoke:
- suit-directive-set-component-index: 0
- suit-directive-override-parameters:
suit-parameter-vendor-identifier:
RFC4122_UUID:
name: nordicsemi.com
suit-parameter-class-identifier:
RFC4122_UUID:
namespace: nordicsemi.com
name: nRF54H20_sys
- suit-condition-vendor-identifier:
- suit-send-record-success
- suit-send-record-failure
- suit-send-sysinfo-success
- suit-send-sysinfo-failure
- suit-condition-class-identifier:
- suit-send-record-success
- suit-send-record-failure
- suit-send-sysinfo-success
- suit-send-sysinfo-failure
suit-parameter-image-size:
file: {{ sysctrl['binary'] }}
- suit-condition-image-match: []
- suit-directive-invoke: []
suit-payload-fetch:
- suit-directive-set-component-index: 2
- suit-directive-override-parameters:
suit-parameter-uri: '#{{ sysctrl['name'] }}'
- suit-directive-fetch: []
- suit-condition-image-match: []
suit-install:
- suit-directive-set-component-index: 1
- suit-directive-override-parameters:
suit-parameter-uri: '#{{ sysctrl['name'] }}'
- suit-directive-fetch:
- suit-send-record-failure
- suit-directive-set-component-index: 0
- suit-directive-override-parameters:
suit-parameter-source-component: 1
- suit-directive-copy:
- suit-send-record-failure
- suit-directive-set-component-index: 2
- suit-directive-override-parameters:
suit-parameter-uri: '#{{ sysctrl['name'] }}'
- suit-directive-fetch: []
- suit-condition-image-match: []
- suit-directive-set-component-index: 1
- suit-directive-override-parameters:
suit-parameter-source-component: 2
- suit-directive-copy: []
suit-manifest-component-id:
- INSTLD_MFST
- RFC4122_UUID:
Expand Down
3 changes: 2 additions & 1 deletion suit_generator/suit/manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from os.path import getsize

from suit_generator.suit.types.common import (
SuitInt,
SuitUint,
SuitKeyValue,
SuitKeyValueUnnamed,
Expand Down Expand Up @@ -268,7 +269,7 @@ class SuitCommand(SuitUnion):
class SuitComponentIdentifierPart(SuitUnion):
"""Abstract element to define possible sub-elements."""

_metadata = Metadata(children=[SuitUUID, SuitBchar, cbstr(SuitTstr), cbstr(SuitUint), SuitBstr])
_metadata = Metadata(children=[SuitUUID, SuitBchar, cbstr(SuitTstr), cbstr(SuitInt), SuitBstr])


class SuitComponentIdentifier(SuitList):
Expand Down

0 comments on commit 3ca62a0

Please sign in to comment.