Skip to content

Commit 347b2ad

Browse files
ArekBalysNordicrlubos
authored andcommitted
samples: matter: Add basic SUIT support to Template sample
Added base SUIT support to Template to allow the next development. - Added a config overlay file to enable all SUIT dependencies and BLE SMP transfer. - Added a DTS overlay file for SUIT purposes, enabling communication between the Application core and secure domain and reorganized partition layout. - Aligned the dfu_over_smp Matter's implementation to be compatible with SUIT. - Moved template SUIT manifests to the common directory - Added some Sysbuild configs to manipulate the common SUIT manifest. - Added a basic configuration for Flash Companion for SUIT purposes. - Removed redundant IPC between radio and application cores configuration. - We use the same long dts files in all Matter samples, so we can move them to the common directory and include them within all samples. - If users want to overlay it, they can write an overlay directly in samples' dts overlays or use the external overlay files. Signed-off-by: Arkadiusz Balys <[email protected]>
1 parent e8b1544 commit 347b2ad

31 files changed

+332
-775
lines changed

samples/matter/common/cmake/source_common.cmake

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,10 @@ if(CONFIG_PWM)
2929
endif()
3030

3131
if(CONFIG_MCUMGR_TRANSPORT_BT)
32-
zephyr_library_link_libraries(MCUBOOT_BOOTUTIL)
3332
target_sources(app PRIVATE ${MATTER_COMMONS_SRC_DIR}/dfu/smp/dfu_over_smp.cpp)
33+
if (NOT CONFIG_SUIT)
34+
zephyr_library_link_libraries(MCUBOOT_BOOTUTIL)
35+
endif()
3436
endif()
3537

