Skip to content

Commit

Permalink
[NXP] Adding Zephyr examples (project-chip#34103)
Browse files Browse the repository at this point in the history
* [NXP] Adding Zephyr examples

Adding 3 examples:

*All-cluster-app
*Thermostat
*Laundry-washer-app

Signed-off-by: Axel Le Bourhis <axel.lebourhis@nxp.com>
Signed-off-by: Yassine El Aissaoui <yassine.elaissaoui@nxp.com>

* Restyled by prettier-markdown

* [NXP] Fix spelling issues on all-clusters-app Readme

* [NXP] add support for rw61x Zephyr on build_examples

With the current change, NXP Matter apps using
Zephyr can be built using the build_examples.py.

Build examples that are supported are:

* all-clusters-app
* laundry-washer
* thermostat

Build variants that are supported for now:

* build with factory data

More variants can be added later.

* Restyled by autopep8

---------

Signed-off-by: Axel Le Bourhis <axel.lebourhis@nxp.com>
Signed-off-by: Yassine El Aissaoui <yassine.elaissaoui@nxp.com>
Co-authored-by: Restyled.io <commits@restyled.io>
  • Loading branch information
yeaissa and restyled-commits authored Jul 11, 2024
1 parent e3cab4d commit 2405b12
Show file tree
Hide file tree
Showing 40 changed files with 2,037 additions and 26 deletions.
24 changes: 12 additions & 12 deletions .github/workflows/examples-nxp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,36 +60,36 @@ jobs:
run: |
scripts/run_in_build_env.sh "\
./scripts/build/build_examples.py \
--target nxp-k32w0-lighting \
--target nxp-k32w0-lighting-factory \
--target nxp-k32w0-lighting-rotating-id \
--target nxp-k32w0-contact-sensor \
--target nxp-k32w0-contact-sensor-low-power \
--target nxp-k32w0-contact-sensor-low-power-factory \
--target nxp-k32w1-lighting \
--target nxp-k32w1-contact-sensor-low-power \
--target nxp-k32w0-freertos-lighting \
--target nxp-k32w0-freertos-lighting-factory \
--target nxp-k32w0-freertos-lighting-rotating-id \
--target nxp-k32w0-freertos-contact-sensor \
--target nxp-k32w0-freertos-contact-sensor-low-power \
--target nxp-k32w0-freertos-contact-sensor-low-power-factory \
--target nxp-k32w1-freertos-lighting \
--target nxp-k32w1-freertos-contact-sensor-low-power \
build \
--copy-artifacts-to out/artifacts \
"
- name: Get lighting app size stats
run: |
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \
nxp k32w0+release light \
out/artifacts/nxp-k32w0-lighting/chip-k32w0x-light-example.elf \
out/artifacts/nxp-k32w0-freertos-lighting/chip-k32w0x-light-example.elf \
/tmp/bloat_reports/
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \
nxp k32w1+release light \
out/artifacts/nxp-k32w1-lighting/chip-k32w1-light-example.elf \
out/artifacts/nxp-k32w1-freertos-lighting/chip-k32w1-light-example.elf \
/tmp/bloat_reports/
- name: Get contact sensor size stats
run: |
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \
nxp k32w0+release contact \
out/artifacts/nxp-k32w0-contact-sensor-low-power/chip-k32w0x-contact-example.elf \
out/artifacts/nxp-k32w0-freertos-contact-sensor-low-power/chip-k32w0x-contact-example.elf \
/tmp/bloat_reports/
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \
nxp k32w1+release contact \
out/artifacts/nxp-k32w1-contact-sensor-low-power/chip-k32w1-contact-example.elf \
out/artifacts/nxp-k32w1-freertos-contact-sensor-low-power/chip-k32w1-contact-example.elf \
/tmp/bloat_reports/
- name: Uploading Size Reports
uses: ./.github/actions/upload-size-reports
Expand Down
1 change: 1 addition & 0 deletions examples/all-clusters-app/nxp/zephyr/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build/
115 changes: 115 additions & 0 deletions examples/all-clusters-app/nxp/zephyr/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
#
# Copyright (c) 2023-2024 Project CHIP Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
cmake_minimum_required(VERSION 3.13.1)

get_filename_component(CHIP_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/third_party/connectedhomeip REALPATH)
get_filename_component(GEN_DIR ${CHIP_ROOT}/zzz_generated/ REALPATH)
get_filename_component(ALL_CLUSTERS_COMMON_DIR ${CHIP_ROOT}/examples/all-clusters-app/all-clusters-common REALPATH)
get_filename_component(ALL_CLUSTERS_NXP_COMMON_DIR ${CHIP_ROOT}/examples/all-clusters-app/nxp/common REALPATH)
get_filename_component(EXAMPLE_PLATFORM_NXP_COMMON_DIR ${CHIP_ROOT}/examples/platform/nxp/common REALPATH)
get_filename_component(EXAMPLE_PLATFORM_NXP_ZEPHYR_DIR ${CHIP_ROOT}/examples/platform/nxp/zephyr REALPATH)

# Perform common operations like detecting extra overlays in the platform folder for the target board
# This must be called before find_package(Zephyr)
include(${CHIP_ROOT}/config/nxp/app/pre-zephyr.cmake)

list(APPEND ZEPHYR_EXTRA_MODULES ${CHIP_ROOT}/config/nxp/chip-module)
find_package(Zephyr HINTS $ENV{ZEPHYR_BASE})

# -Wmaybe-uninitialized has too many false positives, including on std::optional
# and chip::Optional. Make it nonfatal.
#
# See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80635
target_compile_options(app PRIVATE -Werror -Wno-error=maybe-uninitialized)

project(chip-nxp-all-clusters-app-example)

include(${CHIP_ROOT}/config/nxp/app/enable-gnu-std.cmake)
include(${CHIP_ROOT}/src/app/chip_data_model.cmake)

target_include_directories(app
PRIVATE
${ALL_CLUSTERS_NXP_COMMON_DIR}/main/include
${ALL_CLUSTERS_COMMON_DIR}/include
${GEN_DIR}/app-common
${GEN_DIR}/all-clusters-app
${EXAMPLE_PLATFORM_NXP_COMMON_DIR}/device_manager/include
${EXAMPLE_PLATFORM_NXP_COMMON_DIR}/icd/include
${EXAMPLE_PLATFORM_NXP_COMMON_DIR}/device_callbacks/include
${EXAMPLE_PLATFORM_NXP_COMMON_DIR}/factory_data/include
${EXAMPLE_PLATFORM_NXP_COMMON_DIR}/app_task/include
)

target_sources(app
PRIVATE
main/main.cpp
${ALL_CLUSTERS_NXP_COMMON_DIR}/main/AppTask.cpp
${EXAMPLE_PLATFORM_NXP_COMMON_DIR}/device_manager/source/CHIPDeviceManager.cpp
${ALL_CLUSTERS_NXP_COMMON_DIR}/main/DeviceCallbacks.cpp
${EXAMPLE_PLATFORM_NXP_COMMON_DIR}/device_callbacks/source/CommonDeviceCallbacks.cpp
${ALL_CLUSTERS_NXP_COMMON_DIR}/main/ZclCallbacks.cpp
${ALL_CLUSTERS_COMMON_DIR}/src/binding-handler.cpp
${EXAMPLE_PLATFORM_NXP_COMMON_DIR}/app_task/source/AppTaskBase.cpp
${EXAMPLE_PLATFORM_NXP_COMMON_DIR}/app_task/source/AppTaskZephyr.cpp
${EXAMPLE_PLATFORM_NXP_ZEPHYR_DIR}/factory_data/source/AppFactoryDataExample.cpp
)

target_compile_definitions(app PUBLIC
"EXTERNAL_FACTORY_DATA_PROVIDER_IMPL_HEADER=\"platform/nxp/zephyr/FactoryDataProviderImpl.h\""
)

if(CONFIG_CHIP_OTA_REQUESTOR)
target_sources(app PRIVATE
${EXAMPLE_PLATFORM_NXP_COMMON_DIR}/ota_requestor/source/OTARequestorInitiatorCommon.cpp
${EXAMPLE_PLATFORM_NXP_COMMON_DIR}/ota_requestor/source/OTARequestorInitiatorZephyr.cpp
)
target_include_directories(app PRIVATE
${EXAMPLE_PLATFORM_NXP_COMMON_DIR}/ota_requestor/include/
)
endif()

chip_configure_data_model(app
INCLUDE_SERVER
ZAP_FILE ${ALL_CLUSTERS_COMMON_DIR}/all-clusters-app.zap
)

if(CONFIG_CHIP_LIB_SHELL)
target_compile_definitions(app PRIVATE ENABLE_CHIP_SHELL)
target_include_directories(app PRIVATE
${CHIP_ROOT}/examples/shell/shell_common/include
${EXAMPLE_PLATFORM_NXP_COMMON_DIR}/matter_cli/include
)
target_sources(app PRIVATE
${EXAMPLE_PLATFORM_NXP_COMMON_DIR}/matter_cli/source/AppCLIBase.cpp
${EXAMPLE_PLATFORM_NXP_COMMON_DIR}/matter_cli/source/AppCLIZephyr.cpp
${CHIP_ROOT}/examples/shell/shell_common/cmd_misc.cpp
${CHIP_ROOT}/examples/shell/shell_common/cmd_otcli.cpp
${CHIP_ROOT}/examples/shell/shell_common/cmd_server.cpp
)
endif()

target_sources(app
PRIVATE
${ALL_CLUSTERS_COMMON_DIR}/src/smco-stub.cpp
${ALL_CLUSTERS_COMMON_DIR}/src/static-supported-modes-manager.cpp
${ALL_CLUSTERS_COMMON_DIR}/src/static-supported-temperature-levels.cpp
${ALL_CLUSTERS_COMMON_DIR}/src/bridged-actions-stub.cpp
${ALL_CLUSTERS_COMMON_DIR}/src/fan-stub.cpp
${ALL_CLUSTERS_COMMON_DIR}/src/air-quality-instance.cpp
${ALL_CLUSTERS_COMMON_DIR}/src/concentration-measurement-instances.cpp
${ALL_CLUSTERS_COMMON_DIR}/src/resource-monitoring-delegates.cpp
${EXAMPLE_PLATFORM_NXP_COMMON_DIR}/icd/source/ICDUtil.cpp
)
20 changes: 20 additions & 0 deletions examples/all-clusters-app/nxp/zephyr/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#
# Copyright (c) 2024 Project CHIP Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
mainmenu "Matter NXP All Clusters Example Application"

rsource "../../../../config/nxp/chip-module/Kconfig.features"
rsource "../../../../config/nxp/chip-module/Kconfig.defaults"
source "Kconfig.zephyr"
Loading

0 comments on commit 2405b12

Please sign in to comment.