Skip to content

Commit fb701f7

Browse files
committed
sysbuild: Add matter_factory_data image and configuration
Adds a image which is used by matter and contains the factory settings for the device Signed-off-by: Jamie McCrae <[email protected]>
1 parent 9147963 commit fb701f7

File tree

6 files changed

+98
-8
lines changed

6 files changed

+98
-8
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#
2+
# Copyright (c) 2025 Nordic Semiconductor ASA
3+
#
4+
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
#
6+
7+
cmake_minimum_required(VERSION 3.20.0)
8+
9+
# Do not apply shield or snippets for the factory data partition and use an empty file for the
10+
# board defconfig file
11+
set(BOARD_DEFCONFIG ${CMAKE_CURRENT_SOURCE_DIR}/prj.conf)
12+
set(CACHED_SHIELD "" CACHE STRING "" FORCE)
13+
set(CACHED_SNIPPET "" CACHE STRING "" FORCE)
14+
15+
find_package(Zephyr
16+
COMPONENTS zephyr_default:kconfig
17+
REQUIRED HINTS $ENV{ZEPHYR_BASE}
18+
)
19+
20+
project(matter_factory_data)
21+
22+
# Manually include board configuration to enable automatic runners.yaml generation
23+
include(${BOARD_DIR}/board.cmake OPTIONAL)
24+
25+
# Create the runners_yaml_props_target that flash system expects
26+
add_custom_target(runners_yaml_props_target)
27+
28+
# Override the runners.yaml path to use CMAKE_CURRENT_BINARY_DIR/zephyr instead of
29+
# PROJECT_BINARY_DIR, this ensures runners.yaml is generated at <build>/softdevice/zephyr where
30+
# west expects it
31+
set(PROJECT_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/zephyr)
32+
33+
# Import Kconfig and DTS from the application then generate the factory data hex file which will
34+
# be flashed when west flash is invoked. Unlike PM, it will not be merged with the application
35+
# into a new hex file
36+
set(app_dir ${CMAKE_CURRENT_BINARY_DIR}/../${CONFIG_APPLICATION_NAME})
37+
import_kconfig(CONFIG_ ${app_dir}/zephyr/.config)
38+
zephyr_dt_import(EDT_PICKLE_FILE ${app_dir}/zephyr/edt.pickle TARGET devicetree_target)
39+
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS
40+
${app_dir}/zephyr/.config
41+
${app_dir}/zephyr/edt.pickle
42+
)
43+
set(CHIP_ROOT ${ZEPHYR_CONNECTEDHOMEIP_MODULE_DIR})
44+
include(/tmp/bb/modules/lib/matter/config/nrfconnect/chip-module/generate_factory_data.cmake)
45+
nrfconnect_generate_factory_data()
46+
47+
# Set hex_file property to point to factory data output file in this directory
48+
set_target_properties(runners_yaml_props_target PROPERTIES
49+
hex_file "${CMAKE_CURRENT_BINARY_DIR}/factory_data.hex"
50+
)
51+
52+
# Include flash support to automatically generate runners.yaml
53+
include(${ZEPHYR_BASE}/cmake/flash/CMakeLists.txt)
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#
2+
# Copyright (c) 2025 Nordic Semiconductor ASA
3+
#
4+
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
#
6+
7+
config APPLICATION_NAME
8+
string "Application name (informative only, do not change)"
9+
10+
config PARTITION_MANAGER_ENABLED
11+
bool "Partition manager is enabled (informative only, do not change)"
12+
13+
config BUILD_OUTPUT_BIN
14+
bool "Build a binary in BIN format (informative only, do not change)"
15+
16+
config BUILD_OUTPUT_HEX
17+
bool "Build a binary in HEX format (informative only, do not change)"
18+
default y
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Nothing here

sysbuild/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,5 +1054,6 @@ include(${CMAKE_CURRENT_LIST_DIR}/radio_loader.cmake)
10541054
include(${CMAKE_CURRENT_LIST_DIR}/secureboot.cmake)
10551055
include(${CMAKE_CURRENT_LIST_DIR}/mcuboot.cmake)
10561056
include(${CMAKE_CURRENT_LIST_DIR}/firmware_loader_radio.cmake)
1057+
include(${CMAKE_CURRENT_LIST_DIR}/matter_factory_data.cmake)
10571058

10581059
store_ncs_vars()

sysbuild/Kconfig.matter

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ config MATTER_FACTORY_DATA_GENERATE
1414
Generate Matter factory data set and the HEX file for the sample during the building
1515
process.
1616

17-
config MATTER_FACTORY_DATA_MERGE_WITH_FIRMWARE
18-
bool "Merge generated factory data with merged.hex output"
19-
depends on MATTER_FACTORY_DATA_GENERATE
20-
default y
21-
help
22-
Enables merging the generated factory data with the merged.hex output build file. As a
23-
result, the merged.hex build output file, which is used when flashing the firmware using
24-
the west tool, includes the factory data as well.
17+
#config MATTER_FACTORY_DATA_MERGE_WITH_FIRMWARE
18+
# bool "Merge generated factory data with merged.hex output"
19+
# depends on MATTER_FACTORY_DATA_GENERATE
20+
# default y
21+
# help
22+
# Enables merging the generated factory data with the merged.hex output build file. As a
23+
# result, the merged.hex build output file, which is used when flashing the firmware using
24+
# the west tool, includes the factory data as well.
2525

2626
config MATTER_OTA
2727
bool "Matter OTA Software Update"

sysbuild/matter_factory_data.cmake

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#
2+
# Copyright (c) 2025 Nordic Semiconductor
3+
#
4+
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
#
6+
7+
if(SB_CONFIG_ZEPHYR_CONNECTEDHOMEIP_MODULE AND SB_CONFIG_MATTER AND
8+
SB_CONFIG_MATTER_FACTORY_DATA_GENERATE AND NOT SB_CONFIG_PARTITION_MANAGER
9+
)
10+
ExternalZephyrProject_Add(
11+
APPLICATION matter_factory_data
12+
SOURCE_DIR ${ZEPHYR_NRF_MODULE_DIR}/applications/matter_factory_data
13+
)
14+
15+
set_config_string(matter_factory_data CONFIG_APPLICATION_NAME ${DEFAULT_IMAGE})
16+
sysbuild_add_dependencies(CONFIGURE matter_factory_data ${DEFAULT_IMAGE})
17+
endif()

0 commit comments

Comments
 (0)