Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port to NCS 2.4.0 #2

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
build/
*~
35 changes: 30 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,37 @@

cmake_minimum_required(VERSION 3.20.0)

get_filename_component(MATTER_MODULE_ROOT $ENV{ZEPHYR_BASE}/../modules/lib/matter REALPATH)

# Set Kconfig root files that will be processed as a first Kconfig for used child images.
set(mcuboot_KCONFIG_ROOT ${MATTER_MODULE_ROOT}/config/nrfconnect/chip-module/Kconfig.mcuboot.root)
set(multiprotocol_rpmsg_KCONFIG_ROOT ${MATTER_MODULE_ROOT}/config/nrfconnect/chip-module/Kconfig.multiprotocol_rpmsg.root)
set(hci_rpmsg_KCONFIG_ROOT ${MATTER_MODULE_ROOT}/config/nrfconnect/chip-module/Kconfig.hci_rpmsg.root)

# For prj.conf the CONF_FILE is empty. In other case extract the exact file name from the path string.
if(CONF_FILE)
get_filename_component(CONFIG_FILE_NAME ${CONF_FILE} NAME)
endif()

if(NOT CONFIG_FILE_NAME STREQUAL "prj_no_dfu.conf")
set(PM_STATIC_YML_FILE ${CMAKE_CURRENT_SOURCE_DIR}/configuration/${BOARD}/pm_static_dfu.yml)
endif()

find_package(Zephyr HINTS $ENV{ZEPHYR_BASE})

project(matter-bridge)

set(COMMON_ROOT ${ZEPHYR_NRF_MODULE_DIR}/samples/matter/common)
set(NLIO_ROOT ${ZEPHYR_CONNECTEDHOMEIP_MODULE_DIR}/third_party/nlio/repo)
include(${ZEPHYR_CONNECTEDHOMEIP_MODULE_DIR}/config/nrfconnect/app/enable-gnu-std.cmake)
include(${ZEPHYR_CONNECTEDHOMEIP_MODULE_DIR}/src/app/chip_data_model.cmake)
set(NLIO_ROOT ${MATTER_MODULE_ROOT}/third_party/nlio/repo)
include(${MATTER_MODULE_ROOT}/config/nrfconnect/app/enable-gnu-std.cmake)
include(${MATTER_MODULE_ROOT}/src/app/chip_data_model.cmake)

# NORDIC SDK APP START
target_include_directories(app PRIVATE
src
${COMMON_ROOT}/src
${NLIO_ROOT}/include
${ZEPHYR_CONNECTEDHOMEIP_MODULE_DIR}/zzz_generated/app-common
${MATTER_MODULE_ROOT}/zzz_generated/app-common
)

