-
Notifications
You must be signed in to change notification settings - Fork 1.4k
NCSDK-30461: Move SUIT MPI to sysbuild #19016
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
rlubos
merged 4 commits into
nrfconnect:main
from
tomchy:feature/suit/NCSDK-30461_Move_mpi_to_sysbuild
Dec 12, 2024
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,238 @@ | ||
| # | ||
| # Copyright (c) 2024 Nordic Semiconductor ASA | ||
| # | ||
| # SPDX-License-Identifier: LicenseRef-Nordic-5-Clause | ||
| # | ||
|
|
||
| set(SUIT_GENERATOR_CLI_SCRIPT "${ZEPHYR_SUIT_GENERATOR_MODULE_DIR}/suit_generator/cli.py") | ||
| sysbuild_get(DEFAULT_BINARY_DIR IMAGE ${DEFAULT_IMAGE} VAR APPLICATION_BINARY_DIR CACHE) | ||
| set(MPI_BINARY_DIR ${DEFAULT_BINARY_DIR}/zephyr) | ||
|
|
||
| # Usage: | ||
| # configure_storage_address_cache() | ||
| # | ||
| # Store the absolute address of the SUIT storage inside CMake cache. | ||
| # | ||
| function(configure_storage_address_cache) | ||
| sysbuild_dt_nodelabel( | ||
| suit_storage_dev | ||
| IMAGE | ||
| ${DEFAULT_IMAGE} | ||
| NODELABEL | ||
| "suit_storage_partition" | ||
| ) | ||
|
|
||
| if(NOT DEFINED suit_storage_dev) | ||
| message(WARNING "Unable to read SUIT storage address from DTS - nodes undefined") | ||
| return() | ||
| endif() | ||
|
|
||
| # Calculate SUIT storage address, based on the DTS | ||
| sysbuild_dt_reg_addr( | ||
| suit_storage_address | ||
| IMAGE | ||
| ${DEFAULT_IMAGE} | ||
| PATH | ||
| "${suit_storage_dev}" | ||
| ) | ||
|
|
||
| set(SUIT_STORAGE_ADDRESS ${suit_storage_address} CACHE STRING "SUIT storage address") | ||
| endfunction() | ||
|
|
||
| # Usage: | ||
| # generate_mpi_hex(<manifest_role>) | ||
| # | ||
| # Will generate HEX file for a single manifest role, based on Kconfigs defined by the template. | ||
| # | ||
| # <manifest_role>: The role that was used to generate a set of Kconfigs, defined by the | ||
| # Kconfig.template.manifest_config. | ||
| # | ||
| # Required Kconfigs: | ||
| # - SUIT_MPI_<manifest_role>_VENDOR_NAME | ||
| # - SUIT_MPI_<manifest_role>_CLASS_NAME | ||
| # - SUIT_MPI_<manifest_role>_OFFSET | ||
| # - SUIT_MPI_<manifest_role>_PATH | ||
| # - SUIT_MPI_SLOT_SIZE | ||
| # | ||
| function(generate_mpi_hex manifest_role) | ||
| set(generate_args "") | ||
| set(descr_args "") | ||
|
|
||
| if(NOT DEFINED SB_CONFIG_SUIT_MPI_${manifest_role}) | ||
| return() | ||
| endif() | ||
|
|
||
| if((NOT DEFINED SB_CONFIG_SUIT_MPI_${manifest_role}_VENDOR_NAME) OR | ||
| (NOT DEFINED SB_CONFIG_SUIT_MPI_${manifest_role}_CLASS_NAME) OR | ||
| (NOT DEFINED SB_CONFIG_SUIT_MPI_${manifest_role}_OFFSET) OR | ||
| (NOT DEFINED SB_CONFIG_SUIT_MPI_${manifest_role}_PATH) OR | ||
| (NOT DEFINED SB_CONFIG_SUIT_MPI_SLOT_SIZE) | ||
| ) | ||
| message(FATAL_ERROR "Malformed configuration for: ${manifest_role}") | ||
| return() | ||
| endif() | ||
|
|
||
| if(SB_CONFIG_SUIT_MPI_${manifest_role}_VENDOR_NAME STREQUAL "nordicsemi.com") | ||
| message(WARNING " | ||
| ----------------------------------------------------------- | ||
| --- WARNING: Using default Vendor ID (nordicsemi.com). --- | ||
| --- It should not be used for production. --- | ||
| --- See SB_CONFIG_SUIT_MPI_${manifest_role}_VENDOR_NAME \t--- | ||
| --- and SB_CONFIG_SUIT_MPI_${manifest_role}_CLASS_NAME \t--- | ||
| ----------------------------------------------------------- | ||
| \n" | ||
| ) | ||
| endif() | ||
|
|
||
| MATH( | ||
| EXPR | ||
| SUIT_MPI_${manifest_role}_ADDRESS | ||
| "${SUIT_STORAGE_ADDRESS} | ||
| + ${SB_CONFIG_SUIT_MPI_${manifest_role}_OFFSET}" | ||
| OUTPUT_FORMAT HEXADECIMAL | ||
| ) | ||
|
|
||
| list(APPEND generate_args | ||
| --vendor-name ${SB_CONFIG_SUIT_MPI_${manifest_role}_VENDOR_NAME} | ||
| --class-name ${SB_CONFIG_SUIT_MPI_${manifest_role}_CLASS_NAME} | ||
| --address ${SUIT_MPI_${manifest_role}_ADDRESS} | ||
| --size ${SB_CONFIG_SUIT_MPI_SLOT_SIZE} | ||
| --output-file ${SB_CONFIG_SUIT_MPI_${manifest_role}_PATH} | ||
| ) | ||
|
|
||
| list(APPEND descr_args | ||
| ${SB_CONFIG_SUIT_MPI_${manifest_role}_PATH} | ||
| ${SB_CONFIG_SUIT_MPI_${manifest_role}_VENDOR_NAME} | ||
| ${SB_CONFIG_SUIT_MPI_${manifest_role}_CLASS_NAME} | ||
| "address=${SUIT_MPI_${manifest_role}_ADDRESS}" | ||
| ) | ||
|
|
||
| if(DEFINED SB_CONFIG_SUIT_MPI_${manifest_role}_DOWNGRADE_PREVENTION) | ||
| list(APPEND generate_args | ||
| --downgrade-prevention-enabled | ||
| ) | ||
| list(APPEND descr_args | ||
| downgrade-prevention-enabled | ||
| ) | ||
| endif() | ||
|
|
||
| if(DEFINED SB_CONFIG_SUIT_MPI_${manifest_role}_INDEPENDENT_UPDATE) | ||
| list(APPEND generate_args | ||
| --independent-updates | ||
| ) | ||
| list(APPEND descr_args | ||
| "independent updates" | ||
| ) | ||
| endif() | ||
|
|
||
| if(DEFINED SB_CONFIG_SUIT_MPI_${manifest_role}_SIGNATURE_CHECK_ENABLED_ON_UPDATE) | ||
| list(APPEND generate_args | ||
| --signature-verification update | ||
| ) | ||
| list(APPEND descr_args | ||
| "signed updates" | ||
| ) | ||
| elseif(DEFINED SB_CONFIG_SUIT_MPI_${manifest_role}_SIGNATURE_CHECK_ENABLED_ON_UPDATE_AND_BOOT) | ||
| list(APPEND generate_args | ||
| --signature-verification update-and-boot | ||
| ) | ||
| list(APPEND descr_args | ||
| "signed updates" | ||
| "signed boot" | ||
| ) | ||
| endif() | ||
|
|
||
| add_custom_target( | ||
| create_suit_mpi_${manifest_role} | ||
| COMMAND ${PYTHON_EXECUTABLE} ${SUIT_GENERATOR_CLI_SCRIPT} | ||
| mpi | ||
| generate | ||
| ${generate_args} | ||
| BYPRODUCTS ${SB_CONFIG_SUIT_MPI_${manifest_role}_PATH} | ||
| COMMENT "Create SUIT artifacts" | ||
| ) | ||
| message(INFO " Generate MPI for ${manifest_role} manifest (${descr_args})") | ||
| endfunction() | ||
|
|
||
| # Usage: | ||
| # generate_mpi_area(<area_name> [<manifest_role>...]) | ||
| # | ||
| # Will generate HEX file for an MPI area attached to a single domain. | ||
| # At the end of the merging process, a digest of the resulting binary will be | ||
| # calculated and appended at the end of it. | ||
| # | ||
| # <area_name>: Name of the area. A valid area must define output file path, address and size. | ||
| # <manifest_role>: The role that was used to generate a set of Kconfigs, defined by the | ||
| # Kconfig.template.manifest_config. | ||
| # Used to extract the HEX file path containing the MPI configuration. | ||
| # | ||
| # Required Kconfigs: | ||
| # - SUIT_MPI_<area_name>_PATH | ||
| # - SUIT_MPI_<area_name>_OFFSET | ||
| # - SUIT_MPI_<area_name>_SIZE | ||
| # - SUIT_MPI_<manifest_role>_PATH | ||
| # | ||
| function (generate_mpi_area area) | ||
| set(merge_args "") | ||
| set(dependencies "") | ||
|
|
||
| if((NOT DEFINED SB_CONFIG_SUIT_MPI_${area}_PATH) OR | ||
| (NOT DEFINED SB_CONFIG_SUIT_MPI_${area}_OFFSET) OR | ||
| (NOT DEFINED SB_CONFIG_SUIT_MPI_${area}_SIZE) | ||
| ) | ||
| message(FATAL_ERROR "Malformed configuration for: ${area}") | ||
| return() | ||
| endif() | ||
|
|
||
| # Calculate the absolute address of the MPI area. | ||
| MATH( | ||
| EXPR | ||
| SUIT_MPI_${area}_ADDRESS | ||
| "${SUIT_STORAGE_ADDRESS} | ||
| + ${SB_CONFIG_SUIT_MPI_${area}_OFFSET}" | ||
| OUTPUT_FORMAT HEXADECIMAL | ||
| ) | ||
|
|
||
| set(output ${MPI_BINARY_DIR}/${SB_CONFIG_SUIT_MPI_${area}_PATH}) | ||
| set(address ${SUIT_MPI_${area}_ADDRESS}) | ||
| set(size ${SB_CONFIG_SUIT_MPI_${area}_SIZE}) | ||
|
|
||
| list(APPEND merge_args | ||
| --output-file ${output} | ||
| --address ${address} | ||
| --size ${size} | ||
| ) | ||
|
|
||
| foreach(role ${ARGN}) | ||
| if(NOT DEFINED SB_CONFIG_SUIT_MPI_${role}_PATH) | ||
| continue() | ||
| endif() | ||
|
|
||
| list(APPEND merge_args "--file" "${SB_CONFIG_SUIT_MPI_${role}_PATH}") | ||
| list(APPEND dependencies "${SB_CONFIG_SUIT_MPI_${role}_PATH}") | ||
| endforeach() | ||
|
|
||
| add_custom_target( | ||
| create_suit_mpi_area_${area} | ||
| ALL | ||
| COMMAND ${PYTHON_EXECUTABLE} ${SUIT_GENERATOR_CLI_SCRIPT} | ||
| mpi | ||
| merge | ||
| ${merge_args} | ||
| DEPENDS ${dependencies} | ||
| BYPRODUCTS ${output} | ||
| COMMENT "Create SUIT artifacts" | ||
| ) | ||
|
|
||
| message(INFO " Generate merged MPI for ${area} (${output})") | ||
| endfunction() | ||
|
|
||
| if(DEFINED SB_CONFIG_SOC_SERIES_NRF54HX) | ||
| configure_storage_address_cache() | ||
| endif() # SB_CONFIG_SOC_SERIES_NRF54HX | ||
|
|
||
| if(DEFINED SB_CONFIG_SUIT_MPI_GENERATE) | ||
| if(DEFINED SB_CONFIG_SUIT_MPI_SOC_NRF54H20) | ||
| include(${CMAKE_CURRENT_LIST_DIR}/suit_provisioning_nrf54h20.cmake) | ||
| endif() # SB_CONFIG_SUIT_MPI_SOC_NRF54H20 | ||
| endif() # SB_CONFIG_SUIT_MPI_GENERATE |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.