Skip to content

Commit 49acaa0

Browse files
alstrzebonskijukkar
authored andcommitted
fast_pair: Remove MRAM1x dependency for targets without Partition Manager
Removes MRAM1x dependency for targets without Partition Manager. The absolute Fast Pair partition address is now calculated by getting address of Fast Pair partition grandparent and adding it to Fast Pair partition relative address. Fast Pair partition grandparent node is a NVM node the partition resides in. Jira: NCSDK-29847 Signed-off-by: Aleksander Strzebonski <[email protected]>
1 parent 568a7d4 commit 49acaa0

File tree

2 files changed

+37
-8
lines changed

2 files changed

+37
-8
lines changed

cmake/sysbuild/fast_pair_hex.cmake

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,18 @@ function(fast_pair_hex_pm)
4747
)
4848
endfunction()
4949

50+
# This function should probably one day be moved to some common utilities file.
51+
function(dt_get_parent parent_full_path node_full_path)
52+
string(FIND "${node_full_path}" "/" pos REVERSE)
53+
54+
if(pos LESS_EQUAL 0)
55+
message(FATAL_ERROR "Unable to get parent of node: ${node_full_path}")
56+
endif()
57+
58+
string(SUBSTRING "${node_full_path}" 0 ${pos} parent)
59+
set(${parent_full_path} ${parent} PARENT_SCOPE)
60+
endfunction()
61+
5062
function(fast_pair_hex_dts)
5163
include(${CMAKE_CURRENT_LIST_DIR}/suit_utilities.cmake)
5264

@@ -58,31 +70,47 @@ function(fast_pair_hex_dts)
5870
set(fp_partition_name bt_fast_pair_partition)
5971

6072
sysbuild_dt_nodelabel(
61-
bt_fast_pair_partition_nodelabel
73+
bt_fast_pair_partition_node_full_path
6274
IMAGE
6375
${DEFAULT_IMAGE}
6476
NODELABEL
6577
"${fp_partition_name}"
6678
)
79+
6780
sysbuild_dt_reg_addr(
6881
bt_fast_pair_partition_relative_address
6982
IMAGE
7083
${DEFAULT_IMAGE}
7184
PATH
72-
"${bt_fast_pair_partition_nodelabel}"
85+
"${bt_fast_pair_partition_node_full_path}"
7386
)
7487

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}")
88+
# It's assumed that the Fast Pair partition node is a child of an address-less node which groups
89+
# partitions and is a child of a NVM node. For more details see the Fixed flash partitions section
90+
# of https://docs.zephyrproject.org/latest/build/dts/intro-syntax-structure.html#unit-addresses.
91+
dt_get_parent(
92+
bt_fast_pair_partition_node_parent_full_path
93+
"${bt_fast_pair_partition_node_full_path}"
94+
)
95+
dt_get_parent(
96+
nvm_node_full_path
97+
"${bt_fast_pair_partition_node_parent_full_path}"
98+
)
99+
sysbuild_dt_reg_addr(
100+
nvm_base_address
101+
IMAGE
102+
${DEFAULT_IMAGE}
103+
PATH
104+
"${nvm_node_full_path}"
105+
)
79106

80107
math(
81108
EXPR
82109
bt_fast_pair_partition_address
83-
"${mram1x_address} + ${bt_fast_pair_partition_relative_address}"
110+
"${nvm_base_address} + ${bt_fast_pair_partition_relative_address}"
84111
OUTPUT_FORMAT
85-
HEXADECIMAL)
112+
HEXADECIMAL
113+
)
86114

87115
set(
88116
fp_provisioning_data_hex

subsys/bluetooth/services/fast_pair/fp_registration_data.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ LOG_MODULE_DECLARE(fast_pair, CONFIG_BT_FAST_PAIR_LOG_LEVEL);
2222
#define FP_PARTITION_ID PM_BT_FAST_PAIR_ID
2323
#define FP_PARTITION_SIZE PM_BT_FAST_PAIR_SIZE
2424
#else
25+
BUILD_ASSERT(FIXED_PARTITION_EXISTS(bt_fast_pair_partition));
2526
#define FP_PARTITION_ID FIXED_PARTITION_ID(bt_fast_pair_partition)
2627
#define FP_PARTITION_SIZE FIXED_PARTITION_SIZE(bt_fast_pair_partition)
2728
#endif

0 commit comments

Comments
 (0)