Skip to content

Commit 6b121dd

Browse files
dinabenamarrestyled-commitsandy31415
authored
[NXP] Adding pre/post-build process support for NXP RW61x platform (#35448)
* [NXP][config][zephyr] Allow factory data to be generated outside "zephyr" folder in order to share the generation process with freertos Signed-off-by: Dina Benamar <dina.benamarelmaaroufi@nxp.com> * [NXP][config][freertos] Adding support to build applications and execute pre/post-build processes with cmake wrappers Signed-off-by: Dina Benamar <dina.benamarelmaaroufi@nxp.com> * [NXP][examples][rw61x] Adding support to build applications with cmake (this method is using wrappers which call the gn build command) * Adding configs for build & pre/post-build processes Signed-off-by: Dina Benamar <dina.benamarelmaaroufi@nxp.com> * [NXP][scripts][build_examples] Adding support to build applications with cmake using build_examples.py as the entry-point for RW61x Signed-off-by: Dina Benamar <dina.benamarelmaaroufi@nxp.com> * [NXP][scripts][build_examples] Adding differentiator to support both gn and cmake build systems Signed-off-by: Dina Benamar <dina.benamarelmaaroufi@nxp.com> * Restyled by autopep8 * Restyled by isort * [NXP][script][build_examples] Adding board variant enum Signed-off-by: Dina Benamar <dina.benamarelmaaroufi@nxp.com> * [NXP] Adding setup requirements to the list requirements.nxp.txt Signed-off-by: Dina Benamar <dina.benamarelmaaroufi@nxp.com> * Restyled by autopep8 * [NXP] Updating nxp_matter_support submodule Signed-off-by: Dina Benamar <dina.benamarelmaaroufi@nxp.com> * Restyled by autopep8 * Update scripts/build/builders/nxp.py Co-authored-by: Andrei Litvin <andy314@gmail.com> * Update scripts/build/builders/nxp.py Co-authored-by: Andrei Litvin <andy314@gmail.com> * Update scripts/build/builders/nxp.py Co-authored-by: Andrei Litvin <andy314@gmail.com> --------- Signed-off-by: Dina Benamar <dina.benamarelmaaroufi@nxp.com> Co-authored-by: Restyled.io <commits@restyled.io> Co-authored-by: Andrei Litvin <andy314@gmail.com>
1 parent afb1a33 commit 6b121dd

File tree

11 files changed

+391
-51
lines changed

11 files changed

+391
-51
lines changed

.github/workflows/examples-nxp.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ jobs:
243243
--target nxp-rw61x-freertos-all-clusters-wifi \
244244
--target nxp-rw61x-freertos-all-clusters-thread \
245245
--target nxp-rw61x-freertos-all-clusters-thread-wifi \
246+
--target nxp-rw61x-freertos-all-clusters-wifi-ota-cmake \
246247
build \
247248
--copy-artifacts-to out/artifacts \
248249
"

config/nxp/chip-cmake-freertos/CMakeLists.txt

+67-10
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,24 @@ if(NOT CHIP_ROOT)
2020
get_filename_component(CHIP_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../../.. REALPATH)
2121
endif()
2222

23-
get_filename_component(GN_ROOT_TARGET ${CHIP_ROOT}/config/nxp/chip-gn-freertos REALPATH)
23+
if (NOT GN_ROOT_TARGET)
24+
get_filename_component(GN_ROOT_TARGET ${CHIP_ROOT}/config/nxp/chip-gn-freertos REALPATH)
25+
endif()
26+
27+
# Include common NXP helpers for build & pre/post-build process
28+
include(${CHIP_ROOT}/third_party/nxp/nxp_matter_support/cmake/build_helpers.cmake)
2429

2530
include(${CHIP_ROOT}/config/nxp/cmake/common.cmake)
2631
include(${CHIP_ROOT}/src/app/chip_data_model.cmake)
2732

33+
if(NOT CONFIG_CHIP_BUILD_APP_WITH_GN)
2834
# Prepare compiler flags
2935
matter_add_cflags(${CMAKE_C_FLAGS})
3036
matter_add_cxxflags(${CMAKE_CXX_FLAGS})
3137

3238
matter_get_compiler_flags_from_targets("${CONFIG_CHIP_EXTERNAL_TARGETS}")
39+
endif()
40+
3341

3442
# ==============================================================================
3543
# Generate configuration for CHIP GN build system
@@ -39,31 +47,80 @@ matter_add_gn_arg_string("nxp_platform" ${CONFIG_CHIP_NXP_PLATFORM})
3947
matter_add_gn_arg("chip_with_factory_data" ${CONFIG_CHIP_FACTORY_DATA})
4048
matter_add_gn_arg("chip_enable_secure_dac_private_key_storage" ${CONFIG_CHIP_SECURE_DAC_PRIVATE_KEY_STORAGE})
4149
matter_add_gn_arg("chip_enable_secure_whole_factory_data" ${CONFIG_CHIP_ENABLE_SECURE_WHOLE_FACTORY_DATA})
50+
matter_add_gn_arg_bool("chip_enable_matter_cli" CONFIG_CHIP_LIB_SHELL)
51+
matter_add_gn_arg_bool("chip_enable_pairing_autostart" CONFIG_CHIP_ENABLE_PAIRING_AUTOSTART)
4252

4353
if (CONFIG_USE_CHIP_DATA_MODEL_INTERFACE)
4454
set(DATA_MODEL_INTERFACE "enabled")
4555
else()
4656
set(DATA_MODEL_INTERFACE "disabled")
4757
endif()
4858

49-
matter_common_gn_args(
50-
DEBUG CONFIG_DEBUG
51-
LIB_SHELL CONFIG_CHIP_LIB_SHELL
52-
LIB_TESTS CONFIG_CHIP_BUILD_TESTS
53-
PROJECT_CONFIG ${CONFIG_CHIP_PROJECT_CONFIG}
54-
PROJECT_CONFIG_INC_DIR ${CONFIG_CHIP_PROJECT_CONFIG_INCLUDE_DIRS}
55-
DEVICE_INFO_EXAMPLE_PROVIDER CONFIG_CHIP_EXAMPLE_DEVICE_INFO_PROVIDER
56-
DATA_MODEL_INTERFACE ${DATA_MODEL_INTERFACE}
57-
)
59+
if(CONFIG_BOOTLOADER_MCUBOOT)
60+
matter_add_gn_arg_bool("no_mcuboot" false)
61+
endif(CONFIG_BOOTLOADER_MCUBOOT)
62+
63+
# Enable map file generation by default
64+
matter_add_gn_arg_bool("chip_generate_link_map_file" true)
65+
66+
if(CONFIG_CHIP_BUILD_APP_WITH_GN)
67+
include(${CHIP_ROOT}/third_party/nxp/nxp_matter_support/cmake/nxp_sdk_gn_build.cmake)
68+
else()
69+
matter_common_gn_args(
70+
DEBUG CONFIG_DEBUG
71+
LIB_SHELL CONFIG_CHIP_LIB_SHELL
72+
LIB_TESTS CONFIG_CHIP_BUILD_TESTS
73+
PROJECT_CONFIG ${CONFIG_CHIP_PROJECT_CONFIG}
74+
PROJECT_CONFIG_INC_DIR ${CONFIG_CHIP_PROJECT_CONFIG_INCLUDE_DIRS}
75+
DEVICE_INFO_EXAMPLE_PROVIDER CONFIG_CHIP_EXAMPLE_DEVICE_INFO_PROVIDER
76+
DATA_MODEL_INTERFACE ${DATA_MODEL_INTERFACE}
77+
)
78+
endif()
5879

5980
matter_generate_args_tmp_file()
6081

6182
# ==============================================================================
6283
# Build chip library
6384
# ==============================================================================
85+
if(NOT CONFIG_CHIP_BUILD_APP_WITH_GN)
6486
matter_build(chip
6587
LIB_SHELL ${CONFIG_CHIP_LIB_SHELL}
6688
LIB_TESTS ${CONFIG_CHIP_BUILD_TESTS}
6789
DEVICE_INFO_EXAMPLE_PROVIDER ${CONFIG_CHIP_EXAMPLE_DEVICE_INFO_PROVIDER}
6890
GN_DEPENDENCIES ${CONFIG_GN_DEPENDENCIES}
6991
)
92+
endif()
93+
94+
95+
#**************************************************************************************
96+
# Pre-build instructions
97+
#**************************************************************************************
98+
nxp_pre_build_process()
99+
100+
#**************************************************************************************
101+
# Post-build instructions
102+
#**************************************************************************************
103+
if(CONFIG_CHIP_OTA_REQUESTOR)
104+
105+
if (CONFIG_BOOTLOADER_MCUBOOT)
106+
# Build mcuboot application
107+
nxp_generate_mcuboot()
108+
109+
# Sign application binaries with mcuboot imgtool
110+
nxp_sign_app_imgtool("${CONFIG_REMOVE_SECTIONS_FROM_BIN}")
111+
112+
endif()
113+
114+
# Generate .ota file
115+
nxp_generate_ota_file()
116+
117+
endif(CONFIG_CHIP_OTA_REQUESTOR)
118+
119+
if (CONFIG_CHIP_FACTORY_DATA_BUILD)
120+
121+
set(OUTPUT_FILE_PATH ${gn_build}/factory_data)
122+
123+
# Generate factory data binaries
124+
nxp_generate_factory_data()
125+
126+
endif(CONFIG_CHIP_FACTORY_DATA_BUILD)

config/nxp/chip-module/generate_factory_data.cmake

+3-1
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,9 @@ function(nxp_generate_factory_data)
218218
# Localize all scripts needed to generate factory data partition
219219
set(GENERATE_CERTS_SCRIPT_PATH ${CHIP_ROOT}/scripts/tools/nxp/generate_certs.py)
220220
set(GENERATE_FDATA_SCRIPT_PATH ${CHIP_ROOT}/scripts/tools/nxp/factory_data_generator/generate.py)
221-
set(OUTPUT_FILE_PATH ${APPLICATION_BINARY_DIR}/zephyr)
221+
if (NOT OUTPUT_FILE_PATH)
222+
set(OUTPUT_FILE_PATH ${APPLICATION_BINARY_DIR}/zephyr)
223+
endif()
222224

223225
if(CONFIG_CHIP_FACTORY_DATA_CERT_SOURCE_GENERATED)
224226
# Generate certificates
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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+
cmake_minimum_required(VERSION 3.13.1)
18+
19+
project(chip-rw61x-all-cluster-example)
20+
21+
if (NOT CHIP_ROOT)
22+
get_filename_component(CHIP_ROOT ${CMAKE_CURRENT_LIST_DIR}/../../../../.. REALPATH)
23+
endif()
24+
25+
# Define the GN root target for the application
26+
get_filename_component(GN_ROOT_TARGET ${CMAKE_CURRENT_LIST_DIR} REALPATH)
27+
28+
# Include platform specific configs / variables
29+
include(${CHIP_ROOT}/examples/platform/nxp/rt/rw61x/platform_config.cmake)
30+
31+
add_subdirectory(${CHIP_ROOT}/config/nxp/chip-cmake-freertos ./chip)
32+
33+
#**************************************************************************************
34+
# Build example application
35+
#**************************************************************************************
36+
if(CONFIG_CHIP_BUILD_APP_WITH_GN)
37+
nxp_build_app_with_gn()
38+
endif()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
2+
#
3+
# Copyright (c) 2024 Project CHIP Authors
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
18+
#
19+
# @file
20+
# CMake file that defines cmake variables specific to this platform
21+
#
22+
23+
# Board configs
24+
set(CONFIG_CORE_FOLDER "")
25+
26+
if (CONFIG_BOARD_VARIANT STREQUAL "frdm")
27+
set(CONFIG_BOARD_NAME "frdmrw612")
28+
else()
29+
set(CONFIG_BOARD_NAME "rdrw612bga")
30+
endif()
31+
32+
# MCUBoot OTA configs
33+
set(CONFIG_MCUBOOT_BUILD_TYPE "flash_release")
34+
set(CONFIG_CHIP_MCUBOOT_SLOT_SIZE 0x440000)
35+
set(CONFIG_CHIP_MCUBOOT_MAX_SECTORS 1088)
36+
set(CONFIG_CHIP_MCUBOOT_HEADER_SIZE 0x1000)
37+
38+
# CHIP configs
39+
set(CONFIG_CHIP_DEVICE_VENDOR_ID 4151)
40+
set(CONFIG_CHIP_DEVICE_PRODUCT_ID 41510)
41+
42+
set(CONFIG_CHIP_DEVICE_VENDOR_NAME "NXP Semiconductors")
43+
if (NOT CONFIG_CHIP_DEVICE_PRODUCT_NAME)
44+
set(CONFIG_CHIP_DEVICE_PRODUCT_NAME "Thermostat")
45+
endif()
46+
if (NOT CONFIG_CHIP_DEVICE_TYPE)
47+
set(CONFIG_CHIP_DEVICE_TYPE 769)
48+
endif()
49+
set(CONFIG_CHIP_DEVICE_SPAKE2_IT 10000)
50+
set(CONFIG_CHIP_DEVICE_SPAKE2_SALT "UXKLzwHdN3DZZLBaL2iVGhQi/OoQwIwJRQV4rpEalbA=")
51+
if (NOT CONFIG_CHIP_DEVICE_DISCRIMINATOR)
52+
set(CONFIG_CHIP_DEVICE_DISCRIMINATOR 2560)
53+
endif()
54+
if (NOT CONFIG_CHIP_DEVICE_SPAKE2_PASSCODE)
55+
set(CONFIG_CHIP_DEVICE_SPAKE2_PASSCODE 14014)
56+
endif()
57+
set(CONFIG_CHIP_DEVICE_HARDWARE_VERSION 1)
58+
set(CONFIG_CHIP_DEVICE_HARDWARE_VERSION_STRING "1.0")
59+
set(CONFIG_CHIP_DEVICE_SERIAL_NUMBER "12345678")
60+
set(CONFIG_CHIP_DEVICE_MANUFACTURING_DATE "2024-01-01")
61+
set(CONFIG_CHIP_DEVICE_ROTATING_DEVICE_UID "00112233445566778899aabbccddeeff")
62+
set(CONFIG_CHIP_DEVICE_PRODUCT_FINISH "Matte")
63+
set(CONFIG_CHIP_DEVICE_PRODUCT_COLOR "Green")
64+
set(CONFIG_CHIP_DEVICE_PRODUCT_URL "https://www.nxp.com/products/wireless/wi-fi-plus-bluetooth-plus-802-15-4/wireless-mcu-with-integrated-tri-radiobr1x1-wi-fi-6-plus-bluetooth-low-energy-5-3-802-15-4:RW612")
65+
set(CONFIG_CHIP_DEVICE_PRODUCT_LABEL "RW612")
66+
set(CONFIG_CHIP_DEVICE_PART_NUMBER "RW612")
67+
set(CONFIG_CHIP_ENCRYPTED_FACTORY_DATA_AES128_KEY "2B7E151628AED2A6ABF7158809CF4F3C")
68+
set(CONFIG_CHIP_FACTORY_DATA_CERT_SOURCE_GENERATED true)
69+
set(CONFIG_CHIP_FACTORY_DATA_GENERATE_SPAKE2_VERIFIER true)
70+
set(CONFIG_CHIP_ENCRYPTED_FACTORY_DATA true)
71+
72+
# build configs
73+
set(CONFIG_CHIP_NVM_COMPONENT "nvs")
74+
set(CONFIG_CHIP_RT_PLATFORM "rw61x")
75+
set(CONFIG_CHIP_NXP_PLATFORM "rt/${CONFIG_CHIP_RT_PLATFORM}")
76+
set(CONFIG_CHIP_FACTORY_DATA 1)
77+
set(CONFIG_CHIP_SECURE_DAC_PRIVATE_KEY_STORAGE false)
78+
set(CONFIG_CHIP_ENABLE_SECURE_WHOLE_FACTORY_DATA false)
79+
set(CONFIG_CHIP_BUILD_APP_WITH_GN true)
80+
set(CONFIG_LOG true)
81+
set(CONFIG_MATTER_LOG_LEVEL 4) # detail logs
82+
83+
# BLE is enabled by default
84+
if (NOT DEFINED CONFIG_BT)
85+
set(CONFIG_BT true)
86+
endif()
87+
88+
if (NOT DEFINED CONFIG_CHIP_IPV4)
89+
set(CONFIG_CHIP_IPV4 true)
90+
endif()
91+
92+
if (NOT DEFINED CONFIG_CHIP_DEVICE_SOFTWARE_VERSION)
93+
set(CONFIG_CHIP_DEVICE_SOFTWARE_VERSION 1)
94+
endif()
95+
96+
if (NOT DEFINED CONFIG_CHIP_DEVICE_SOFTWARE_VERSION_STRING)
97+
set(CONFIG_CHIP_DEVICE_SOFTWARE_VERSION_STRING "1.0")
98+
endif()
99+
100+
if(NOT DEFINED CONFIG_CHIP_ENABLE_PAIRING_AUTOSTART)
101+
set(CONFIG_CHIP_ENABLE_PAIRING_AUTOSTART true)
102+
endif()
103+
104+
105+
# define sections to remove from the binary when converting the elf to bin with objcopy
106+
if (CONFIG_CHIP_OTA_REQUESTOR)
107+
set(CONFIG_REMOVE_SECTIONS_FROM_BIN -R .flash_config -R .NVM)
108+
else()
109+
set(CONFIG_REMOVE_SECTIONS_FROM_BIN -R .NVM)
110+
endif()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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+
cmake_minimum_required(VERSION 3.13.1)
18+
19+
project(chip-rw61x-thermostat-example)
20+
21+
if (NOT CHIP_ROOT)
22+
get_filename_component(CHIP_ROOT ${CMAKE_CURRENT_LIST_DIR}/../../../../.. REALPATH)
23+
endif()
24+
25+
# Define the GN root target for the application
26+
get_filename_component(GN_ROOT_TARGET ${CMAKE_CURRENT_LIST_DIR} REALPATH)
27+
28+
# Include platform specific configs / variables
29+
include(${CHIP_ROOT}/examples/platform/nxp/rt/rw61x/platform_config.cmake)
30+
31+
add_subdirectory(${CHIP_ROOT}/config/nxp/chip-cmake-freertos ./chip)
32+
33+
#**************************************************************************************
34+
# Build example application
35+
#**************************************************************************************
36+
if(CONFIG_CHIP_BUILD_APP_WITH_GN)
37+
nxp_build_app_with_gn()
38+
endif()

scripts/build/build/targets.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
from builders.mw320 import MW320App, MW320Builder
2929
from builders.nrf import NrfApp, NrfBoard, NrfConnectBuilder
3030
from builders.nuttx import NuttXApp, NuttXBoard, NuttXBuilder
31-
from builders.nxp import NxpApp, NxpBoard, NxpBuilder, NxpOsUsed
31+
from builders.nxp import NxpApp, NxpBoard, NxpBoardVariant, NxpBuilder, NxpBuildSystem, NxpOsUsed
3232
from builders.openiotsdk import OpenIotSdkApp, OpenIotSdkBuilder, OpenIotSdkCryptoBackend
3333
from builders.qpg import QpgApp, QpgBoard, QpgBuilder
3434
from builders.stm32 import stm32App, stm32Board, stm32Builder
@@ -550,6 +550,9 @@ def BuildNxpTarget():
550550
target.AppendModifier(name="matter-shell", enable_shell=True).ExceptIfRe('k32w0|k32w1')
551551
target.AppendModifier('data-model-disabled', data_model_interface="disabled").ExceptIfRe('-data-model-enabled')
552552
target.AppendModifier('data-model-enabled', data_model_interface="enabled").ExceptIfRe('-data-model-disabled')
553+
target.AppendModifier(name="factory-build", enable_factory_data_build=True).OnlyIfRe('rw61x')
554+
target.AppendModifier(name="frdm", board_variant=NxpBoardVariant.FRDM).OnlyIfRe('rw61x')
555+
target.AppendModifier(name="cmake", build_system=NxpBuildSystem.CMAKE).OnlyIfRe('rw61x')
553556

554557
return target
555558

0 commit comments

Comments
 (0)