Skip to content

Commit

Permalink
samples: matter: Added support for DFU in lock and light bulb.
Browse files Browse the repository at this point in the history
* Added an overlay enabling build with MCUboot and DFU over BLE
support.
* Aligned samples' docs to contain information about DFU support.
* Changed button 1 functionality from performing factory reset
after pressing to perform factory reset after holding over 6s
and enabling DFU after short press.

Signed-off-by: Kamil Kasperczyk <[email protected]>
  • Loading branch information
kkasperczyk-no committed Jun 1, 2021
1 parent 778fa29 commit 136865c
Show file tree
Hide file tree
Showing 16 changed files with 521 additions and 22 deletions.
1 change: 1 addition & 0 deletions doc/nrf/links.txt
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
.. _`Building and installing Android CHIPTool`: https://github.com/nrfconnect/sdk-connectedhomeip/blob/b35e8e/docs/guides/nrfconnect_android_commissioning.md#user-content-building-and-installing-android-chiptool
.. _`Configuring PC as Thread Border Router`: https://github.com/nrfconnect/sdk-connectedhomeip/blob/b35e8e/docs/guides/nrfconnect_android_commissioning.md#user-content-configuring-pc-as-thread-border-router
.. _`Preparing and commissioning accessory device`: https://github.com/nrfconnect/sdk-connectedhomeip/blob/b35e8e/docs/guides/nrfconnect_android_commissioning.md#user-content-preparing-accessory-device
.. _`Performing Device Firmware Upgrade in Matter device`: https://github.com/nrfconnect/sdk-connectedhomeip/blob/TODO!!!!!!!!!/docs/guides/nrfconnect_examples_software_update.md
.. _`Matter Protocol Overview`: https://github.com/nrfconnect/sdk-connectedhomeip/blob/b35e8e/README.md
.. _`nRF Connect platform overview`: https://github.com/nrfconnect/sdk-connectedhomeip/blob/b35e8e/docs/guides/nrfconnect_platform_overview.md

Expand Down
31 changes: 31 additions & 0 deletions samples/matter/common/config/overlay-dfu_support.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#
# Copyright (c) 2021 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#


CONFIG_BOOTLOADER_MCUBOOT=y

# QSPI configuration
CONFIG_NORDIC_QSPI_NOR=y
CONFIG_NORDIC_QSPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096
CONFIG_NORDIC_QSPI_NOR_STACK_WRITE_BUFFER_SIZE=4

# External flash memory configuration
CONFIG_PM_EXTERNAL_FLASH=y
CONFIG_PM_EXTERNAL_FLASH_DEV_NAME="MX25R64"
CONFIG_PM_EXTERNAL_FLASH_SIZE=0xf2000
CONFIG_PM_EXTERNAL_FLASH_BASE=0

# MCU Manager and SMP configuration
CONFIG_MCUMGR=y
CONFIG_MCUMGR_CMD_IMG_MGMT=y
CONFIG_MCUMGR_CMD_OS_MGMT=y
CONFIG_MCUMGR_SMP_BT=y
CONFIG_MCUMGR_SMP_BT_AUTHEN=n
CONFIG_MCUMGR_BUF_COUNT=6

# Increase BT MTU and RX buffer for big size DFU messages
CONFIG_BT_L2CAP_TX_MTU=260
CONFIG_BT_BUF_ACL_RX_SIZE=264
21 changes: 19 additions & 2 deletions samples/matter/light_bulb/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ It can be tested in the following ways:
The remote control testing requires either commissioning by the Matter controller device into a network or using the test mode.
Both methods can be enabled after :ref:`building and running the sample <matter_light_bulb_sample_remote_control>`.

The sample can be configured to use the secure bootloader and utilize it for performing over-the-air Device Firmware Upgrade using Bluetooth LE.

.. _matter_light_bulb_network_mode:

Remote testing in a network
Expand All @@ -76,6 +78,13 @@ Configuration

|config|

Device Firmware Upgrade support
===============================

.. include:: ../lock/README.rst
:start-after: matter_door_lock_sample_build_with_dfu_start
:end-before: matter_door_lock_sample_build_with_dfu_end

