Skip to content

Commit 992213e

Browse files
kapi-nonordicjm
authored andcommitted
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 <[email protected]> Signed-off-by: Jamie McCrae <[email protected]>
1 parent ec6c446 commit 992213e

File tree

4 files changed

+91
-6
lines changed

4 files changed

+91
-6
lines changed

cmake/sysbuild/fast_pair_hex.cmake

Lines changed: 75 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#
2-
# Copyright (c) 2022-2023 Nordic Semiconductor
2+
# Copyright (c) 2022-2024 Nordic Semiconductor
33
#
44
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
55
#
66

7-
function(fast_pair_hex)
7+
function(fast_pair_hex_pm)
88
set(fp_partition_name bt_fast_pair)
99

1010
set(
@@ -47,4 +47,76 @@ function(fast_pair_hex)
4747
)
4848
endfunction()
4949

50-
fast_pair_hex()
50+
function(fast_pair_hex_dts)
51+
include(${CMAKE_CURRENT_LIST_DIR}/suit_utilities.cmake)
52+
53+
if(NOT SB_CONFIG_SOC_SERIES_NRF54HX)
54+
message(FATAL_ERROR "Fast Pair data provisioning using DTS partitions is only supported"
55+
"for nRF54H series.")
56+
endif()
57+
58+
set(fp_partition_name bt_fast_pair_partition)
59+
60+
sysbuild_dt_nodelabel(
61+
bt_fast_pair_partition_nodelabel
62+
IMAGE
63+
${DEFAULT_IMAGE}
64+
NODELABEL
65+
"${fp_partition_name}"
66+
)
67+
sysbuild_dt_reg_addr(
68+
bt_fast_pair_partition_relative_address
69+
IMAGE
70+
${DEFAULT_IMAGE}
71+
PATH
72+
"${bt_fast_pair_partition_nodelabel}"
73+
)
74+
75+
# This part assumes that the Fast Pair partition resides in MRAM1x.
76+
# TODO: Rewrite it to be more generic and support other memory regions.
77+
sysbuild_dt_nodelabel(mram1x_nodelabel IMAGE ${DEFAULT_IMAGE} NODELABEL "mram1x")
78+
sysbuild_dt_reg_addr(mram1x_address IMAGE ${DEFAULT_IMAGE} PATH "${mram1x_nodelabel}")
79+
80+
math(
81+
EXPR
82+
bt_fast_pair_partition_address
83+
"${mram1x_address} + ${bt_fast_pair_partition_relative_address}"
84+
OUTPUT_FORMAT
85+
HEXADECIMAL)
86+
87+
set(
88+
fp_provisioning_data_hex
89+
${CMAKE_BINARY_DIR}/modules/nrf/subsys/bluetooth/services/fast_pair/fp_provisioning_data.hex
90+
)
91+
92+
set(fp_provisioning_data_address ${bt_fast_pair_partition_address})
93+
94+
add_custom_command(
95+
OUTPUT
96+
${fp_provisioning_data_hex}
97+
COMMAND
98+
${PYTHON_EXECUTABLE} ${ZEPHYR_NRF_MODULE_DIR}/scripts/nrf_provision/fast_pair/fp_provision_cli.py
99+
-o ${fp_provisioning_data_hex} -a ${fp_provisioning_data_address}
100+
-m ${FP_MODEL_ID} -k ${FP_ANTI_SPOOFING_KEY}
101+
COMMENT
102+
"Generating Fast Pair provisioning data hex file"
103+
USES_TERMINAL
104+
)
105+
106+
add_custom_target(
107+
${fp_partition_name}_target
108+
ALL
109+
DEPENDS
110+
"${fp_provisioning_data_hex}"
111+
)
112+
113+
suit_add_merge_hex_file(FILES ${fp_provisioning_data_hex}
114+
DEPENDENCIES ${fp_partition_name}_target
115+
)
116+
endfunction()
117+
118+
if(SB_CONFIG_PARTITION_MANAGER)
119+
fast_pair_hex_pm()
120+
else()
121+
fast_pair_hex_dts()
122+
endif()

subsys/bluetooth/services/fast_pair/Kconfig.fast_pair

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ endif # BT_FAST_PAIR_GATT_SERVICE
131131
config BT_FAST_PAIR_REGISTRATION_DATA
132132
bool
133133
default y
134-
select PM_SINGLE_IMAGE
134+
select PM_SINGLE_IMAGE if !(SOC_SERIES_NRF54HX)
135135
help
136136
Add Fast Pair registration data source files.
137137

subsys/bluetooth/services/fast_pair/fp_registration_data.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
#include <string.h>
99
#include <zephyr/device.h>
1010
#include <zephyr/storage/flash_map.h>
11-
#include <pm_config.h>
1211

1312
#include <zephyr/logging/log.h>
1413
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);
1817
#include "fp_crypto.h"
1918
#include "fp_registration_data.h"
2019

20+
#if defined(CONFIG_PARTITION_MANAGER_ENABLED)
21+
#include <pm_config.h>
2122
#define FP_PARTITION_ID PM_BT_FAST_PAIR_ID
2223
#define FP_PARTITION_SIZE PM_BT_FAST_PAIR_SIZE
24+
#else
25+
#define FP_PARTITION_ID FIXED_PARTITION_ID(bt_fast_pair_partition)
26+
#define FP_PARTITION_SIZE FIXED_PARTITION_SIZE(bt_fast_pair_partition)
27+
#endif
2328

2429
static const uint8_t fp_magic[] = {0xFA, 0x57, 0xFA, 0x57};
2530

sysbuild/CMakeLists.txt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,10 @@ function(${SYSBUILD_CURRENT_MODULE_NAME}_pre_cmake)
498498
set_config_bool(${DEFAULT_IMAGE} CONFIG_BT_FAST_PAIR y)
499499

500500
if(DEFINED FP_MODEL_ID AND DEFINED FP_ANTI_SPOOFING_KEY)
501-
include(${ZEPHYR_NRF_MODULE_DIR}/cmake/sysbuild/fast_pair_hex.cmake)
501+
if(SB_CONFIG_PARTITION_MANAGER)
502+
include(${ZEPHYR_NRF_MODULE_DIR}/cmake/sysbuild/fast_pair_hex.cmake)
503+
endif()
504+
502505
set(FP_DATA_PRESENT "y" CACHE INTERNAL "Fast Pair provisioning data provided" FORCE)
503506
else()
504507
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")
@@ -613,6 +616,11 @@ function(${SYSBUILD_CURRENT_MODULE_NAME}_post_cmake)
613616

614617
set_property(GLOBAL PROPERTY DOMAIN_APP_APP ${DEFAULT_IMAGE})
615618

619+
# Include any files that need to merge files with uicr_merged.hex before including suit
620+
if(FP_DATA_PRESENT AND NOT SB_CONFIG_PARTITION_MANAGER)
621+
include(${ZEPHYR_NRF_MODULE_DIR}/cmake/sysbuild/fast_pair_hex.cmake)
622+
endif()
623+
616624
include_packaging()
617625
include_suit()
618626

0 commit comments

Comments
 (0)