Skip to content

Commit 833e33a

Browse files
committed
Merge remote-tracking branch 'origin/camera-webrtc-server' into camera-webrtc-server
2 parents 05c4b6a + f0f8867 commit 833e33a

File tree

14 files changed

+152
-87
lines changed

14 files changed

+152
-87
lines changed

examples/energy-management-app/linux/README.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,9 @@ data (e.g. fabric info).
239239

240240
## CHIP-REPL Interaction
241241

242-
- See chip-repl documentation in
243-
[Matter_REPL_Intro](../../../docs/development_controllers/chip-repl/Matter_REPL_Intro.ipynb)
242+
- See chip-repl documentation in:
243+
- [Working with Python CHIP Controller](../../../docs/development_controllers/chip-repl/python_chip_controller_building.md)
244+
- [Matter_REPL_Intro](../../../docs/development_controllers/chip-repl/Matter_REPL_Intro.ipynb)
244245

245246
### Building chip-repl:
246247

examples/energy-management-app/silabs/README.md

+2-6
Original file line numberDiff line numberDiff line change
@@ -108,14 +108,14 @@ creating real products based on the Silicon Labs platform.
108108
To build the Water Heater example you can change the args to gn gen (see
109109
BUILD.gn for arg options)
110110

111-
$ gn gen out/debug --args='chip_enable_example_evse_device=false chip_enable_example_water_heater_device=true'
111+
$ gn gen out/debug --args='sl_enable_example_evse_device=false sl_enable_example_water_heater_device=true'
112112
$ ninja -C out/debug
113113

114114
To change Device Energy Management feature support (e.g. Power forecast or
115115
State forecast reporting), you can change the args to gn gen (see BUILD.gn
116116
for arg options)
117117

118-
$ gn gen out/debug --args='chip_dem_support_state_forecast_reporting=true chip_dem_support_power_forecast_reporting=false'
118+
$ gn gen out/debug --args='sl_dem_support_state_forecast_reporting=true sl_dem_support_power_forecast_reporting=false'
119119
$ ninja -C out/debug
120120

121121
- To delete generated executable, libraries and object files use:
@@ -127,10 +127,6 @@ creating real products based on the Silicon Labs platform.
127127

128128
$ ./scripts/examples/gn_silabs_example.sh ./examples/energy-management-app/silabs/ ./out/energy-management-app_ICD BRD4187C --icd
129129

130-
or use gn as previously mentioned but adding the following arguments:
131-
132-
$ gn gen out/debug '--args=SILABS_BOARD="BRD4187C" enable_sleepy_device=true chip_openthread_ftd=false'
133-
134130
* Build the example with pigweed RPC
135131

136132
$ ./scripts/examples/gn_silabs_example.sh examples/energy-management-app/silabs/ out/energy_management_app_rpc BRD4187C 'import("//with_pw_rpc.gni")'

examples/platform/linux/AppMain.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@
9696
#if CHIP_DEVICE_CONFIG_ENABLE_DEVICE_ENERGY_MANAGEMENT_TRIGGER
9797
#include <app/clusters/device-energy-management-server/DeviceEnergyManagementTestEventTriggerHandler.h>
9898
#endif
99+
#if CHIP_CONFIG_ENABLE_ICD_SERVER
100+
#include <app/icd/server/ICDManager.h>
101+
#endif
99102
#include <app/TestEventTriggerDelegate.h>
100103

101104
#include <signal.h>
@@ -593,6 +596,9 @@ void ChipLinuxAppMainLoop(AppMainLoopImplementation * impl)
593596
static DeviceEnergyManagementTestEventTriggerHandler sDeviceEnergyManagementTestEventTriggerHandler;
594597
sTestEventTriggerDelegate.AddHandler(&sDeviceEnergyManagementTestEventTriggerHandler);
595598
#endif
599+
#if CHIP_CONFIG_ENABLE_ICD_SERVER
600+
sTestEventTriggerDelegate.AddHandler(&Server::GetInstance().GetICDManager());
601+
#endif
596602