target_sources(app PRIVATE
Expand All @@ -31,11 +47,20 @@ target_sources(app PRIVATE
src/zap-generated/IMClusterCommandHandler.cpp
src/zap-generated/callback-stub.cpp
${COMMON_ROOT}/src/led_widget.cpp
${COMMON_ROOT}/src/thread_util.cpp
)

if(CONFIG_CHIP_OTA_REQUESTOR OR CONFIG_MCUMGR_TRANSPORT_BT)
target_sources(app PRIVATE ${COMMON_ROOT}/src/ota_util.cpp)
endif()

if(CONFIG_MCUMGR_TRANSPORT_BT)
target_sources(app PRIVATE ${COMMON_ROOT}/src/dfu_over_smp.cpp)
endif()

chip_configure_data_model(app
INCLUDE_SERVER
BYPASS_IDL
GEN_DIR src/zap-generated
ZAP_FILE ${CMAKE_CURRENT_SOURCE_DIR}/src/bridge.zap
)
# NORDIC SDK APP END
18 changes: 15 additions & 3 deletions Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,25 @@
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#
mainmenu "Matter Bridge sample application"

source "Kconfig.zephyr"
# Sample configuration used for Thread networking
if NET_L2_OPENTHREAD

choice OPENTHREAD_NORDIC_LIBRARY_CONFIGURATION
default OPENTHREAD_NORDIC_LIBRARY_FTD
endchoice

menu "Matter Bridge"
choice OPENTHREAD_DEVICE_TYPE
default OPENTHREAD_FTD
endchoice

endif # NET_L2_OPENTHREAD

config ZIGBEE_SHELL_DEVICE_NAME
string "UART device name for Zigbee shell"
default "UART_1"

endmenu
source "${ZEPHYR_BASE}/../modules/lib/matter/config/nrfconnect/chip-module/Kconfig.features"
source "${ZEPHYR_BASE}/../modules/lib/matter/config/nrfconnect/chip-module/Kconfig.defaults"
source "Kconfig.zephyr"
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ The Matter device(nRF5340) that runs the lighting bridge application is connecte

## Build the example

1. This example is based on nRF Conenct SDK **v1.9.0**. Before building the example, install the NCS v1.9.0 first. See [Getting Started](https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.9.0/nrf/getting_started.html) for more information.
1. This example is based on nRF Connect SDK **v2.4.0**. Before building the example, install the NCS v1.9.0 first. See [Getting Started](https://developer.nordicsemi.com/nRF_Connect_SDK/doc/2.4.0/nrf/getting_started.html) for more information.

2. Clone the example to nrf/samples/matter/bridge:

Expand Down Expand Up @@ -77,4 +77,4 @@ Shows the overall state of the device and its connectivity. The following states

5. Send test command to control the bridged light device. Below example toggle light device of endpoint 3 of node ID 1234:

zcl OnOff Toggle 1234 3 0
zcl OnOff Toggle 1234 3 0
7 changes: 7 additions & 0 deletions boards/nrf52840dk_nrf52840.overlay
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
*/

/ {
chosen {
nordic,pm-ext-flash = &mx25r64;
};
};


/ {
/*
* In some default configurations within the nRF Connect SDK,
Expand Down
60 changes: 57 additions & 3 deletions boards/nrf5340dk_nrf5340_cpuapp.overlay
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,66 @@
*
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
*/

/ {
chosen {
nordic,pm-ext-flash = &mx25r64;
};

/*
* By default, PWM module is only configured for led0 (LED1 on the board).
* The light bulb app, however, uses LED2 to show the state of the lighting,
* including its brightness level.
*/
aliases {
pwm-led1 = &pwm_led1;
};

pwmleds {
compatible = "pwm-leds";
pwm_led1: pwm_led_1 {
pwms = < &pwm0 1 PWM_MSEC(20) PWM_POLARITY_INVERTED>;
};
};
};

&pwm0 {
pinctrl-0 = <&pwm0_default_alt>;
pinctrl-1 = <&pwm0_sleep_alt>;
pinctrl-names = "default", "sleep";
};

&pinctrl {
pwm0_default_alt: pwm0_default_alt {
group1 {
psels = <NRF_PSEL(PWM_OUT1, 0, 29)>;
nordic,invert;
};
};

pwm0_sleep_alt: pwm0_sleep_alt {
group1 {
psels = <NRF_PSEL(PWM_OUT1, 0, 29)>;
low-power-enable;
};
};
};

/* Disable unused peripherals to reduce power consumption */
&adc {
status = "disabled";
};
&i2c1 {
status = "disabled";
};
&spi2 {
status = "disabled";
};
&usbd {
status = "disabled";
};

/* Used to talk to the Zigbee board */
&uart1 {
status = "okay";
tx-pin = <34>;
rx-pin = <35>;
};
};
23 changes: 23 additions & 0 deletions child_image/mcuboot/prj.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#
# Copyright (c) 2022 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#

# This sample uses Kconfig.defaults to set options common for all
# samples. This file should contain only options specific for this sample
# or overrides of default values.
# This target uses Kconfig.mcuboot.defaults to set options common for all
# samples using mcuboot. This file should contain only options specific for this sample
# mcuboot configuration or overrides of default values.

CONFIG_MBEDTLS_CFG_FILE="mcuboot-mbedtls-cfg.h"

# Bootloader size optimization
# Disable not used modules that cannot be set in Kconfig.mcuboot.defaults due to overriding
# in board files.
CONFIG_GPIO=n
CONFIG_CONSOLE=n
CONFIG_SERIAL=n
CONFIG_UART_CONSOLE=n
CONFIG_USE_SEGGER_RTT=n
23 changes: 23 additions & 0 deletions child_image/mcuboot/prj_release.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#
# Copyright (c) 2022 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#

# This sample uses Kconfig.defaults to set options common for all
# samples. This file should contain only options specific for this sample
# or overrides of default values.
# This target uses Kconfig.mcuboot.defaults to set options common for all
# samples using mcuboot. This file should contain only options specific for this sample
# mcuboot configuration or overrides of default values.

CONFIG_MBEDTLS_CFG_FILE="mcuboot-mbedtls-cfg.h"

# Bootloader size optimization
# Disable not used modules that cannot be set in Kconfig.mcuboot.defaults due to overriding
# in board files.
CONFIG_GPIO=n
CONFIG_CONSOLE=n
CONFIG_SERIAL=n
CONFIG_UART_CONSOLE=n
CONFIG_USE_SEGGER_RTT=n
10 changes: 0 additions & 10 deletions child_image/multiprotocol_rpmsg.conf

This file was deleted.

15 changes: 15 additions & 0 deletions child_image/multiprotocol_rpmsg/prj.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#
# Copyright (c) 2022 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#

# This target uses Kconfig.multiprotocol_rpmsg.defaults to set options common for all
# samples using multiprotocol_rpmsg. This file should contain only options specific for this sample
# multiprotocol_rpmsg configuration or overrides of default values.

# Disable not used modules that cannot be set in Kconfig.multiprotocol_rpmsg.defaults due to overriding
# in board files.

CONFIG_SERIAL=n
CONFIG_UART_CONSOLE=n
15 changes: 15 additions & 0 deletions child_image/multiprotocol_rpmsg/prj_no_dfu.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#
# Copyright (c) 2022 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#

# This target uses Kconfig.multiprotocol_rpmsg.defaults to set options common for all
# samples using multiprotocol_rpmsg. This file should contain only options specific for this sample
# multiprotocol_rpmsg configuration or overrides of default values.

# Disable not used modules that cannot be set in Kconfig.multiprotocol_rpmsg.defaults due to overriding
# in board files.

CONFIG_SERIAL=n
CONFIG_UART_CONSOLE=n
15 changes: 15 additions & 0 deletions child_image/multiprotocol_rpmsg/prj_release.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#
# Copyright (c) 2022 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#

# This target uses Kconfig.multiprotocol_rpmsg.defaults to set options common for all
# samples using multiprotocol_rpmsg. This file should contain only options specific for this sample
# multiprotocol_rpmsg configuration or overrides of default values.

# Disable not used modules that cannot be set in Kconfig.multiprotocol_rpmsg.defaults due to overriding
# in board files.

CONFIG_SERIAL=n
CONFIG_UART_CONSOLE=n
42 changes: 42 additions & 0 deletions configuration/nrf52840dk_nrf52840/pm_static_dfu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
mcuboot:
address: 0x0
size: 0x7000
region: flash_primary
mcuboot_pad:
address: 0x7000
size: 0x200
app:
address: 0x7200
size: 0xefe00
mcuboot_primary:
orig_span: &id001
- mcuboot_pad
- app
span: *id001
address: 0x7000
size: 0xf0000
region: flash_primary
mcuboot_primary_app:
orig_span: &id002
- app
span: *id002
address: 0x7200
size: 0xefe00
factory_data:
address: 0xf7000
size: 0x1000
region: flash_primary
settings_storage:
address: 0xf8000
size: 0x8000
region: flash_primary
mcuboot_secondary:
address: 0x0
size: 0xf0000
device: MX25R64
region: external_flash
external_flash:
address: 0xf0000
size: 0x710000
device: MX25R64
region: external_flash
Loading