Skip to content

Commit a603b57

Browse files
authored
Merge branch 'master' into camera-push
2 parents 8a02f5b + b0d0614 commit a603b57

22 files changed

+218
-65
lines changed

.github/workflows/examples-esp32.yaml

+9-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ jobs:
8383
"./scripts/build/build_examples.py \
8484
--enable-flashbundle \
8585
--target esp32-m5stack-all-clusters-minimal \
86-
--target esp32-m5stack-all-clusters-rpc-ipv6only \
8786
--pregen-dir ./zzz_pregenerated \
8887
build \
8988
--copy-artifacts-to out/artifacts \
@@ -95,6 +94,15 @@ jobs:
9594
mv scripts/tools/zap/generate.py.renamed scripts/tools/zap/generate.py
9695
- name: Build example All Clusters App(Target:ESP32C3)
9796
run: scripts/examples/esp_example.sh all-clusters-app sdkconfig.defaults.esp32c3 esp32c3
97+
- name: Build example All Clusters App(Target:ESP32)
98+
run: |
99+
./scripts/run_in_build_env.sh \
100+
"./scripts/build/build_examples.py \
101+
--enable-flashbundle \
102+
--target esp32-devkitc-all-clusters-rpc-ipv6only \
103+
build \
104+
--copy-artifacts-to out/artifacts \
105+
"
98106
- name: Copy aside build products
99107
run: |
100108
mkdir -p example_binaries/esp32-build

.vscode/tasks.json

-2
Original file line numberDiff line numberDiff line change
@@ -579,8 +579,6 @@
579579
"esp32-devkitc-temperature-measurement",
580580
"esp32-m5stack-all-clusters",
581581
"esp32-m5stack-all-clusters-ipv6only",
582-
"esp32-m5stack-all-clusters-rpc",
583-
"esp32-m5stack-all-clusters-rpc-ipv6only",
584582
"infineon-psoc6-all-clusters",
585583
"infineon-psoc6-lock",
586584
"infineon-psoc6-light",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
#
2+
# Copyright (c) 2024 Project CHIP Authors
3+
# Copyright (c) 2024 Nest Labs, Inc.
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+
# Description:
19+
# CI uses this to select the ESP32.
20+
#
21+
CONFIG_IDF_TARGET="esp32"
22+
CONFIG_IDF_TARGET_ESP32=y
23+
24+
# Default to 921600 baud when flashing and monitoring device
25+
CONFIG_ESPTOOLPY_BAUD_921600B=y
26+
CONFIG_ESPTOOLPY_BAUD=921600
27+
CONFIG_ESPTOOLPY_COMPRESSED=y
28+
CONFIG_ESPTOOLPY_MONITOR_BAUD_115200B=y
29+
CONFIG_ESPTOOLPY_MONITOR_BAUD=115200
30+
31+
#enable BT
32+
CONFIG_BT_ENABLED=y
33+
CONFIG_BT_NIMBLE_ENABLED=y
34+
35+
#enable lwip ipv6 autoconfig
36+
CONFIG_LWIP_IPV6_AUTOCONFIG=y
37+
38+
# Use a custom partition table
39+
CONFIG_PARTITION_TABLE_CUSTOM=y
40+
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv"
41+
42+
# Vendor and product id
43+
CONFIG_DEVICE_VENDOR_ID=0xFFF1
44+
CONFIG_DEVICE_PRODUCT_ID=0x8001
45+
46+
# Main task needs a bit more stack than the default
47+
# default is 3584, bump this up to 5k.
48+
CONFIG_ESP_MAIN_TASK_STACK_SIZE=5120
49+
50+
# PW RPC Debug channel
51+
CONFIG_EXAMPLE_UART_PORT_NUM=0
52+
CONFIG_EXAMPLE_UART_BAUD_RATE=115200
53+
CONFIG_EXAMPLE_UART_RXD=3
54+
CONFIG_EXAMPLE_UART_TXD=1
55+
CONFIG_ENABLE_PW_RPC=y
56+
57+
# Disable shell
58+
CONFIG_ENABLE_CHIP_SHELL=n
59+
60+
# Serial Flasher config
61+
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
62+
CONFIG_ESPTOOLPY_FLASHSIZE="4MB"
63+
64+
65+
#disable Bluetooth modem sleep
66+
#enable it may cause GPIO ISR triggers continuously
67+
CONFIG_BTDM_CTRL_MODEM_SLEEP=n
68+
CONFIG_BTDM_CTRL_MODEM_SLEEP_MODE_ORIG=n
69+
CONFIG_BTDM_CTRL_LPCLK_SEL_MAIN_XTAL=n
70+
71+
# Enable HKDF in mbedtls
72+
CONFIG_MBEDTLS_HKDF_C=y
73+
74+
# Build chip tests
75+
CONFIG_BUILD_CHIP_TESTS=y
76+
77+
# Move functions from IRAM to flash
78+
CONFIG_FREERTOS_PLACE_FUNCTIONS_INTO_FLASH=y
79+
80+
CONFIG_DIAG_USE_EXTERNAL_LOG_WRAP=y
81+
82+
# Memory Optimizations
83+
CONFIG_NIMBLE_MAX_CONNECTIONS=1
84+
CONFIG_BTDM_CTRL_BLE_MAX_CONN=1
85+
CONFIG_BT_NIMBLE_ROLE_CENTRAL=n
86+
CONFIG_BT_NIMBLE_ROLE_OBSERVER=n
87+
88+
# Reduce the event logging buffer to reduce the DRAM overflow
89+
# TODO: [ESP32] Fix the DRAM overflow in esp32 apps #34717
90+
CONFIG_EVENT_LOGGING_CRIT_BUFFER_SIZE=512
91+
CONFIG_EVENT_LOGGING_INFO_BUFFER_SIZE=512
92+
CONFIG_EVENT_LOGGING_DEBUG_BUFFER_SIZE=512