3638
if(CONFIG_NCS_SAMPLE_MATTER_OPERATIONAL_KEYS_MIGRATION_TO_ITS)
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/*
2+
* Copyright (c) 2024 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
*/
6+
7+
/*
8+
* This file contains memory layout for the Application core aligned to Matter requirements
9+
*/
10+
11+
/ {
12+
aliases {
13+
factory-data = &factory_data;
14+
factory-data-memory-region = &cpuapp_rw_partitions;
15+
};
16+
};
17+
18+
/* We need to redefine partitions to meet Matter requirements */
19+
/delete-node/ &cpuapp_rx_partitions;
20+
/delete-node/ &cpuapp_rw_partitions;
21+
/delete-node/ &cpurad_rx_partitions;
22+
/delete-node/ &cpuppr_vpr;
23+
/delete-node/ &cpuapp_cpuppr_ipc;
24+
25+
&mram1x {
26+
erase-block-size = < 0x1000 >;
27+
write-block-size = < 0x10 >;
28+
29+
cpuapp_rx_partitions: cpuapp-rx-partitions {
30+
compatible = "nordic,owned-partitions", "fixed-partitions";
31+
status = "okay";
32+
perm-read;
33+
perm-execute;
34+
perm-secure;
35+
#address-cells = <1>;
36+
#size-cells = <1>;
37+
38+
companion_partition: partition@98000 {
39+
reg = <0x98000 DT_SIZE_K(64)>;
40+
};
41+
42+
cpuapp_slot0_partition: partition@a8000 {
43+
reg = <0xa8000 DT_SIZE_K(784)>;
44+
};
45+
};
46+
47+
cpuapp_rw_partitions: cpuapp-rw-partitions {
48+
compatible = "nordic,owned-partitions", "fixed-partitions";
49+
status = "okay";
50+
perm-read;
51+
perm-write;
52+
#address-cells = < 0x1 >;
53+
#size-cells = < 0x1 >;
54+
55+
storage_partition: partition@16C000 {
56+
reg = < 0x16C000 DT_SIZE_K(32) >;
57+
};
58+
59+
factory_data: partition@174000 {
60+
reg = < 0x174000 DT_SIZE_K(4) >;
61+
};
62+
63+
/* DFU partition to store SUIT manifests and Nordic Firmware update */
64+
dfu_partition: partition@175000 {
65+
reg = < 0x175000 DT_SIZE_K(464) >;
66+
};
67+
68+
};
69+
};
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Copyright (c) 2024 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
*/
6+
7+
/*
8+
* This file contains all peripherals needed by the Application core for Matter purposes
9+
*/
10+
11+
/ {
12+
chosen {
13+
/* prepare IPC to HCI Radio core */
14+
zephyr,bt-hci-ipc = &ipc0;
15+
};
16+
17+
aliases {
18+
watchdog0 = &cpuapp_wdt010;
19+
};
20+
};
21+
22+
/* Watchdog */
23+
&cpuapp_wdt010 {
24+
status = "okay";
25+
};
26+
27+
/* Communication between Application Core and Secure domain for SUIT */
28+
&cpusec_cpuapp_ipc {
29+
status = "okay";
30+
};
31+
&cpusec_bellboard {
32+
status = "okay";
33+
};
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Copyright (c) 2024 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
*/
6+
7+
/*
8+
* This file contains memory layout for the Radio core aligned to Matter requirements
9+
*/
10+
11+
/*
12+
* Reduce size of the cpurad code partition and remove all redundant partitions
13+
*/
14+
15+
/delete-node/ &cpuapp_rx_partitions;
16+
/delete-node/ &cpuapp_rw_partitions;
17+
/delete-node/ &cpurad_rx_partitions;
18+
/delete-node/ &cpuppr_vpr;
19+
20+
&mram1x {
21+
cpurad_rx_partitions: cpurad-rx-partitions {
22+
compatible = "nordic,owned-partitions", "fixed-partitions";
23+
status = "okay";
24+
perm-read;
25+
perm-execute;
26+
perm-secure;
27+
#address-cells = < 0x1 >;
28+
#size-cells = < 0x1 >;
29+
cpurad_slot0_partition: partition@66000 {
30+
reg = < 0x66000 DT_SIZE_K(200) >;
31+
};
32+
};
33+
};
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* Copyright (c) 2024 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
*/
6+
7+
/*
8+
* This is a workaround for radio core configuration.
9+
* It will be removed once those configs are enabled
10+
* within the sdk-zephyr
11+
*/
12+
13+
&dppic130 {
14+
owned-channels = <0 1 2 3>;
15+
sink-channels = <0 1 2>;
16+
source-channels = <3>;
17+
nonsecure-channels = <0 1 2 3>;
18+
status = "okay";
19+
};
20+
21+
&dppic132 {
22+
owned-channels = <0 1 2 3>;
23+
owned-channel-groups = <0 1>;
24+
source-channels = <0 1 2>;
25+
sink-channels = <3>;
26+
nonsecure-channels = <0 1 2 3>;
27+
status = "okay";
28+
};
29+
30+
&cpurad_ipct {
31+
source-channel-links = <0 13 0>;
32+
sink-channel-links = <0 13 0
33+
1 13 1
34+
2 13 2>;
35+
};
36+
37+
&ipct130 {
38+
status = "okay";
39+
owned-channels = <0 1 2>;
40+
source-channel-links = <0 3 0
41+
1 3 1
42+
2 3 2>;
43+
sink-channel-links = <0 3 0>;
44+
};
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
* Copyright (c) 2024 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
*/
6+
7+
/*
8+
* This file board definitions needed to run flash companion for SUIT purposes
9+
* aligned to the Matter requirements.
10+
*/
11+
12+
/ {
13+
chosen {
14+
extmem-device = &mx25uw63;
15+
zephyr,code-partition = &companion_partition;
16+
};
17+
};
18+
19+
&cpusec_cpuapp_ipc {
20+
status = "okay";
21+
};
22+
23+
&cpusec_bellboard {
24+
status = "okay";
25+
};
26+
27+
&cpuapp_bellboard {
28+
status = "okay";
29+
};
30+
31+
&mx25uw63 {
32+
status = "okay";
33+
};
34+
35+
&uart136 {
36+
status = "disabled";
37+
};
38+
39+
&cpurad_bellboard {
40+
status = "disabled";
41+
};
42+
43+
&pwm120 {
44+
status = "disabled";
45+
};
46+
47+
&cpuapp_cpurad_ipc {
48+
status = "disabled";
49+
};
50+
51+
&prng {
52+
status = "disabled";
53+
};
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*
2+
* Copyright (c) 2024 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
*/
6+
7+
/*
8+
* This file contains RAM layout aligned to Matter requirements
9+
*/
10+
11+
&cpuapp_ram0x_region{
12+
status = "okay";
13+
reg = <0x2f010000 DT_SIZE_K(512)>;
14+
ranges = <0x0 0x2f010000 0x6e000>;
15+
cpuapp_data: memory@1000 {
16+
reg = <0x1000 DT_SIZE_K(508)>;
17+
};
18+
};

samples/matter/common/src/dfu/smp/dfu_over_smp.cpp

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,12 @@
66

77
#include "dfu_over_smp.h"
88

9-
#if !defined(CONFIG_MCUMGR_TRANSPORT_BT) || !defined(CONFIG_MCUMGR_GRP_IMG) || !defined(CONFIG_MCUMGR_GRP_OS)
10-
#error "DFUOverSMP requires MCUMGR module configs enabled"
9+
#if !defined(CONFIG_MCUMGR_TRANSPORT_BT)
10+
#error "DFU over SMP requires MCUmgr Bluetooth LE module config enabled"
11+
#endif
12+
13+
#if !defined(CONFIG_SUIT) && (!defined(CONFIG_MCUMGR_GRP_IMG) || !defined(CONFIG_MCUMGR_GRP_OS))
14+
#error "DFU over SMP requires MCUmgr IMG and OS groups"
1115
#endif
1216

