Skip to content

Commit fe92e23

Browse files
authored
Merge branch 'master' into feature/fix-tv-app-install-flow-and-supported-clusters
2 parents 8914178 + 7c04979 commit fe92e23

File tree

12 files changed

+223
-23
lines changed

12 files changed

+223
-23
lines changed

config/nxp/chip-module/CMakeLists.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ if (CONFIG_CHIP_OTA_REQUESTOR)
237237
COMMAND
238238
cp ${PROJECT_BINARY_DIR}/../modules/connectedhomeip/build_mcuboot/zephyr/zephyr.bin ${PROJECT_BINARY_DIR}/zephyr.mcuboot.bin
239239
)
240-
240+
add_dependencies(build_mcuboot ${ZEPHYR_FINAL_EXECUTABLE})
241241
set(BLOCK_SIZE "1024")
242242
dt_nodelabel(dts_partition_path NODELABEL "boot_partition")
243243
dt_reg_size(mcuboot_size PATH ${dts_partition_path})
@@ -249,7 +249,7 @@ if (CONFIG_CHIP_OTA_REQUESTOR)
249249
COMMAND
250250
dd if=${PROJECT_BINARY_DIR}/${ZEPHYR_OUTPUT_NAME}.bin of=${PROJECT_BINARY_DIR}/zephyr_full.bin bs=${BLOCK_SIZE} seek=${boot_blocks}
251251
)
252-
add_dependencies(merge_mcuboot ${ZEPHYR_FINAL_EXECUTABLE})
252+
add_dependencies(merge_mcuboot build_mcuboot)
253253

254254
if (CONFIG_CHIP_OTA_IMAGE_BUILD)
255255
chip_ota_image(chip-ota-image

config/nxp/chip-module/Kconfig.defaults

+5-2
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ config BT_BUF_ACL_TX_SIZE
205205

206206
config BT_RX_STACK_SIZE
207207
default 2048 if NO_OPTIMIZATIONS && DEBUG
208-
default 1536
208+
default 1600
209209

210210
config BT_DEVICE_NAME_GATT_WRITABLE
211211
bool
@@ -217,6 +217,9 @@ config HCI_NXP_ENABLE_AUTO_SLEEP
217217
config CHIP_OTA_REQUESTOR
218218
default n
219219

220+
config CHIP_DEVICE_SOFTWARE_VERSION
221+
default 1
222+
220223
# Enable extended discovery
221224
config CHIP_EXTENDED_DISCOVERY
222225
default y
@@ -225,7 +228,7 @@ config NVS_LOOKUP_CACHE
225228
default y
226229

227230
config NVS_LOOKUP_CACHE_SIZE
228-
default 512
231+
default 1024
229232

230233
if CHIP_WIFI
231234

docs/guides/nxp/nxp_zephyr_ota_software_update.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,9 @@ The same procedure can be followed from the
157157
sub-section, replacing `CONFIG_CHIP_DEVICE_SOFTWARE_VERSION` with a number
158158
greater than the initial one used on the active application (Candidate
159159
application version number should be greater than the one used on the active
160-
application). By default the value is set to 0, try resetting this option to 1
160+
application). By default the value is set to 1, try resetting this option to 2
161161
to generate the OTA update Image. You can do this by adding
162-
`-DCONFIG_CHIP_DEVICE_SOFTWARE_VERSION=1` to the west build command.
162+
`-DCONFIG_CHIP_DEVICE_SOFTWARE_VERSION=2` to the west build command.
163163

164164
The current implementation automates the following procedures:
165165

examples/platform/nxp/common/app_task/source/AppTaskZephyr.cpp

+5-3
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
#include <zephyr/logging/log.h>
3030

3131
#ifdef CONFIG_CHIP_WIFI
32-
#include <platform/nxp/zephyr/wifi/NxpWifiDriver.h>
32+
#include <platform/Zephyr/wifi/ZephyrWifiDriver.h>
3333
#endif
3434

