From 6b7493695716bf8c059bcec1fd8933b892d10e15 Mon Sep 17 00:00:00 2001 From: Mateusz Kapala Date: Wed, 26 Feb 2025 14:21:29 +0100 Subject: [PATCH] sysbuild: fast_pair: Separate provisioning data generation Changed FP provisioning data generation to be handled separately from the SB_CONFIG_BT_FAST_PAIR under the sysbuild Kconfig option SB_CONFIG_BT_FAST_PAIR_PROVISIONING_DATA_GENERATE. It allows to build the app image with FP provisioning data but without the Fast Pair stack enabled, which could be added for example after DFU. The SB_CONFIG_BT_FAST_PAIR option has been left to keep backwards compability in how the Fast Pair stack is enabled and enables the FP provisioning data generation by default. Jira: NCSDK-31128 Signed-off-by: Mateusz Kapala --- cmake/sysbuild/fast_pair_hex.cmake | 4 ++++ .../services/fast_pair/CMakeLists.txt | 8 ------- .../services/fast_pair/fp_registration_data.c | 4 ---- sysbuild/CMakeLists.txt | 23 ++++++++++--------- sysbuild/Kconfig.bt_fast_pair | 13 +++++++---- 5 files changed, 25 insertions(+), 27 deletions(-) diff --git a/cmake/sysbuild/fast_pair_hex.cmake b/cmake/sysbuild/fast_pair_hex.cmake index cccce890cbd9..06692a555af4 100644 --- a/cmake/sysbuild/fast_pair_hex.cmake +++ b/cmake/sysbuild/fast_pair_hex.cmake @@ -143,6 +143,10 @@ function(fast_pair_hex_dts) ) endfunction() +if(NOT DEFINED FP_MODEL_ID OR NOT DEFINED FP_ANTI_SPOOFING_KEY) + message(FATAL_ERROR "Automatic Fast Pair provisioning data generation is enabled but `FP_MODEL_ID` or `FP_ANTI_SPOOFING_KEY` were not provided.") +endif() + if(SB_CONFIG_PARTITION_MANAGER) fast_pair_hex_pm() else() diff --git a/subsys/bluetooth/services/fast_pair/CMakeLists.txt b/subsys/bluetooth/services/fast_pair/CMakeLists.txt index 5ede6b91a6c1..c2a1cd5ebf2c 100644 --- a/subsys/bluetooth/services/fast_pair/CMakeLists.txt +++ b/subsys/bluetooth/services/fast_pair/CMakeLists.txt @@ -38,11 +38,3 @@ if(CONFIG_BT_FAST_PAIR_FMDN) add_subdirectory(fmdn) target_link_libraries(fast_pair PRIVATE fmdn) endif() - -zephyr_get(FP_DATA_PRESENT MERGE SYSBUILD) - -if(NOT FP_DATA_PRESENT AND TARGET zephyr_interface) - zephyr_compile_definitions( - FP_DATA_NOT_PRESENT - ) -endif() diff --git a/subsys/bluetooth/services/fast_pair/fp_registration_data.c b/subsys/bluetooth/services/fast_pair/fp_registration_data.c index 4dac3c7316a3..952f5d6f5350 100644 --- a/subsys/bluetooth/services/fast_pair/fp_registration_data.c +++ b/subsys/bluetooth/services/fast_pair/fp_registration_data.c @@ -46,10 +46,6 @@ static const uint8_t fp_magic[] = {0xFA, 0x57, 0xFA, 0x57}; #define FP_DATA_SIZE (FP_END_OFF - FP_DATA_START) #define FP_OFFSET_TO_DATA_IDX(_offset) ((_offset) - FP_DATA_START) -#ifdef FP_DATA_NOT_PRESENT -#error "Fast Pair provisioning data was not provided with `FP_MODEL_ID` and `FP_ANTI_SPOOFING_KEY`" -#endif - BUILD_ASSERT(FP_END_OFF <= FP_PARTITION_SIZE, "Fast Pair registration data partition is too small"); static bool is_enabled; diff --git a/sysbuild/CMakeLists.txt b/sysbuild/CMakeLists.txt index 9d305f7b6f71..b5b1b711aa9e 100644 --- a/sysbuild/CMakeLists.txt +++ b/sysbuild/CMakeLists.txt @@ -506,19 +506,20 @@ function(${SYSBUILD_CURRENT_MODULE_NAME}_pre_cmake) if(SB_CONFIG_BT_FAST_PAIR) set_config_bool(${DEFAULT_IMAGE} CONFIG_BT_FAST_PAIR y) + else() + set_config_bool(${DEFAULT_IMAGE} CONFIG_BT_FAST_PAIR n) + endif() - if(DEFINED FP_MODEL_ID AND DEFINED FP_ANTI_SPOOFING_KEY) - 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") - set(FP_DATA_PRESENT "n" CACHE INTERNAL "Fast Pair provisioning data provided" FORCE) + if(SB_CONFIG_BT_FAST_PAIR_PROVISIONING_DATA_GENERATE) + if(SB_CONFIG_PARTITION_MANAGER) + include(${ZEPHYR_NRF_MODULE_DIR}/cmake/sysbuild/fast_pair_hex.cmake) endif() else() - set_config_bool(${DEFAULT_IMAGE} CONFIG_BT_FAST_PAIR n) + if(SB_CONFIG_BT_FAST_PAIR) + message(WARNING "Fast Pair support is enabled but automatic Fast Pair provisioning data generation is disabled. " + "If FP_MODEL_ID and FP_ANTI_SPOOFING_KEY were provided, they will be ignored. " + "This means that the Fast Pair provisioning data must be generated manually.") + endif() endif() if(SB_CONFIG_WIFI_NRF70) @@ -655,7 +656,7 @@ 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) + if(SB_CONFIG_BT_FAST_PAIR_PROVISIONING_DATA_GENERATE AND NOT SB_CONFIG_PARTITION_MANAGER) include(${ZEPHYR_NRF_MODULE_DIR}/cmake/sysbuild/fast_pair_hex.cmake) endif() diff --git a/sysbuild/Kconfig.bt_fast_pair b/sysbuild/Kconfig.bt_fast_pair index 434b7978e593..b138ba4fd0b3 100644 --- a/sysbuild/Kconfig.bt_fast_pair +++ b/sysbuild/Kconfig.bt_fast_pair @@ -7,7 +7,12 @@ config BT_FAST_PAIR bool "Bluetooth Fast Pair support" help - Enable this option to generate a Fast Pair provisioning data hex file and enable - Bluetooth Fast Pair support in the main image. Note that ``FP_MODEL_ID`` and - ``FP_ANTI_SPOOFING_KEY`` variables must be supplied when configuring the application for - this functionality to be available. + Enable this option to enable Bluetooth Fast Pair support in the main image. + +config BT_FAST_PAIR_PROVISIONING_DATA_GENERATE + bool "Generate Fast Pair provisioning data" + default y if BT_FAST_PAIR + help + Enable this option to generate a Fast Pair provisioning data hex file. + Note that ``FP_MODEL_ID`` and ``FP_ANTI_SPOOFING_KEY`` variables must be supplied when + configuring the application for this functionality to be available.