1317
#include "dfu/ota/ota_util.h"
@@ -16,43 +20,42 @@
1620

1721
#include <lib/support/logging/CHIPLogging.h>
1822

23+
#ifndef CONFIG_SUIT
1924
#include <zephyr/dfu/mcuboot.h>
25+
#include <zephyr/mgmt/mcumgr/grp/img_mgmt/img_mgmt.h>
26+
#endif
27+
2028
#include <zephyr/mgmt/mcumgr/mgmt/callbacks.h>
2129
#include <zephyr/mgmt/mcumgr/mgmt/mgmt.h>
22-
#include <zephyr/mgmt/mcumgr/grp/img_mgmt/img_mgmt.h>
2330

2431
using namespace ::chip;
2532
using namespace ::chip::DeviceLayer;
2633

27-
constexpr uint8_t kAdvertisingPriority = UINT8_MAX;
28-
constexpr uint32_t kAdvertisingOptions = BT_LE_ADV_OPT_CONNECTABLE;
29-
constexpr uint16_t kAdvertisingIntervalMin = 400;
30-
constexpr uint16_t kAdvertisingIntervalMax = 500;
31-
constexpr uint8_t kAdvertisingFlags = BT_LE_AD_GENERAL | BT_LE_AD_NO_BREDR;
34+
constexpr static uint8_t kAdvertisingPriority = UINT8_MAX;
35+
constexpr static uint32_t kAdvertisingOptions = BT_LE_ADV_OPT_CONNECTABLE;
36+
constexpr static uint16_t kAdvertisingIntervalMin = 400;
37+
constexpr static uint16_t kAdvertisingIntervalMax = 500;
38+
constexpr static uint8_t kAdvertisingFlags = BT_LE_AD_GENERAL | BT_LE_AD_NO_BREDR;
3239

3340
namespace
3441
{
35-
enum mgmt_cb_return UploadConfirmHandler(uint32_t event,
36-
enum mgmt_cb_return prev_status,
37-
int32_t *rc, uint16_t *group,
38-
bool *abort_more, void *data,
39-
size_t data_size)
42+
enum mgmt_cb_return UploadConfirmHandler(uint32_t event, enum mgmt_cb_return prev_status, int32_t *rc, uint16_t *group,
43+
bool *abort_more, void *data, size_t data_size)
4044
{
45+
/* Currently img_mgmt hooks are not supported by SUIT */
46+
#ifndef CONFIG_SUIT
4147
const img_mgmt_upload_check &imgData = *static_cast<img_mgmt_upload_check *>(data);
4248
IgnoreUnusedVariable(imgData);
4349

4450
ChipLogProgress(SoftwareUpdate, "DFU over SMP progress: %u/%u B of image %u",
4551
static_cast<unsigned>(imgData.req->off), static_cast<unsigned>(imgData.action->size),
4652
static_cast<unsigned>(imgData.req->image));
47-
53+
#endif
4854
return MGMT_CB_OK;
4955
}
5056

51-
enum mgmt_cb_return CommandHandler(uint32_t event,
52-
enum mgmt_cb_return prev_status,
53-
int32_t *rc, uint16_t *group,
54-
bool *abort_more, void *data,
55-
size_t data_size)
57+
enum mgmt_cb_return CommandHandler(uint32_t event, enum mgmt_cb_return prev_status, int32_t *rc, uint16_t *group,
58+
bool *abort_more, void *data, size_t data_size)
5659
{
5760
if (event == MGMT_EVT_OP_CMD_RECV) {
5861
Nrf::Matter::GetFlashHandler().DoAction(ExternalFlashManager::Action::WAKE_UP);
@@ -75,7 +78,8 @@ mgmt_callback sCommandCallback = {
7578

7679
} /* namespace */
7780

78-
namespace Nrf {
81+
namespace Nrf
82+
{
7983

8084
DFUOverSMP DFUOverSMP::sDFUOverSMP;
8185

@@ -106,6 +110,7 @@ void DFUOverSMP::Init()
106110

107111
void DFUOverSMP::ConfirmNewImage()
108112
{
113+
#ifndef CONFIG_SUIT
109114
/* Check if the image is run in the REVERT mode and eventually */
110115
/* confirm it to prevent reverting on the next boot. */
111116
VerifyOrReturn(mcuboot_swap_type() == BOOT_SWAP_TYPE_REVERT);
@@ -115,6 +120,7 @@ void DFUOverSMP::ConfirmNewImage()
115120
} else {
116121
ChipLogProgress(SoftwareUpdate, "New firmware image confirmed");
117122
}
123+
#endif
118124
}
119125

120126
void DFUOverSMP::StartServer()

samples/matter/common/src/dfu/smp/dfu_over_smp.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010

1111
#include <array>
1212

13-
namespace Nrf {
13+
namespace Nrf
14+
{
1415

1516
/**
1617
* @brief DFU over SMP helper class

0 commit comments

Comments
 (0)