3535
#if CONFIG_CHIP_FACTORY_DATA
@@ -62,14 +62,16 @@ K_MSGQ_DEFINE(sAppEventQueue, sizeof(AppEvent), kAppEventQueueSize, alignof(AppE
6262
#if defined(CONFIG_CHIP_WIFI)
6363
chip::DeviceLayer::NetworkCommissioning::WiFiDriver * chip::NXP::App::AppTaskZephyr::GetWifiDriverInstance()
6464
{
65-
return static_cast<chip::DeviceLayer::NetworkCommissioning::WiFiDriver *>(&(NetworkCommissioning::NxpWifiDriver::Instance()));
65+
return static_cast<chip::DeviceLayer::NetworkCommissioning::WiFiDriver *>(
66+
&(NetworkCommissioning::ZephyrWifiDriver::Instance()));
6667
}
6768
#endif // CONFIG_CHIP_WIFI
6869

6970
CHIP_ERROR chip::NXP::App::AppTaskZephyr::Start()
7071
{
71-
72+
PreInitMatterStack();
7273
ReturnErrorOnFailure(Init());
74+
PostInitMatterStack();
7375

7476
AppEvent event{};
7577

examples/platform/nxp/common/icd/source/ICDUtil.cpp

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
*
3-
* Copyright (c) 2023 Project CHIP Authors
3+
* Copyright (c) 2023-2024 Project CHIP Authors
44
* All rights reserved.
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -17,6 +17,9 @@
1717
*/
1818

1919
#include "ICDUtil.h"
20+
#if CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR
21+
#include "OTARequestorInitiator.h"
22+
#endif
2023

2124
chip::NXP::App::ICDUtil chip::NXP::App::ICDUtil::sICDUtil;
2225

@@ -32,5 +35,8 @@ CHIP_ERROR chip::NXP::App::ICDUtil::OnSubscriptionRequested(chip::app::ReadHandl
3235
{
3336
agreedMaxInterval = requestedMaxInterval;
3437
}
38+
#if CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR
39+
chip::NXP::App::OTARequestorInitiator::Instance().gImageProcessor.SetRebootDelaySec(requestedMinInterval);
40+
#endif
3541
return aReadHandler.SetMaxReportingInterval(agreedMaxInterval);
3642
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
/*
2+
*
3+
* Copyright (c) 2024 Project CHIP Authors
4+
* All rights reserved.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
#include "AppFactoryData.h"
20+
21+
#include <credentials/DeviceAttestationCredsProvider.h>
22+
#include <platform/CommissionableDataProvider.h>
23+
#include <platform/DeviceInstanceInfoProvider.h>
24+
25+
#if CONFIG_CHIP_PLAT_LOAD_REAL_FACTORY_DATA
26+
#include "FactoryDataProvider.h"
27+
/*
28+
* Test key used to encrypt factory data before storing it to the flash.
29+
* The software key should be used only during development stage.
30+
* For production usage, it is recommended to use the OTP key which needs to be fused in the RT1060 SW_GP2.
31+
*/
32+
static const uint8_t aes128TestKey[]
33+
__attribute__((aligned)) = { 0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c };
34+
#else
35+
#include <credentials/examples/DeviceAttestationCredsExample.h>
36+
#endif
37+
38+
#if CONFIG_CHIP_FACTORY_DATA
39+
#include <platform/nxp/common/factory_data/FactoryDataProvider.h>
40+
#else
41+
#include <platform/nxp/zephyr/DeviceInstanceInfoProviderImpl.h>
42+
#endif
43+
44+
#if CONFIG_CHIP_FACTORY_DATA && CONFIG_CHIP_ENCRYPTED_FACTORY_DATA
45+
#ifdef CONFIG_CHIP_ENCRYPTED_FACTORY_DATA_AES128_KEY
46+
47+
#define KEY CONFIG_CHIP_ENCRYPTED_FACTORY_DATA_AES128_KEY
48+
#define HEXTONIBBLE(c) (*(c) >= 'A' ? (*(c) - 'A') + 10 : (*(c) - '0'))
49+
#define HEXTOBYTE(c) (HEXTONIBBLE(c) * 16 + HEXTONIBBLE(c + 1))
50+
#define AES128_KEY_ARRAY \
51+
HEXTOBYTE(KEY + 0), HEXTOBYTE(KEY + 2), HEXTOBYTE(KEY + 4), HEXTOBYTE(KEY + 6), HEXTOBYTE(KEY + 8), HEXTOBYTE(KEY + 10), \
52+
HEXTOBYTE(KEY + 12), HEXTOBYTE(KEY + 14), HEXTOBYTE(KEY + 16), HEXTOBYTE(KEY + 18), HEXTOBYTE(KEY + 20), \
53+
HEXTOBYTE(KEY + 22), HEXTOBYTE(KEY + 24), HEXTOBYTE(KEY + 26), HEXTOBYTE(KEY + 28), HEXTOBYTE(KEY + 30)
54+
#else
55+
#define AES128_KEY_ARRAY 0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c
56+
#endif /* CONFIG_CHIP_ENCRYPTED_FACTORY_DATA_AES128_KEY */
57+
58+
/*
59+
* Test key used to encrypt factory data before storing it to the flash.
60+
*/
61+
static const uint8_t aes128TestKey[] __attribute__((aligned)) = { AES128_KEY_ARRAY };
62+
63+
#endif /* CONFIG_CHIP_FACTORY_DATA && CONFIG_CHIP_ENCRYPTED_FACTORY_DATA */
64+
65+
using namespace chip;
66+
using namespace ::chip::Credentials;
67+
using namespace ::chip::DeviceLayer;
68+
69+
/**
70+
* Allows to register Matter factory data before initializing the Matter stack
71+
* Load factory data from the flash to the RAM.
72+
* Needs to be done before starting other Matter modules to avoid concurrent access issues with DCP hardware module.
73+
*
74+
* This example demonstrates the usage of the ecb with a software key, to use other encryption mode,
75+
* or to use hardware keys, check available methodes from the FactoryDataProviderImpl class.
76+
*/
77+
CHIP_ERROR NXP::App::AppFactoryData_PreMatterStackInit(void)
78+
{
79+
return CHIP_NO_ERROR;
80+
}
81+
82+
/**
83+
* Allows to register Matter factory data after initializing the Matter stack
84+
*/
85+
CHIP_ERROR NXP::App::AppFactoryData_PostMatterStackInit(void)
86+
{
87+
#if CONFIG_CHIP_FACTORY_DATA
88+
#if CONFIG_CHIP_ENCRYPTED_FACTORY_DATA
89+
FactoryDataPrvdImpl().SetEncryptionMode(FactoryDataProvider::encrypt_ecb);
90+
FactoryDataPrvdImpl().SetAes128Key(&aes128TestKey[0]);
91+
#endif /* CONFIG_CHIP_ENCRYPTED_FACTORY_DATA */
92+
ReturnErrorOnFailure(FactoryDataPrvdImpl().Init());
93+
SetDeviceInstanceInfoProvider(&FactoryDataPrvd());
94+
SetDeviceAttestationCredentialsProvider(&FactoryDataPrvd());
95+
SetCommissionableDataProvider(&FactoryDataPrvd());
96+
#else
97+
SetDeviceInstanceInfoProvider(&DeviceInstanceInfoProviderMgrImpl());
98+
SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider());
99+
#endif /* CONFIG_CHIP_FACTORY_DATA */
100+
return CHIP_NO_ERROR;
101+
}

src/platform/nxp/common/OTAImageProcessorImpl.cpp

+12-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
*
3-
* Copyright (c) 2022 Project CHIP Authors
3+
* Copyright (c) 2022-2024 Project CHIP Authors
44
* Copyright 2023 NXP
55
* All rights reserved.
66
*
@@ -22,6 +22,8 @@
2222

2323
#include "OTAImageProcessorImpl.h"
2424

25+
static constexpr uint16_t deltaRebootDelayMs = 200;
26+
2527
namespace chip {
2628

2729
CHIP_ERROR OTAImageProcessorImpl::PrepareDownload()
@@ -279,8 +281,10 @@ void OTAImageProcessorImpl::HandleApply(intptr_t context)
279281
* This should be done with a delay so the device has enough time to send
280282
* the state-transition event when applying the update.
281283
*/
282-
ChipLogProgress(SoftwareUpdate, "Restarting device in 5 seconds ...");
283-
DeviceLayer::SystemLayer().StartTimer(System::Clock::Milliseconds32(5 * 1000), HandleRestart, nullptr);
284+
ChipLogProgress(SoftwareUpdate, "Restarting device, will reboot in %d seconds ...", imageProcessor->mDelayBeforeRebootSec);
285+
DeviceLayer::PlatformMgr().HandleServerShuttingDown();
286+
DeviceLayer::SystemLayer().StartTimer(
287+
System::Clock::Milliseconds32(imageProcessor->mDelayBeforeRebootSec * 1000 + deltaRebootDelayMs), HandleRestart, nullptr);
284288

285289
/*
286290
* At next boot time, the bootloader will test + validate new image.
@@ -350,4 +354,9 @@ CHIP_ERROR OTAImageProcessorImpl::ReleaseBlock()
350354
return CHIP_NO_ERROR;
351355
}
352356

357+
void OTAImageProcessorImpl::SetRebootDelaySec(uint16_t rebootDelay)
358+
{
359+
mDelayBeforeRebootSec = rebootDelay;
360+
}
361+
353362
} // namespace chip

src/platform/nxp/common/OTAImageProcessorImpl.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
*
3-
* Copyright (c) 2022 Project CHIP Authors
3+
* Copyright (c) 2022-2024 Project CHIP Authors
44
* Copyright 2023 NXP
55
* All rights reserved.
66
*
@@ -47,6 +47,7 @@ class OTAImageProcessorImpl : public OTAImageProcessorInterface
4747
static void TriggerNewRequestForData(intptr_t context);
4848

4949
void SetOTADownloader(OTADownloader * downloader) { mDownloader = downloader; }
50+
void SetRebootDelaySec(uint16_t rebootDelay);
5051

5152
private:
5253
//////////// Actual handlers for the OTAImageProcessorInterface ///////////////
@@ -77,6 +78,8 @@ class OTAImageProcessorImpl : public OTAImageProcessorInterface
7778

7879
/* Buffer used for transaction storage */
7980
uint8_t mPostedOperationsStorage[NB_PENDING_TRANSACTIONS * TRANSACTION_SZ];
81+
82+
uint16_t mDelayBeforeRebootSec = 0;
8083
};
8184

8285
} // namespace chip

src/platform/nxp/zephyr/CHIPDevicePlatformConfig.h

-5
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,6 @@
7676
#define CHIP_DEVICE_CONFIG_SETTINGS_KEY "mt"
7777
#endif // CHIP_DEVICE_CONFIG_SETTINGS_KEY
7878

79-
#ifndef CHIP_DEVICE_CONFIG_OTA_REQUESTOR_REBOOT_DELAY_MS
80-
/// Delay between completing a firmware update download and reboot to apply the update
81-
#define CHIP_DEVICE_CONFIG_OTA_REQUESTOR_REBOOT_DELAY_MS 1000
82-
#endif // CHIP_DEVICE_CONFIG_OTA_REQUESTOR_REBOOT_DELAY_MS
83-
8479
#ifndef CHIP_DEVICE_CONFIG_SERVER_SHUTDOWN_ACTIONS_SLEEP_MS
8580
/// Time to sleep after running server shutdown actions to let lower layers complete the actions.
8681
/// This may include transmitting packets created by the actions.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
/*
2+
* Copyright (c) 2023-2024 Project CHIP Authors
3+
* All rights reserved.
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+
&sram {
19+
#address-cells = <1>;
20+
#size-cells = <1>;
21+
22+
sram_data: memory@20000000 {
23+
compatible = "mmio-sram";
24+
reg = <0x20000000 DT_SIZE_K(1216)>;
25+
};
26+
};
27+
28+
/delete-node/ &boot_partition;
29+
/delete-node/ &slot0_partition;
30+
/delete-node/ &slot1_partition;
31+
/delete-node/ &fw_storage;
32+
/delete-node/ &storage_partition;
33+
34+
&flexspi {
35+
status = "okay";
36+
37+
mx25u51245g: mx25u51245g@0 {
38+
status = "okay";
39+
40+
partitions {
41+
boot_partition: partition@0 {
42+
label = "mcuboot";
43+
reg = <0x00000000 DT_SIZE_K(128)>;
44+
};
45+
46+
slot0_partition: partition@20000 {
47+
label = "image-0";
48+
reg = <0x00020000 0x440000>;
49+
};
50+
51+
slot1_partition: partition@460000 {
52+
label = "image-1";
53+
reg = <0x00460000 0x440000>;
54+
};
55+
56+
storage_partition: partition@3FEF000 {
57+
label = "storage";
58+
reg = <0x03FEF000 DT_SIZE_K(64)>;
59+
};
60+
61+
factory_partition: partition@3FFF000 {
62+
label = "factory-data";
63+
reg = <0x03FFF000 DT_SIZE_K(4)>;
64+
};
65+
66+
};
67+
};
68+
};

0 commit comments

Comments
 (0)