examples/chef/nrfconnect/rpc.overlay

+4-2
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ CONFIG_LOG_OUTPUT=y
4949
# Increase zephyr tty rx buffer
5050
CONFIG_CONSOLE_GETCHAR_BUFSIZE=128
5151

52-
# Increase BLE thread stack size
53-
CONFIG_BT_RX_STACK_SIZE=2048
52+
# Increase thread stack sizes
53+
CONFIG_BT_RX_STACK_SIZE=4096
54+
CONFIG_MAIN_STACK_SIZE=8092
55+
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048
5456

examples/lighting-app/nrfconnect/rpc.overlay

+4-2
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ CONFIG_LOG_OUTPUT=y
4646
# Increase zephyr tty rx buffer
4747
CONFIG_CONSOLE_GETCHAR_BUFSIZE=128
4848

49-
# Increase BLE thread stack size
50-
CONFIG_BT_RX_STACK_SIZE=2048
49+
# Increase thread stack sizes
50+
CONFIG_BT_RX_STACK_SIZE=4096
51+
CONFIG_MAIN_STACK_SIZE=8092
52+
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048
5153

integrations/cloudbuild/smoke-test.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ steps:
3434
./scripts/build/build_examples.py --enable-flashbundle --target
3535
esp32-devkitc-light-rpc --target
3636
esp32-m5stack-all-clusters-ipv6only --target
37-
esp32-m5stack-all-clusters-rpc-ipv6only --target
3837
esp32-m5stack-light --target
3938
esp32-m5stack-light-ipv6only --target
4039
esp32-m5stack-ota-requestor build --create-archives

