Skip to content

Commit 62139bf

Browse files
authored
[NXP][config] Adding CMake support to build CHIP libs for NXP FreeRTOS platforms (project-chip#34901)
* [NXP][config][freertos] Adding support to build Matter lib and port files with cmake on NXP freertos platforms Signed-off-by: Dina Benamar <dina.benamarelmaaroufi@nxp.com> * [NXP][config][common] Create common .cmake file to include common configs between freertos & zephyr Signed-off-by: Dina Benamar <dina.benamarelmaaroufi@nxp.com> * [NXP][config][zephyr] Include common.cmake which adds common options to zephyr & freertos Signed-off-by: Dina Benamar <dina.benamarelmaaroufi@nxp.com> * [NXP][config][freertos] Updates to align with new flag introduction "chip_enable_secure_whole_factory_data" Signed-off-by: Dina Benamar <dina.benamarelmaaroufi@nxp.com> * [NXP][config][freertos] Set build_matter_standalone_lib to true to support building CHIP libs with CMake in matter-over-thread configuration Signed-off-by: Dina Benamar <dina.benamarelmaaroufi@nxp.com> --------- Signed-off-by: Dina Benamar <dina.benamarelmaaroufi@nxp.com>
1 parent 13c45d5 commit 62139bf

File tree

6 files changed

+234
-41
lines changed

6 files changed

+234
-41
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#
2+
# Copyright (c) 2024 Project CHIP Authors
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
17+
include(ExternalProject)
18+
19+
if(NOT CHIP_ROOT)
20+
get_filename_component(CHIP_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../../.. REALPATH)
21+
endif()
22+
23+
get_filename_component(GN_ROOT_TARGET ${CHIP_ROOT}/config/nxp/chip-gn-freertos REALPATH)
24+
25+
include(${CHIP_ROOT}/config/nxp/cmake/common.cmake)
26+
include(${CHIP_ROOT}/src/app/chip_data_model.cmake)
27+
28+
# Prepare compiler flags
29+
matter_add_cflags(${CMAKE_C_FLAGS})
30+
matter_add_cxxflags(${CMAKE_CXX_FLAGS})
31+
32+
matter_get_compiler_flags_from_targets("${CONFIG_CHIP_EXTERNAL_TARGETS}")
33+
34+
# ==============================================================================
35+
# Generate configuration for CHIP GN build system
36+
# ==============================================================================
37+
matter_add_gn_arg_string("nxp_nvm_component" ${CONFIG_CHIP_NVM_COMPONENT})
38+
matter_add_gn_arg_string("nxp_platform" ${CONFIG_CHIP_NXP_PLATFORM})
39+
matter_add_gn_arg("chip_with_factory_data" ${CONFIG_CHIP_FACTORY_DATA})
40+
matter_add_gn_arg("chip_enable_secure_dac_private_key_storage" ${CONFIG_CHIP_SECURE_DAC_PRIVATE_KEY_STORAGE})
41+
matter_add_gn_arg("chip_enable_secure_whole_factory_data" ${CONFIG_CHIP_ENABLE_SECURE_WHOLE_FACTORY_DATA})
42+
43+
matter_common_gn_args(
44+
DEBUG CONFIG_DEBUG
45+
LIB_SHELL CONFIG_CHIP_LIB_SHELL
46+
LIB_TESTS CONFIG_CHIP_BUILD_TESTS
47+
PROJECT_CONFIG ${CONFIG_CHIP_PROJECT_CONFIG}
48+
PROJECT_CONFIG_INC_DIR ${CONFIG_CHIP_PROJECT_CONFIG_INCLUDE_DIRS}
49+
DEVICE_INFO_EXAMPLE_PROVIDER CONFIG_CHIP_EXAMPLE_DEVICE_INFO_PROVIDER
50+
)
51+
52+
matter_generate_args_tmp_file()
53+
54+
# ==============================================================================
55+
# Build chip library
56+
# ==============================================================================
57+
matter_build(chip
58+
LIB_SHELL ${CONFIG_CHIP_LIB_SHELL}
59+
LIB_TESTS ${CONFIG_CHIP_BUILD_TESTS}
60+
DEVICE_INFO_EXAMPLE_PROVIDER ${CONFIG_CHIP_EXAMPLE_DEVICE_INFO_PROVIDER}
61+
GN_DEPENDENCIES ${CONFIG_GN_DEPENDENCIES}
62+
)

config/nxp/chip-gn-freertos/.gn

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Copyright (c) 2024 Project CHIP Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
import("//build_overrides/build.gni")
16+
import("//build_overrides/chip.gni")
17+
18+
# The location of the build configuration file.
19+
buildconfig = "//build/config/BUILDCONFIG.gn"
20+
21+
# CHIP uses angle bracket includes.
22+
check_system_includes = true
23+
24+
default_args = {
25+
target_cpu = "arm"
26+
target_os = "freertos"
27+
28+
import("${chip_root}/config/nxp/chip-gn-freertos/args.gni")
29+
}

config/nxp/chip-gn-freertos/BUILD.gn

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Copyright (c) 2024 Project CHIP Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
import("//build_overrides/build.gni")
16+
import("//build_overrides/chip.gni")
17+
18+
import("${chip_root}/build/chip/tests.gni")
19+
20+
assert(current_os == "freertos")
21+
22+
declare_args() {
23+
chip_build_example_providers = false
24+
chip_enable_ethernet = false
25+
chip_malloc_sys_heap = false
26+
}
27+
28+
group("nxp_freertos") {
29+
deps = [ "${chip_root}/src/lib" ]
30+
31+
if (chip_build_tests) {
32+
deps += [ "${chip_root}/src:tests" ]
33+
}
34+
35+
if (chip_build_example_providers) {
36+
deps += [ "${chip_root}/examples/providers:device_info_provider" ]
37+
}
38+
}
39+
40+
group("default") {
41+
deps = [ ":nxp_freertos" ]
42+
}

config/nxp/chip-gn-freertos/args.gni

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Copyright (c) 2024 Project CHIP Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
import("//build_overrides/chip.gni")
16+
import("//build_overrides/nxp_sdk.gni")
17+
18+
nxp_external_sdk = true
19+
nxp_build_matter_standalone_lib = true
20+
chip_device_platform = "nxp"
21+
lwip_platform = "nxp"
22+
23+
# project config files
24+
chip_device_project_config_include = ""
25+
chip_project_config_include = ""
26+
chip_inet_project_config_include = ""
27+
chip_system_project_config_include = ""
28+
chip_ble_project_config_include = ""
29+
30+
# mbedtls is built as part of the NXP SDK build process
31+
mbedtls_target = "${nxp_sdk_build_root}:nxp_mbedtls"

config/nxp/chip-module/CMakeLists.txt

+1-41
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,8 @@ if (NOT CHIP_ROOT)
4242
get_filename_component(CHIP_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../../.. REALPATH)
4343
endif()
4444
get_filename_component(GN_ROOT_TARGET ${CHIP_ROOT}/config/nxp/chip-gn REALPATH)
45-
get_filename_component(COMMON_CMAKE_SOURCE_DIR ${CHIP_ROOT}/config/common/cmake REALPATH)
4645

47-
# Get common Cmake sources
48-
49-
include(${COMMON_CMAKE_SOURCE_DIR}/chip_gn_args.cmake)
50-
include(${COMMON_CMAKE_SOURCE_DIR}/chip_gn.cmake)
46+
include(${CHIP_ROOT}/config/nxp/cmake/common.cmake)
5147

5248
# Prepare compiler flags
5349
if (CHIP_CFLAGS)
@@ -109,30 +105,6 @@ matter_common_gn_args(
109105
matter_add_gn_arg_string("zephyr_ar" ${CMAKE_AR})
110106
matter_add_gn_arg_string("zephyr_cc" ${CMAKE_C_COMPILER})
111107
matter_add_gn_arg_string("zephyr_cxx" ${CMAKE_CXX_COMPILER})
112-
matter_add_gn_arg_bool ("chip_logging" CONFIG_LOG)
113-
matter_add_gn_arg_bool ("chip_enable_openthread" CONFIG_NET_L2_OPENTHREAD)
114-
matter_add_gn_arg_bool ("chip_openthread_ftd" CONFIG_OPENTHREAD_FTD)
115-
matter_add_gn_arg_bool ("chip_config_network_layer_ble" CONFIG_BT)
116-
matter_add_gn_arg_bool ("chip_inet_config_enable_ipv4" CONFIG_CHIP_IPV4)
117-
matter_add_gn_arg_bool ("chip_persist_subscriptions" CONFIG_CHIP_PERSISTENT_SUBSCRIPTIONS)
118-
matter_add_gn_arg_bool ("chip_monolithic_tests" CONFIG_CHIP_BUILD_TESTS)
119-
matter_add_gn_arg_bool ("chip_inet_config_enable_tcp_endpoint" CONFIG_CHIP_BUILD_TESTS)
120-
matter_add_gn_arg_bool ("chip_error_logging" CONFIG_MATTER_LOG_LEVEL GREATER_EQUAL 1)
121-
matter_add_gn_arg_bool ("chip_progress_logging" CONFIG_MATTER_LOG_LEVEL GREATER_EQUAL 3)
122-
matter_add_gn_arg_bool ("chip_detail_logging" CONFIG_MATTER_LOG_LEVEL GREATER_EQUAL 4)
123-
matter_add_gn_arg_bool ("chip_automation_logging" FALSE)
124-
matter_add_gn_arg_bool ("chip_malloc_sys_heap" CONFIG_CHIP_MALLOC_SYS_HEAP)
125-
matter_add_gn_arg_bool ("chip_enable_wifi" CONFIG_CHIP_WIFI)
126-
matter_add_gn_arg_bool ("chip_system_config_provide_statistics" CONFIG_CHIP_STATISTICS)
127-
matter_add_gn_arg_bool ("chip_enable_icd_server" CONFIG_CHIP_ENABLE_ICD_SUPPORT)
128-
matter_add_gn_arg_bool ("enable_eventlist_attribute" TRUE)
129-
matter_add_gn_arg_bool ("chip_enable_ota_requestor" CONFIG_CHIP_OTA_REQUESTOR)
130-
131-
if(CONFIG_DEBUG)
132-
matter_add_gn_arg_bool("optimize_debug" true)
133-
matter_add_gn_arg_string("optimize_debug_level" "0")
134-
matter_add_gn_arg_string("symbol_level" "2")
135-
endif()
136108

137109
if (CONFIG_CHIP_FACTORY_DATA)
138110
matter_add_gn_arg_bool("chip_use_transitional_commissionable_data_provider" FALSE)
@@ -141,11 +113,6 @@ elseif (CONFIG_CHIP_FACTORY_DATA_CUSTOM_BACKEND)
141113
matter_add_gn_arg_bool("chip_use_transitional_commissionable_data_provider" FALSE)
142114
endif()
143115

144-
if (CONFIG_CHIP_ROTATING_DEVICE_ID)
145-
matter_add_gn_arg_bool("chip_enable_rotating_device_id" TRUE)
146-
matter_add_gn_arg_bool("chip_enable_additional_data_advertising" TRUE)
147-
endif()
148-
149116
if (CONFIG_NET_L2_OPENTHREAD)
150117
matter_add_gn_arg_string("chip_mdns" "platform")
151118
elseif(CONFIG_WIFI_NXP)
@@ -154,20 +121,13 @@ else()
154121
matter_add_gn_arg_string("chip_mdns" "none")
155122
endif()
156123

157-
if (CONFIG_CHIP_CRYPTO_PSA)
158-
matter_add_gn_arg_string("chip_crypto" "psa")
159-
endif()
160124

161125
# if (BOARD STREQUAL "native_posix")
162126
# matter_add_gn_arg_string("target_cpu" "x86")
163127
# elseif (BOARD STREQUAL "native_posix_64")
164128
# matter_add_gn_arg_string("target_cpu" "x64")
165129
# endif()
166130

167-
if (NOT CONFIG_CHIP_DEBUG_SYMBOLS)
168-
matter_add_gn_arg_string("symbol_level" "0")
169-
endif()
170-
171131
# if (CHIP_COMPILER_LAUNCHER)
172132
# matter_add_gn_arg_string("pw_command_launcher" ${CHIP_COMPILER_LAUNCHER})
173133
# endif()

config/nxp/cmake/common.cmake

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#
2+
# Copyright (c) 2024 Project CHIP Authors
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
17+
#
18+
# @file
19+
# CMake for CHIP library configuration common to NXP platforms
20+
#
21+
22+
include(${CHIP_ROOT}/config/nxp/chip-module/generate_factory_data.cmake)
23+
24+
get_filename_component(COMMON_CMAKE_SOURCE_DIR ${CHIP_ROOT}/config/common/cmake REALPATH)
25+
26+
# Get common Cmake sources
27+
include(${COMMON_CMAKE_SOURCE_DIR}/chip_gn_args.cmake)
28+
include(${COMMON_CMAKE_SOURCE_DIR}/chip_gn.cmake)
29+
30+
# ==============================================================================
31+
# Generate configuration for CHIP GN build system
32+
# ==============================================================================
33+
matter_add_gn_arg_bool ("chip_logging" CONFIG_LOG)
34+
matter_add_gn_arg_bool ("chip_enable_openthread" CONFIG_NET_L2_OPENTHREAD)
35+
matter_add_gn_arg_bool ("chip_openthread_ftd" CONFIG_OPENTHREAD_FTD)
36+
matter_add_gn_arg_bool ("chip_config_network_layer_ble" CONFIG_BT)
37+
matter_add_gn_arg_bool ("chip_inet_config_enable_ipv4" CONFIG_CHIP_IPV4)
38+
matter_add_gn_arg_bool ("chip_persist_subscriptions" CONFIG_CHIP_PERSISTENT_SUBSCRIPTIONS)
39+
matter_add_gn_arg_bool ("chip_monolithic_tests" CONFIG_CHIP_BUILD_TESTS)
40+
matter_add_gn_arg_bool ("chip_inet_config_enable_tcp_endpoint" CONFIG_CHIP_BUILD_TESTS)
41+
matter_add_gn_arg_bool ("chip_error_logging" CONFIG_MATTER_LOG_LEVEL GREATER_EQUAL 1)
42+
matter_add_gn_arg_bool ("chip_progress_logging" CONFIG_MATTER_LOG_LEVEL GREATER_EQUAL 3)
43+
matter_add_gn_arg_bool ("chip_detail_logging" CONFIG_MATTER_LOG_LEVEL GREATER_EQUAL 4)
44+
matter_add_gn_arg_bool ("chip_automation_logging" FALSE)
45+
matter_add_gn_arg_bool ("chip_malloc_sys_heap" CONFIG_CHIP_MALLOC_SYS_HEAP)
46+
matter_add_gn_arg_bool ("chip_enable_wifi" CONFIG_CHIP_WIFI)
47+
matter_add_gn_arg_bool ("chip_system_config_provide_statistics" CONFIG_CHIP_STATISTICS)
48+
matter_add_gn_arg_bool ("chip_enable_icd_server" CONFIG_CHIP_ENABLE_ICD_SUPPORT)
49+
matter_add_gn_arg_bool ("enable_eventlist_attribute" TRUE)
50+
matter_add_gn_arg_bool ("chip_enable_ota_requestor" CONFIG_CHIP_OTA_REQUESTOR)
51+
52+
if(CONFIG_DEBUG)
53+
matter_add_gn_arg_bool("optimize_debug" true)
54+
matter_add_gn_arg_string("optimize_debug_level" "0")
55+
matter_add_gn_arg_string("symbol_level" "2")
56+
endif()
57+
58+
if (CONFIG_CHIP_ROTATING_DEVICE_ID)
59+
matter_add_gn_arg_bool("chip_enable_rotating_device_id" TRUE)
60+
matter_add_gn_arg_bool("chip_enable_additional_data_advertising" TRUE)
61+
endif()
62+
63+
if (CONFIG_CHIP_CRYPTO_PSA)
64+
matter_add_gn_arg_string("chip_crypto" "psa")
65+
endif()
66+
67+
if (NOT CONFIG_CHIP_DEBUG_SYMBOLS)
68+
matter_add_gn_arg_string("symbol_level" "0")
69+
endif()

0 commit comments

Comments
 (0)