From 6c06685fa247b91cf6aaad1fea356982e3fc1e7c Mon Sep 17 00:00:00 2001 From: Jamie McCrae Date: Fri, 8 Nov 2024 11:07:25 +0000 Subject: [PATCH 1/5] cmake: sysbuild: suit: Add support for merging other files Adds support for merging other files onto the uicr_merged.hex file Signed-off-by: Jamie McCrae --- cmake/sysbuild/suit.cmake | 8 +++++++- cmake/sysbuild/suit_utilities.cmake | 17 +++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/cmake/sysbuild/suit.cmake b/cmake/sysbuild/suit.cmake index 9f2939f1c377..1fbcf2d4adcc 100644 --- a/cmake/sysbuild/suit.cmake +++ b/cmake/sysbuild/suit.cmake @@ -534,12 +534,18 @@ function(suit_setup_merge) list(APPEND ARTIFACTS_TO_MERGE ${BINARY_DIR}/zephyr/suit_mpi_${IMAGE_TARGET_NAME}_merged.hex) endif() + # Get a list of files (and their dependencies) which need merging into the uicr merged file and + # add them at the end of the list, allowing for overwriting + get_property(merge_files GLOBAL PROPERTY SUIT_MERGE_FILE) + get_property(merge_dependencies GLOBAL PROPERTY SUIT_MERGE_DEPENDENCIES) + set_property( GLOBAL APPEND PROPERTY SUIT_POST_BUILD_COMMANDS COMMAND ${PYTHON_EXECUTABLE} ${ZEPHYR_BASE}/scripts/build/mergehex.py --overlap replace -o ${OUTPUT_HEX_FILE} - ${ARTIFACTS_TO_MERGE} + ${ARTIFACTS_TO_MERGE} ${merge_files} + DEPENDS ${merge_dependencies} # fixme: uicr_merged is overwritten by new content, runners_yaml_props_target could be used to define # what shall be flashed, but not sure where to set this! Remove --overlap if ready! # example usage: set_property(TARGET runners_yaml_props_target PROPERTY hex_file ${merged_hex_file}) diff --git a/cmake/sysbuild/suit_utilities.cmake b/cmake/sysbuild/suit_utilities.cmake index 9acdbc639c02..835672bcfb4a 100644 --- a/cmake/sysbuild/suit_utilities.cmake +++ b/cmake/sysbuild/suit_utilities.cmake @@ -108,3 +108,20 @@ function(suit_create_cache_partition args output_file partition_num recovery) "${output_file_name}type=cache;${output_file_name}partition=${partition_num};") endif() endfunction() + +# Usage: +# suit_add_merge_hex_file(FILES [DEPENDENCIES ] +# +# Add files which should be merged into the uicr_merged.hex output file, respecting any +# dependencies that need to be generated before hand. This will overwrite existing data if it is +# present in other files +function(suit_add_merge_hex_file) + cmake_parse_arguments(VAR "" "" "FILES;DEPENDENCIES" ${ARGN}) + + if(NOT VAR_FILES) + message(FATAL_ERROR "suit_add_merge_hex_file missing required argument FILES") + endif() + + set_property(GLOBAL APPEND PROPERTY SUIT_MERGE_FILE ${VAR_FILES}) + set_property(GLOBAL APPEND PROPERTY SUIT_MERGE_DEPENDENCIES ${VAR_DEPENDENCIES}) +endfunction() From 53b9449271bdb5a960fdc2895e17b7da03bc6a7a Mon Sep 17 00:00:00 2001 From: Kamil Piszczek Date: Mon, 14 Oct 2024 13:55:26 +0200 Subject: [PATCH 2/5] cmake: sysbuild: fast_pair: add support for nRF54H20 non-PM Adds support for generating fast pair data for nRF54H20 which does not use partition manager Signed-off-by: Kamil Piszczek Signed-off-by: Jamie McCrae --- cmake/sysbuild/fast_pair_hex.cmake | 78 ++++++++++++++++++- .../services/fast_pair/Kconfig.fast_pair | 2 +- .../services/fast_pair/fp_registration_data.c | 7 +- sysbuild/CMakeLists.txt | 10 ++- 4 files changed, 91 insertions(+), 6 deletions(-) diff --git a/cmake/sysbuild/fast_pair_hex.cmake b/cmake/sysbuild/fast_pair_hex.cmake index 50ed997ba464..9515bd53bf36 100644 --- a/cmake/sysbuild/fast_pair_hex.cmake +++ b/cmake/sysbuild/fast_pair_hex.cmake @@ -1,10 +1,10 @@ # -# Copyright (c) 2022-2023 Nordic Semiconductor +# Copyright (c) 2022-2024 Nordic Semiconductor # # SPDX-License-Identifier: LicenseRef-Nordic-5-Clause # -function(fast_pair_hex) +function(fast_pair_hex_pm) set(fp_partition_name bt_fast_pair) set( @@ -47,4 +47,76 @@ function(fast_pair_hex) ) endfunction() -fast_pair_hex() +function(fast_pair_hex_dts) + include(${CMAKE_CURRENT_LIST_DIR}/suit_utilities.cmake) + + if(NOT SB_CONFIG_SOC_SERIES_NRF54HX) + message(FATAL_ERROR "Fast Pair data provisioning using DTS partitions is only supported" + "for nRF54H series.") + endif() + + set(fp_partition_name bt_fast_pair_partition) + + sysbuild_dt_nodelabel( + bt_fast_pair_partition_nodelabel + IMAGE + ${DEFAULT_IMAGE} + NODELABEL + "${fp_partition_name}" + ) + sysbuild_dt_reg_addr( + bt_fast_pair_partition_relative_address + IMAGE + ${DEFAULT_IMAGE} + PATH + "${bt_fast_pair_partition_nodelabel}" + ) + + # This part assumes that the Fast Pair partition resides in MRAM1x. + # TODO: Rewrite it to be more generic and support other memory regions. + sysbuild_dt_nodelabel(mram1x_nodelabel IMAGE ${DEFAULT_IMAGE} NODELABEL "mram1x") + sysbuild_dt_reg_addr(mram1x_address IMAGE ${DEFAULT_IMAGE} PATH "${mram1x_nodelabel}") + + math( + EXPR + bt_fast_pair_partition_address + "${mram1x_address} + ${bt_fast_pair_partition_relative_address}" + OUTPUT_FORMAT + HEXADECIMAL) + + set( + fp_provisioning_data_hex + ${CMAKE_BINARY_DIR}/modules/nrf/subsys/bluetooth/services/fast_pair/fp_provisioning_data.hex + ) + + set(fp_provisioning_data_address ${bt_fast_pair_partition_address}) + + add_custom_command( + OUTPUT + ${fp_provisioning_data_hex} + COMMAND + ${PYTHON_EXECUTABLE} ${ZEPHYR_NRF_MODULE_DIR}/scripts/nrf_provision/fast_pair/fp_provision_cli.py + -o ${fp_provisioning_data_hex} -a ${fp_provisioning_data_address} + -m ${FP_MODEL_ID} -k ${FP_ANTI_SPOOFING_KEY} + COMMENT + "Generating Fast Pair provisioning data hex file" + USES_TERMINAL + ) + + add_custom_target( + ${fp_partition_name}_target + ALL + DEPENDS + "${fp_provisioning_data_hex}" + ) + + suit_add_merge_hex_file(FILES ${fp_provisioning_data_hex} + DEPENDENCIES ${fp_partition_name}_target + ) +endfunction() + +if(SB_CONFIG_PARTITION_MANAGER) + fast_pair_hex_pm() +else() + fast_pair_hex_dts() +endif() diff --git a/subsys/bluetooth/services/fast_pair/Kconfig.fast_pair b/subsys/bluetooth/services/fast_pair/Kconfig.fast_pair index 9931a1ae035c..2683dbc02633 100644 --- a/subsys/bluetooth/services/fast_pair/Kconfig.fast_pair +++ b/subsys/bluetooth/services/fast_pair/Kconfig.fast_pair @@ -131,7 +131,7 @@ endif # BT_FAST_PAIR_GATT_SERVICE config BT_FAST_PAIR_REGISTRATION_DATA bool default y - select PM_SINGLE_IMAGE + select PM_SINGLE_IMAGE if !(SOC_SERIES_NRF54HX) help Add Fast Pair registration data source files. diff --git a/subsys/bluetooth/services/fast_pair/fp_registration_data.c b/subsys/bluetooth/services/fast_pair/fp_registration_data.c index d98774eea8ec..09a36e75b0c3 100644 --- a/subsys/bluetooth/services/fast_pair/fp_registration_data.c +++ b/subsys/bluetooth/services/fast_pair/fp_registration_data.c @@ -8,7 +8,6 @@ #include #include #include -#include #include LOG_MODULE_DECLARE(fast_pair, CONFIG_BT_FAST_PAIR_LOG_LEVEL); @@ -18,8 +17,14 @@ LOG_MODULE_DECLARE(fast_pair, CONFIG_BT_FAST_PAIR_LOG_LEVEL); #include "fp_crypto.h" #include "fp_registration_data.h" +#if defined(CONFIG_PARTITION_MANAGER_ENABLED) +#include #define FP_PARTITION_ID PM_BT_FAST_PAIR_ID #define FP_PARTITION_SIZE PM_BT_FAST_PAIR_SIZE +#else +#define FP_PARTITION_ID FIXED_PARTITION_ID(bt_fast_pair_partition) +#define FP_PARTITION_SIZE FIXED_PARTITION_SIZE(bt_fast_pair_partition) +#endif static const uint8_t fp_magic[] = {0xFA, 0x57, 0xFA, 0x57}; diff --git a/sysbuild/CMakeLists.txt b/sysbuild/CMakeLists.txt index 42f841986f13..98fbe5f3653c 100644 --- a/sysbuild/CMakeLists.txt +++ b/sysbuild/CMakeLists.txt @@ -495,7 +495,10 @@ function(${SYSBUILD_CURRENT_MODULE_NAME}_pre_cmake) set_config_bool(${DEFAULT_IMAGE} CONFIG_BT_FAST_PAIR y) if(DEFINED FP_MODEL_ID AND DEFINED FP_ANTI_SPOOFING_KEY) - include(${ZEPHYR_NRF_MODULE_DIR}/cmake/sysbuild/fast_pair_hex.cmake) + if(SB_CONFIG_PARTITION_MANAGER) + include(${ZEPHYR_NRF_MODULE_DIR}/cmake/sysbuild/fast_pair_hex.cmake) + endif() + set(FP_DATA_PRESENT "y" CACHE INTERNAL "Fast Pair provisioning data provided" FORCE) else() message(WARNING "Fast Pair support is enabled but `FP_MODEL_ID` or `FP_ANTI_SPOOFING_KEY` were not provided, this is likely to cause a build error") @@ -610,6 +613,11 @@ function(${SYSBUILD_CURRENT_MODULE_NAME}_post_cmake) set_property(GLOBAL PROPERTY DOMAIN_APP_APP ${DEFAULT_IMAGE}) + # Include any files that need to merge files with uicr_merged.hex before including suit + if(FP_DATA_PRESENT AND NOT SB_CONFIG_PARTITION_MANAGER) + include(${ZEPHYR_NRF_MODULE_DIR}/cmake/sysbuild/fast_pair_hex.cmake) + endif() + include_packaging() include_suit() From c51efb6754fc502a36d6c667ac0df96390ab135f Mon Sep 17 00:00:00 2001 From: Kamil Piszczek Date: Thu, 17 Oct 2024 08:52:33 +0200 Subject: [PATCH 3/5] samples: bluetooth: fast_pair: input_device: add support for nrf54h20dk Added nRF54H20 DK support to the Fast Pair Input Device sample. Ref: NCSDK-29602 Signed-off-by: Kamil Piszczek --- .../boards/nrf54h20dk_nrf54h20_cpuapp.overlay | 32 +++++++++++++++++++ .../fast_pair/input_device/sample.yaml | 2 ++ 2 files changed, 34 insertions(+) create mode 100644 samples/bluetooth/fast_pair/input_device/boards/nrf54h20dk_nrf54h20_cpuapp.overlay diff --git a/samples/bluetooth/fast_pair/input_device/boards/nrf54h20dk_nrf54h20_cpuapp.overlay b/samples/bluetooth/fast_pair/input_device/boards/nrf54h20dk_nrf54h20_cpuapp.overlay new file mode 100644 index 000000000000..862b134c777b --- /dev/null +++ b/samples/bluetooth/fast_pair/input_device/boards/nrf54h20dk_nrf54h20_cpuapp.overlay @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ + +&mram1x { + /delete-node/ cpuapp_rw_partitions; + + cpuapp_rw_partitions: cpuapp-rw-partitions { + compatible = "nordic,owned-partitions", "fixed-partitions"; + status = "okay"; + perm-read; + perm-write; + perm-secure; + #address-cells = <1>; + #size-cells = <1>; + + dfu_partition: partition@100000 { + reg = <0x100000 DT_SIZE_K(908)>; + }; + + storage_partition: partition@1e3000 { + reg = <0x1e3000 DT_SIZE_K(20)>; + }; + + bt_fast_pair_partition: partition@1e8fb8 { + label = "bt_fast_pair"; + reg = <0x1e8fb8 0x48>; + }; + }; +}; diff --git a/samples/bluetooth/fast_pair/input_device/sample.yaml b/samples/bluetooth/fast_pair/input_device/sample.yaml index 75f185f94ba0..c0bc9b68962d 100644 --- a/samples/bluetooth/fast_pair/input_device/sample.yaml +++ b/samples/bluetooth/fast_pair/input_device/sample.yaml @@ -11,10 +11,12 @@ tests: - nrf5340dk/nrf5340/cpuapp - nrf5340dk/nrf5340/cpuapp/ns - nrf54l15dk/nrf54l15/cpuapp + - nrf54h20dk/nrf54h20/cpuapp platform_allow: - nrf52dk/nrf52832 - nrf52840dk/nrf52840 - nrf5340dk/nrf5340/cpuapp - nrf5340dk/nrf5340/cpuapp/ns - nrf54l15dk/nrf54l15/cpuapp + - nrf54h20dk/nrf54h20/cpuapp tags: bluetooth ci_build sysbuild From 7491f0198cdcfafcf1809a1526a70c58dc57d511 Mon Sep 17 00:00:00 2001 From: Jamie McCrae Date: Fri, 8 Nov 2024 12:02:35 +0000 Subject: [PATCH 4/5] manifest: Update sdk-connectedhomeip Updates matter to include support for generating factory data when partition manager is not used Signed-off-by: Jamie McCrae --- west.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/west.yml b/west.yml index c0a07a029213..9382c4d22484 100644 --- a/west.yml +++ b/west.yml @@ -158,7 +158,7 @@ manifest: - name: matter repo-path: sdk-connectedhomeip path: modules/lib/matter - revision: 81eb1e99a9fd48bbf3bca2a56e7ac888c7f24a16 + revision: pull/511/head west-commands: scripts/west/west-commands.yml submodules: - name: nlio From 2b3619b60e22623d9752b1445afd15b2b06472cf Mon Sep 17 00:00:00 2001 From: Jamie McCrae Date: Fri, 8 Nov 2024 11:59:02 +0000 Subject: [PATCH 5/5] sysbuild: Add support for matter non-PM factory data generation Calls the updated factory data function irrespective of partition manager enablement Signed-off-by: Jamie McCrae --- sysbuild/CMakeLists.txt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sysbuild/CMakeLists.txt b/sysbuild/CMakeLists.txt index 98fbe5f3653c..037f9b098e29 100644 --- a/sysbuild/CMakeLists.txt +++ b/sysbuild/CMakeLists.txt @@ -618,6 +618,11 @@ function(${SYSBUILD_CURRENT_MODULE_NAME}_post_cmake) include(${ZEPHYR_NRF_MODULE_DIR}/cmake/sysbuild/fast_pair_hex.cmake) endif() + if(SB_CONFIG_MATTER_FACTORY_DATA_GENERATE) + include(${ZEPHYR_CONNECTEDHOMEIP_MODULE_DIR}/config/nrfconnect/chip-module/generate_factory_data_sysbuild.cmake) + nrfconnect_generate_factory_data() + endif() + include_packaging() include_suit() @@ -625,11 +630,6 @@ function(${SYSBUILD_CURRENT_MODULE_NAME}_post_cmake) include_provision_hex() endif() - if(SB_CONFIG_MATTER_FACTORY_DATA_GENERATE AND SB_CONFIG_PARTITION_MANAGER) - include(${ZEPHYR_CONNECTEDHOMEIP_MODULE_DIR}/config/nrfconnect/chip-module/generate_factory_data_sysbuild.cmake) - nrfconnect_generate_factory_data() - endif() - if(SB_CONFIG_MATTER_OTA) include(${ZEPHYR_CONNECTEDHOMEIP_MODULE_DIR}/config/zephyr/ota-image_sysbuild.cmake) if(SB_CONFIG_DFU_MULTI_IMAGE_PACKAGE_BUILD OR SB_CONFIG_SUIT_MULTI_IMAGE_PACKAGE_BUILD)