scripts/build/BUILD.gn

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ pw_python_package("build_examples") {
2626
"testdata/dry_run_android-arm64-chip-tool.txt",
2727
"testdata/dry_run_efr32-brd4187c-light-rpc-no-version.txt",
2828
"testdata/dry_run_esp32-devkitc-light-rpc.txt",
29-
"testdata/dry_run_esp32-m5stack-all-clusters-minimal-rpc-ipv6only.txt",
3029
"testdata/dry_run_linux-arm64-chip-tool-ipv6only-clang.txt",
3130
"testdata/dry_run_linux-arm64-ota-requestor-nodeps-ipv6only.txt",
3231
"testdata/dry_run_linux-x64-all-clusters-coverage.txt",

scripts/build/test.py

-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ def test_general_dry_runs(self):
108108
# build options do not change too much
109109
TARGETS = [
110110
'esp32-devkitc-light-rpc',
111-
'esp32-m5stack-all-clusters-minimal-rpc-ipv6only',
112111
'android-arm64-chip-tool',
113112
'nrf-nrf52840dk-pump',
114113
'efr32-brd4187c-light-rpc-no-version',

scripts/build/testdata/dry_run_esp32-m5stack-all-clusters-minimal-rpc-ipv6only.txt

-26
This file was deleted.

src/app/clusters/user-label-server/user-label-server.cpp

+8-1
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,14 @@ CHIP_ERROR UserLabelAttrAccess::WriteLabelList(const ConcreteDataAttributePath &
151151
ReturnErrorOnFailure(aDecoder.Decode(entry));
152152
VerifyOrReturnError(IsValidLabelEntry(entry), CHIP_IM_GLOBAL_STATUS(ConstraintError));
153153

154-
return provider->AppendUserLabel(endpoint, entry);
154+
// Append the single user label entry
155+
CHIP_ERROR err = provider->AppendUserLabel(endpoint, entry);
156+
if (err == CHIP_ERROR_NO_MEMORY)
157+
{
158+
return CHIP_IM_GLOBAL_STATUS(ResourceExhausted);
159+
}
160+
161+
return err;
155162
}
156163

157164
return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE;

src/app/server/Server.cpp

+16-14
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
#include <app/data-model-provider/Provider.h>
2828
#include <app/server/Dnssd.h>
2929
#include <app/server/EchoHandler.h>
30-
#include <app/util/DataModelHandler.h>
3130

3231
#if CONFIG_NETWORK_LAYER_BLE
3332
#include <ble/Ble.h>
@@ -170,17 +169,6 @@ CHIP_ERROR Server::Init(const ServerInitParams & initParams)
170169
SuccessOrExit(err = mAttributePersister.Init(mDeviceStorage));
171170
SetSafeAttributePersistenceProvider(&mAttributePersister);
172171

173-
// SetDataModelProvider() actually initializes/starts the provider. We need
174-
// to preserve the following ordering guarantees:
175-
//
176-
// 1) Provider initialization (under SetDataModelProvider) happens after
177-
// SetSafeAttributePersistenceProvider, since the provider can then use
178-
// the safe persistence provider to implement and initialize its own attribute persistence logic.
179-
// 2) For now, provider initialization happens before InitDataModelHandler(), which depends
180-
// on atttribute persistence being already set up before it runs. Longer-term, the logic from
181-
// InitDataModelHandler should just move into the codegen provider.
182-
app::InteractionModelEngine::GetInstance()->SetDataModelProvider(initParams.dataModelProvider);
183-
184172
{
185173
FabricTable::InitParams fabricTableInitParams;
186174
fabricTableInitParams.storage = mDeviceStorage;
@@ -302,8 +290,22 @@ CHIP_ERROR Server::Init(const ServerInitParams & initParams)
302290
}
303291
#endif // CHIP_CONFIG_ENABLE_SERVER_IM_EVENT
304292

305-
// This initializes clusters, so should come after lower level initialization.
306-
InitDataModelHandler();
293+
// SetDataModelProvider() initializes and starts the provider, which in turn
294+
// triggers the initialization of cluster implementations. This callsite is
295+
// critical because it ensures that cluster-level initialization occurs only
296+
// after all necessary low-level dependencies have been set up.
297+
//
298+
// Ordering guarantees:
299+
// 1) Provider initialization (under SetDataModelProvider) must happen after
300+
// SetSafeAttributePersistenceProvider to ensure the provider can leverage
301+
// the safe persistence provider for attribute persistence logic.
302+
// 2) It must occur after all low-level components that cluster implementations
303+
// might depend on have been initialized, as they rely on these components
304+
// during their own initialization.
305+
//
306+
// This remains the single point of entry to ensure that all cluster-level
307+
// initialization is performed in the correct order.
308+
app::InteractionModelEngine::GetInstance()->SetDataModelProvider(initParams.dataModelProvider);
307309

308310
#if defined(CHIP_APP_USE_ECHO)
309311
err = InitEchoHandler(&mExchangeMgr);

src/app/tests/TestCommissioningWindowManager.cpp

-3
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,6 @@ using chip::CommissioningWindowAdvertisement;
4141
using chip::CommissioningWindowManager;
4242
using chip::Server;
4343

44-
// Mock function for linking
45-
void InitDataModelHandler() {}
46-
4744
namespace {
4845
bool sAdminFabricIndexDirty = false;
4946
bool sAdminVendorIdDirty = false;

src/app/tests/TestInteractionModelEngine.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@
3939
#if CHIP_CONFIG_PERSIST_SUBSCRIPTIONS
4040
#include <app/SimpleSubscriptionResumptionStorage.h>
4141
#include <lib/support/TestPersistentStorageDelegate.h>
42-
4342
#endif // CHIP_CONFIG_PERSIST_SUBSCRIPTIONS
43+
4444
namespace {
4545

4646
class NullReadHandlerCallback : public chip::app::ReadHandler::ManagementCallback

src/app/tests/suites/TestUserLabelClusterConstraints.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -85,5 +85,5 @@ tests:
8585
]
8686
response:
8787
# When the cluster runs out of capacity to store these entries,
88-
# we expect a FAILURE get returned.
89-
error: FAILURE
88+
# we expect a RESOURCE_EXHAUSTED get returned.
89+
error: RESOURCE_EXHAUSTED

src/app/tests/test-ember-api.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,6 @@ uint16_t emberAfGetClusterServerEndpointIndex(chip::EndpointId endpoint, chip::C
3434
}
3535
return endpoint;
3636
}
37+
38+
// Mock function for linking
39+
void InitDataModelHandler() {}

src/controller/CHIPDeviceControllerFactory.cpp

+2-8
Original file line numberDiff line numberDiff line change
@@ -252,16 +252,10 @@ CHIP_ERROR DeviceControllerFactory::InitSystemState(FactoryInitParams params)
252252

253253
chip::app::InteractionModelEngine * interactionModelEngine = chip::app::InteractionModelEngine::GetInstance();
254254

255-
// Note placement of this BEFORE `InitDataModelHandler` since InitDataModelHandler may
256-
// rely on ember (does emberAfInit() and configure which may load data from NVM).
257-
//
258-
// Expected forward path is that we will move move and more things inside datamodel
259-
// provider (e.g. storage settings) so we want datamodelprovider available before
260-
// `InitDataModelHandler`.
255+
// Initialize the data model now that everything cluster implementations might
256+
// depend on is initalized.
261257
interactionModelEngine->SetDataModelProvider(params.dataModelProvider);
262258

263-
InitDataModelHandler();
264-
265259
ReturnErrorOnFailure(Dnssd::Resolver::Instance().Init(stateParams.udpEndPointManager));
266260

267261
if (params.enableServerInteractions)

src/controller/tests/TestServerCommandDispatch.cpp

+18
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,9 @@ CHIP_ERROR TestClusterCommandHandler::EnumerateAcceptedCommands(const ConcreteCl
126126

127127
namespace {
128128

129+
// TODO:(#36837) implementing its own provider instead of using "CodegenDataModelProvider"
130+
// TestServerCommandDispatch should provide its own dedicated data model provider rather than using CodegenDataModelProvider
131+
// provider. This class exists solely for one specific test scenario, on a temporary basis.
129132
class DispatchTestDataModel : public CodegenDataModelProvider
130133
{
131134
public:
@@ -134,6 +137,20 @@ class DispatchTestDataModel : public CodegenDataModelProvider
134137
static DispatchTestDataModel instance;
135138
return instance;
136139
}
140+
141+
// The Startup method initializes the data model provider with a given context.
142+
// This approach ensures that the test relies on a more controlled and explicit data model provider
143+
// rather than depending on the code-generated one with undefined modifications.
144+
CHIP_ERROR Startup(DataModel::InteractionModelContext context) override
145+
{
146+
ReturnErrorOnFailure(CodegenDataModelProvider::Startup(context));
147+
return CHIP_NO_ERROR;
148+
}
149+
150+
protected:
151+
// Since the current unit tests do not involve any cluster implementations, we override InitDataModelForTesting
152+
// to do nothing, thereby preventing calls to the Ember-specific InitDataModelHandler.
153+
void InitDataModelForTesting() override {}
137154
};
138155

139156
class TestServerCommandDispatch : public chip::Test::AppContext
@@ -144,6 +161,7 @@ class TestServerCommandDispatch : public chip::Test::AppContext
144161
AppContext::SetUp();
145162
mOldProvider = InteractionModelEngine::GetInstance()->SetDataModelProvider(&DispatchTestDataModel::Instance());
146163
}
164+
147165
void TearDown()
148166
{
149167
InteractionModelEngine::GetInstance()->SetDataModelProvider(mOldProvider);

src/controller/tests/data_model/DataModelFixtures.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ using namespace chip::app::Clusters;
4040
using namespace chip::app::Clusters::UnitTesting;
4141
using namespace chip::Protocols;
4242

43+
// Mock function for linking
44+
void InitDataModelHandler() {}
45+
4346
namespace chip {
4447
namespace app {
4548

src/data-model-providers/codegen/CodegenDataModelProvider.cpp

+9
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include <app/RequiredPrivilege.h>
2727
#include <app/data-model-provider/MetadataTypes.h>
2828
#include <app/data-model-provider/Provider.h>
29+
#include <app/util/DataModelHandler.h>
2930
#include <app/util/IMClusterCommandHandler.h>
3031
#include <app/util/af-types.h>
3132
#include <app/util/attribute-storage.h>
@@ -417,6 +418,8 @@ CHIP_ERROR CodegenDataModelProvider::Startup(DataModel::InteractionModelContext
417418
}
418419
}
419420

421+
InitDataModelForTesting();
422+
420423
return CHIP_NO_ERROR;
421424
}
422425

@@ -859,6 +862,12 @@ ConcreteCommandPath CodegenDataModelProvider::NextGeneratedCommand(const Concret
859862
return ConcreteCommandPath(before.mEndpointId, before.mClusterId, commandId);
860863
}
861864

865+
void CodegenDataModelProvider::InitDataModelForTesting()
866+
{
867+
// Call the Ember-specific InitDataModelHandler
868+
InitDataModelHandler();
869+
}
870+
862871
std::optional<DataModel::DeviceTypeEntry> CodegenDataModelProvider::FirstDeviceType(EndpointId endpoint)
863872
{
864873
// Use the `Index` version even though `emberAfDeviceTypeListFromEndpoint` would work because

0 commit comments

Comments
 (0)