597603
initParams.testEventTriggerDelegate = &sTestEventTriggerDelegate;
598604

examples/platform/linux/BUILD.gn

+4
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import("//build_overrides/chip.gni")
1616
import("${chip_root}/examples/common/pigweed/pigweed_rpcs.gni")
1717
import("${chip_root}/src/app/common_flags.gni")
18+
import("${chip_root}/src/app/icd/icd.gni")
1819
import("${chip_root}/src/lib/core/core.gni")
1920
import("${chip_root}/src/lib/lib.gni")
2021
import("${chip_root}/src/tracing/tracing_args.gni")
@@ -133,6 +134,9 @@ source_set("app-main") {
133134
"${chip_root}/src/tracing",
134135
]
135136
}
137+
if (chip_enable_icd_server) {
138+
deps += [ "${chip_root}/src/app/icd/server:manager" ]
139+
}
136140

137141
defines += [
138142
"CHIP_DEVICE_CONFIG_ENABLE_SMOKE_CO_TRIGGER=${chip_enable_smoke_co_trigger}",

examples/platform/silabs/provision/ProvisionStorageDefault.cpp

+5-62
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
#include "AttestationKey.h"
1818
#include "ProvisionStorage.h"
1919
#include <credentials/examples/DeviceAttestationCredsExample.h>
20-
#include <em_device.h>
2120
#include <lib/support/BytesToHex.h>
2221
#include <lib/support/CHIPMemString.h>
2322
#include <lib/support/CodeUtils.h>
@@ -28,6 +27,7 @@
2827
#include <platform/CHIPDeviceConfig.h>
2928
#include <platform/silabs/MigrationManager.h>
3029
#include <platform/silabs/SilabsConfig.h>
30+
#include <platform/silabs/platformAbstraction/SilabsPlatform.h>
3131
#include <silabs_creds.h>
3232
#ifndef NDEBUG
3333
#if defined(SL_MATTER_TEST_EVENT_TRIGGER_ENABLED) && (SL_MATTER_GN_BUILD == 0)
@@ -37,16 +37,7 @@
3737
#ifdef OTA_ENCRYPTION_ENABLE
3838
#include <platform/silabs/multi-ota/OtaTlvEncryptionKey.h>
3939
#endif // OTA_ENCRYPTION_ENABLE
40-
#ifdef SLI_SI91X_MCU_INTERFACE
41-
#include <sl_si91x_common_flash_intf.h>
42-
#else
43-
#ifdef _SILICON_LABS_32B_SERIES_2
44-
#include <em_msc.h>
45-
#elif defined(_SILICON_LABS_32B_SERIES_3)
46-
#include "sl_se_manager.h"
47-
#include "sl_se_manager_types.h"
48-
#include <sl_se_manager_extmem.h>
49-
#endif // _SILICON_LABS_32B_SERIES_2
40+
#ifndef SLI_SI91X_MCU_INTERFACE
5041
#include <psa/crypto.h>
5142
#endif
5243

@@ -56,16 +47,6 @@ extern void setNvm3End(uint32_t addr);
5647
#include <sl_matter_provision_config.h>
5748
#endif
5849

59-
#if defined(_SILICON_LABS_32B_SERIES_3)
60-
// To remove any ambiguities regarding the Flash aliases, use the below macro to ignore the 8 MSB.
61-
#define FLASH_GENERIC_MASK 0x00FFFFFF
62-
#define GENERIC_ADDRESS(addr) ((addr) &FLASH_GENERIC_MASK)
63-
64-
// Transforms any address into an address using the same alias as FLASH_BASE from the CMSIS.
65-
#define CMSIS_CONVERTED_ADDRESS(addr) (GENERIC_ADDRESS(addr) | FLASH_BASE)
66-
sl_se_command_context_t cmd_ctx;
67-
#endif // _SILICON_LABS_32B_SERIES_3
68-
6950
extern uint8_t linker_nvm_end[];
7051

7152
using namespace chip::Credentials;
@@ -86,42 +67,12 @@ size_t sCredentialsOffset = 0;
8667

8768
CHIP_ERROR ErasePage(uint32_t addr)
8869
{
89-
#ifdef SLI_SI91X_MCU_INTERFACE
90-
rsi_flash_erase_sector((uint32_t *) addr);
91-
#elif defined(_SILICON_LABS_32B_SERIES_2)
92-
MSC_ErasePage((uint32_t *) addr);
93-
#elif defined(_SILICON_LABS_32B_SERIES_3)
94-
sl_status_t status;
95-
uint32_t * data_start = NULL;
96-
size_t data_size;
97-
98-
status = sl_se_data_region_get_location(&cmd_ctx, (void **) &data_start, &data_size);
99-
VerifyOrReturnError(status == SL_STATUS_OK, CHIP_ERROR(status));
100-
VerifyOrReturnError(GENERIC_ADDRESS(addr) > GENERIC_ADDRESS((uint32_t) data_start), CHIP_ERROR_INVALID_ADDRESS);
101-
status = sl_se_data_region_erase(&cmd_ctx, (void *) addr, 1); // Erase one page
102-
VerifyOrReturnError(status == SL_STATUS_OK, CHIP_ERROR(status));
103-
#endif
104-
return CHIP_NO_ERROR;
70+
return chip::DeviceLayer::Silabs::GetPlatform().FlashErasePage(addr);
10571
}
10672

10773
CHIP_ERROR WritePage(uint32_t addr, const uint8_t * data, size_t size)
10874
{
109-
#ifdef SLI_SI91X_MCU_INTERFACE
110-
rsi_flash_write((uint32_t *) addr, (unsigned char *) data, size);
111-
#elif defined(_SILICON_LABS_32B_SERIES_2)
112-
MSC_WriteWord((uint32_t *) addr, data, size);
113-
#elif defined(_SILICON_LABS_32B_SERIES_3)
114-
sl_status_t status;
115-
uint32_t * data_start = NULL;
116-
size_t data_size;
117-
118-
status = sl_se_data_region_get_location(&cmd_ctx, (void **) &data_start, &data_size);
119-
VerifyOrReturnError(status == SL_STATUS_OK, CHIP_ERROR(status));
120-
VerifyOrReturnError(GENERIC_ADDRESS(addr) > GENERIC_ADDRESS((uint32_t) data_start), CHIP_ERROR_INVALID_ADDRESS);
121-
status = sl_se_data_region_write(&cmd_ctx, (void *) addr, data, size);
122-
VerifyOrReturnError(status == SL_STATUS_OK, CHIP_ERROR(status));
123-
#endif
124-
return CHIP_NO_ERROR;
75+
return chip::DeviceLayer::Silabs::GetPlatform().FlashWritePage(addr, data, size);
12576
}
12677

12778
size_t RoundNearest(size_t n, size_t multiple)
@@ -203,16 +154,8 @@ CHIP_ERROR Storage::Initialize(uint32_t flash_addr, uint32_t flash_size)
203154
{
204155
#ifndef SLI_SI91X_MCU_INTERFACE
205156
base_addr = (flash_addr + flash_size - FLASH_PAGE_SIZE);
206-
207-
#ifdef _SILICON_LABS_32B_SERIES_2
208-
MSC_Init();
209-
#elif defined(_SILICON_LABS_32B_SERIES_3)
210-
sl_status_t status;
211-
status = sl_se_init();
212-
VerifyOrReturnError(status == SL_STATUS_OK, CHIP_ERROR_INTERNAL);
213-
status = sl_se_init_command_context(&cmd_ctx);
214-
#endif // _SILICON_LABS_32B_SERIES
215157
#endif // SLI_SI91X_MCU_INTERFACE
158+
chip::DeviceLayer::Silabs::GetPlatform().FlashInit();
216159
#ifdef SL_PROVISION_GENERATOR
217160
setNvm3End(base_addr);
218161
#endif

scripts/tests/cirque_tests.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ CIRQUE_TESTS=(
4848
"FailsafeTest"
4949
"MobileDeviceTest"
5050
"CommissioningTest"
51-
"IcdWaitForActiveTest"
51+
"IcdDeviceTest"
5252
"SplitCommissioningTest"
5353
"CommissioningFailureTest"
5454
"CommissioningFailureOnReportTest"

src/app/tests/suites/certification/Test_TC_DEMM_1_2.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ tests:
3636
- Verify that each ModeOptionsStruct entry’s ModeTags field has:
3737
at least one entry the values of the Value fields that are not larger than 16 bits
3838
- for each Value field: Is the mode tag value a defined common tag value (Auto(0x0000), Quick(0x0001), Quiet(0x0002), LowNoise(0x0003), LowEnergy(0x0004), Vacation(0x0005), Min(0x0006), Max(0x0007), Night(0x0008), Day(0x0009)) or a defined cluster-derived tag value (No Optimization, Device Optimization, Local Optimization, Grid Optimization) or in the MfgTags (0x8000 to 0xBFFF) range
39-
- for at least one Value field: Is the mode tag value a defined common tag value (Auto(0x0000), Quick(0x0001), Quiet(0x0002), LowNoise(0x0003), LowEnergy(0x0004), Vacation(0x0005), Min(0x0006), Max(0x0007), Night(0x0008), Day(0x0009)) or a derived cluster value (RapidCool, RapidFreeze)
40-
- Verify that at least one ModeOptionsStruct entry includes either the RapidCool semantic tag or the RapidFreeze semantic tag in the SemanticTags field
39+
- for at least one Value field: Is the mode tag value a defined common tag value (Auto(0x0000), Quick(0x0001), Quiet(0x0002), LowNoise(0x0003), LowEnergy(0x0004), Vacation(0x0005), Min(0x0006), Max(0x0007), Night(0x0008), Day(0x0009)) or a derived cluster value (No Optimization, Device Optimization, Local Optimization, Grid Optimization)
40+
- Verify that at least one SupportedModes entry includes the No Optimization mode tag or Local Optimization mode tag or Grid Optimization mode tag.
41+
- Verify that an entry in the SupportedModes attribute that include one of Device Optimization, Local Optimization, Grid Optimization does not also include No Optimization mode tag.
4142
- Save the Mode field values as supported_modes_dut on the TH (Chip-tool) and below is the sample log provided for the raspi platform:
4243
43-
4444
[1705923890.093456][23589:23591] CHIP:DMG: }
4545
[1705923890.094137][23589:23591] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_009F Attribute 0x0000_0000 DataVersion: 2217281174
4646
[1705923890.094312][23589:23591] CHIP:TOO: SupportedModes: 5 entries

src/controller/python/test/test_scripts/base.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1159,18 +1159,18 @@ def TestResolve(self, nodeid):
11591159
return False
11601160

11611161
async def TestTriggerTestEventHandler(self, nodeid, enable_key, event_trigger):
1162-
self.logger.info("Test trigger test event handler for device = %08x", nodeid)
1162+
self.logger.info("Test trigger test event handler for device = %08x trigger = %016x", nodeid, event_trigger)
11631163
try:
11641164
await self.devCtrl.SendCommand(nodeid, 0, Clusters.GeneralDiagnostics.Commands.TestEventTrigger(enableKey=enable_key, eventTrigger=event_trigger))
11651165
return True
11661166
except Exception as ex:
11671167
self.logger.exception("Failed to trigger test event handler {}".format(ex))
11681168
return False
11691169

1170-
async def TestWaitForActive(self, nodeid):
1170+
async def TestWaitForActive(self, nodeid, stayActiveDurationMs=30000):
11711171
self.logger.info("Test wait for device = %08x", nodeid)
11721172
try:
1173-
await self.devCtrl.WaitForActive(nodeid)
1173+
await self.devCtrl.WaitForActive(nodeid, stayActiveDurationMs=stayActiveDurationMs)
11741174
return True
11751175
except Exception as ex:
11761176
self.logger.exception("Failed to wait for active. {}".format(ex))

src/controller/python/test/test_scripts/icd_wait_for_device_test.py src/controller/python/test/test_scripts/icd_device_test.py

+21-3
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,15 @@
3535

3636

3737
async def waitForActiveAndTriggerCheckIn(test, nodeid):
38-
coro = test.TestWaitForActive(nodeid=nodeid)
39-
await test.TestTriggerTestEventHandler(nodeid, bytes.fromhex("00112233445566778899aabbccddeeff"), 0x0046 << 48)
38+
coro = test.TestWaitForActive(nodeid=nodeid, stayActiveDurationMs=10)
4039
return await coro
4140

4241

42+
async def invalidateHalfCounterValuesAndWaitForCheckIn(test, nodeid, testEventKey):
43+
await test.TestTriggerTestEventHandler(nodeid, bytes.fromhex(testEventKey), 0x0046_0000_0000_0003)
44+
return await waitForActiveAndTriggerCheckIn(test, nodeid)
45+
46+
4347
async def main():
4448
optParser = OptionParser()
4549
optParser.add_option(
@@ -108,6 +112,15 @@ async def main():
108112
help="Discovery type of commissioning. (0: networkOnly 1: networkOnlyWithoutPASEAutoRetry 2: All<Ble & Network>)",
109113
metavar="<discovery-type>"
110114
)
115+
optParser.add_option(
116+
"--test-event-key",
117+
action="store",
118+
dest="testEventKey",
119+
default="00112233445566778899aabbccddeeff",
120+
type=str,
121+
help="Enable key of Test event trigger.",
122+
metavar="<test-event-key>"
123+
)
111124

112125
(options, remainingArgs) = optParser.parse_args(sys.argv[1:])
113126

@@ -125,9 +138,14 @@ async def main():
125138
nodeid=options.nodeid),
126139
"Failed to finish key exchange")
127140
logger.info("Commissioning completed")
141+
128142
logger.info("Testing wait for active")
129143
FailIfNot(await waitForActiveAndTriggerCheckIn(test, nodeid=options.nodeid), "Failed to test wait for active")
130-
logger.info('Successfully handled wait-for-active')
144+
logger.info("Successfully handled wait-for-active")
145+
146+
logger.info("Testing InvalidateHalfCounterValues for refresh key")
147+
FailIfNot(await invalidateHalfCounterValuesAndWaitForCheckIn(test, nodeid=options.nodeid, testEventKey=options.testEventKey), "Failed to test wait for active")
148+
logger.info("Successfully handled key refresh")
131149