User interface
**************

Expand All @@ -90,8 +99,9 @@ LED 2:
* Solid On - The light bulb is on.
* Off - The light bulb is off.

Button 1:
Initiates the factory reset of the device.
.. include:: ../lock/README.rst
:start-after: matter_door_lock_sample_button1_start
:end-before: matter_door_lock_sample_button1_end

Button 2:
Changes the light bulb state to the opposite one.
Expand Down Expand Up @@ -119,6 +129,8 @@ Building and running

.. include:: /includes/build_and_run.txt

See `Configuration`_ for information about building the sample with the DFU support.

Testing
=======

Expand Down Expand Up @@ -183,6 +195,11 @@ Commissioning the device
:start-after: matter_door_lock_sample_commissioning_start
:end-before: matter_door_lock_sample_commissioning_end

Upgrading the device firmware
=============================

To upgrade the device firmware, complete the steps listed for the selected method in the `Performing Device Firmware Upgrade in Matter device`_ tutorial.

Dependencies
************

Expand Down
19 changes: 19 additions & 0 deletions samples/matter/light_bulb/child_image/mcuboot.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#
# Copyright (c) 2021 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#

# QSPI configuration
CONFIG_NORDIC_QSPI_NOR=y
CONFIG_NORDIC_QSPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096
CONFIG_NORDIC_QSPI_NOR_STACK_WRITE_BUFFER_SIZE=4

CONFIG_MULTITHREADING=y
CONFIG_BOOT_MAX_IMG_SECTORS=256

# External flash memory configuration
CONFIG_PM_EXTERNAL_FLASH=y
CONFIG_PM_EXTERNAL_FLASH_DEV_NAME="MX25R64"
CONFIG_PM_EXTERNAL_FLASH_SIZE=0xf2000
CONFIG_PM_EXTERNAL_FLASH_BASE=0
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
mcuboot:
address: 0x0
size: 0xc000
region: flash_primary
mcuboot_pad:
address: 0xc000
size: 0x200
app:
address: 0xc200
size: 0xf1e00
mcuboot_primary:
orig_span: &id001
- mcuboot_pad
- app
span: *id001
address: 0xc000
size: 0xf2000
region: flash_primary
mcuboot_primary_app:
orig_span: &id002
- app
span: *id002
address: 0xc200
size: 0xf1e00
settings_storage:
address: 0xfe000
size: 0x2000
region: flash_primary
mcuboot_secondary:
address: 0x0
size: 0xf2000
device: MX25R64
region: external_flash
external_flash:
address: 0xf2000
size: 0x0
device: MX25R64
region: external_flash
1 change: 1 addition & 0 deletions samples/matter/light_bulb/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ CONFIG_BT_MAX_PAIRED=0
CONFIG_BT_BONDABLE=n
CONFIG_BT_TINYCRYPT_ECC=n
CONFIG_BT_SMP_OOB_LEGACY_PAIR_ONLY=y
CONFIG_SDC_MAX_CONN_EVENT_LEN_DEFAULT=3000

# Use NFC to share commissioning information
CONFIG_CHIP_NFC_COMMISSIONING=y
Expand Down
11 changes: 5 additions & 6 deletions samples/matter/light_bulb/src/app_event.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,9 @@
struct AppEvent {
enum LightEventType : uint8_t { On, Off, Toggle, Level };

enum OtherEventType : uint8_t {
FactoryReset = Level + 1,
StartThread,
StartBleAdvertising,
PublishLightBulbService
};
enum FunctionEventType : uint8_t { FunctionPress = Level + 1, FunctionRelease, FunctionTimer };

enum OtherEventType : uint8_t { StartThread = FunctionTimer + 1, StartBleAdvertising, PublishLightBulbService };

AppEvent() = default;

Expand All @@ -25,6 +22,8 @@ struct AppEvent {
{
}

AppEvent(FunctionEventType type) : Type(type) {}

AppEvent(OtherEventType type) : Type(type) {}

uint8_t Type;
Expand Down
Loading

0 comments on commit 136865c

Please sign in to comment.