132150
timeoutTicker.stop()
133151

src/platform/silabs/platformAbstraction/GsdkSpam.cpp

+69-2
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,17 @@
1515
* limitations under the License.
1616
*/
1717

18+
#include <em_device.h>
19+
#include <lib/support/CodeUtils.h>
1820
#include <platform/silabs/platformAbstraction/SilabsPlatform.h>
19-
2021
#if defined(_SILICON_LABS_32B_SERIES_2)
22+
#include "em_msc.h"
2123
#include "em_rmu.h"
22-
#else
24+
#elif defined(_SILICON_LABS_32B_SERIES_3)
2325
#include "sl_hal_emu.h"
26+
#include "sl_se_manager.h"
27+
#include "sl_se_manager_types.h"
28+
#include <sl_se_manager_extmem.h>
2429
#endif // _SILICON_LABS_32B_SERIES_2
2530
#include "sl_system_kernel.h"
2631

@@ -65,6 +70,18 @@ extern "C" {
6570
#include "silabs_utils.h"
6671
#endif
6772

73+
#if defined(_SILICON_LABS_32B_SERIES_3)
74+
// To remove any ambiguities regarding the Flash aliases, use the below macro to ignore the 8 MSB.
75+
#define FLASH_GENERIC_MASK 0x00FFFFFF
76+
#define GENERIC_ADDRESS(addr) ((addr) &FLASH_GENERIC_MASK)
77+
78+
// Transforms any address into an address using the same alias as FLASH_BASE from the CMSIS.
79+
#define CMSIS_CONVERTED_ADDRESS(addr) (GENERIC_ADDRESS(addr) | FLASH_BASE)
80+
namespace {
81+
sl_se_command_context_t cmd_ctx;
82+
}
83+
#endif // _SILICON_LABS_32B_SERIES_3
84+
6885
namespace chip {
6986
namespace DeviceLayer {
7087
namespace Silabs {
@@ -107,6 +124,56 @@ CHIP_ERROR SilabsPlatform::Init(void)
107124
return CHIP_NO_ERROR;
108125
}
109126

127+
CHIP_ERROR SilabsPlatform::FlashInit()
128+
{
129+
#if defined(_SILICON_LABS_32B_SERIES_2)
130+
MSC_Init();
131+
#elif defined(_SILICON_LABS_32B_SERIES_3)
132+
sl_status_t status;
133+
status = sl_se_init();
134+
VerifyOrReturnError(status == SL_STATUS_OK, CHIP_ERROR(status));
135+
status = sl_se_init_command_context(&cmd_ctx);
136+
VerifyOrReturnError(status == SL_STATUS_OK, CHIP_ERROR(status));
137+
#endif
138+
return CHIP_NO_ERROR;
139+
}
140+
141+
CHIP_ERROR SilabsPlatform::FlashErasePage(uint32_t addr)
142+
{
143+
#if defined(_SILICON_LABS_32B_SERIES_2)
144+
MSC_ErasePage((uint32_t *) addr);
145+
#elif defined(_SILICON_LABS_32B_SERIES_3)
146+
sl_status_t status;
147+
uint32_t * data_start = NULL;
148+
size_t data_size;
149+
150+
status = sl_se_data_region_get_location(&cmd_ctx, (void **) &data_start, &data_size);
151+
VerifyOrReturnError(status == SL_STATUS_OK, CHIP_ERROR(status));
152+
VerifyOrReturnError(GENERIC_ADDRESS(addr) > GENERIC_ADDRESS((uint32_t) data_start), CHIP_ERROR_INVALID_ADDRESS);
153+
status = sl_se_data_region_erase(&cmd_ctx, (void *) addr, 1); // Erase one page
154+
VerifyOrReturnError(status == SL_STATUS_OK, CHIP_ERROR(status));
155+
#endif
156+
return CHIP_NO_ERROR;
157+
}
158+
159+
CHIP_ERROR SilabsPlatform::FlashWritePage(uint32_t addr, const uint8_t * data, size_t size)
160+
{
161+
#if defined(_SILICON_LABS_32B_SERIES_2)
162+
MSC_WriteWord((uint32_t *) addr, data, size);
163+
#elif defined(_SILICON_LABS_32B_SERIES_3)
164+
sl_status_t status;
165+
uint32_t * data_start = NULL;
166+
size_t data_size;
167+
168+
status = sl_se_data_region_get_location(&cmd_ctx, (void **) &data_start, &data_size);
169+
VerifyOrReturnError(status == SL_STATUS_OK, CHIP_ERROR(status));
170+
VerifyOrReturnError(GENERIC_ADDRESS(addr) > GENERIC_ADDRESS((uint32_t) data_start), CHIP_ERROR_INVALID_ADDRESS);
171+
status = sl_se_data_region_write(&cmd_ctx, (void *) addr, data, size);
172+
VerifyOrReturnError(status == SL_STATUS_OK, CHIP_ERROR(status));
173+
#endif
174+
return CHIP_NO_ERROR;
175+
}
176+
110177
#ifdef ENABLE_WSTK_LEDS
111178
void SilabsPlatform::InitLed(void)
112179
{

src/platform/silabs/platformAbstraction/SilabsPlatform.h

+4
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ class SilabsPlatform : virtual public SilabsPlatformAbstractionBase
5757

5858
void StartScheduler(void) override;
5959

60+
CHIP_ERROR FlashInit() override;
61+
CHIP_ERROR FlashErasePage(uint32_t addr) override;
62+
CHIP_ERROR FlashWritePage(uint32_t addr, const uint8_t * data, size_t size) override;
63+
6064
private:
6165
friend SilabsPlatform & GetPlatform(void);
6266

0 commit comments

Comments
 (0)