Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/camera-webrtc-server' into camer…
Browse files Browse the repository at this point in the history
…a-webrtc-server
  • Loading branch information
gmarcosb committed Nov 11, 2024
2 parents 05c4b6a + f0f8867 commit 833e33a
Show file tree
Hide file tree
Showing 14 changed files with 152 additions and 87 deletions.
5 changes: 3 additions & 2 deletions examples/energy-management-app/linux/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,9 @@ data (e.g. fabric info).

## CHIP-REPL Interaction

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

### Building chip-repl:

Expand Down
8 changes: 2 additions & 6 deletions examples/energy-management-app/silabs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,14 @@ creating real products based on the Silicon Labs platform.
To build the Water Heater example you can change the args to gn gen (see
BUILD.gn for arg options)

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

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

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

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

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

or use gn as previously mentioned but adding the following arguments:

$ gn gen out/debug '--args=SILABS_BOARD="BRD4187C" enable_sleepy_device=true chip_openthread_ftd=false'

* Build the example with pigweed RPC

$ ./scripts/examples/gn_silabs_example.sh examples/energy-management-app/silabs/ out/energy_management_app_rpc BRD4187C 'import("//with_pw_rpc.gni")'
Expand Down
6 changes: 6 additions & 0 deletions examples/platform/linux/AppMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@
#if CHIP_DEVICE_CONFIG_ENABLE_DEVICE_ENERGY_MANAGEMENT_TRIGGER
#include <app/clusters/device-energy-management-server/DeviceEnergyManagementTestEventTriggerHandler.h>
#endif
#if CHIP_CONFIG_ENABLE_ICD_SERVER
#include <app/icd/server/ICDManager.h>
#endif
#include <app/TestEventTriggerDelegate.h>

#include <signal.h>
Expand Down Expand Up @@ -593,6 +596,9 @@ void ChipLinuxAppMainLoop(AppMainLoopImplementation * impl)
static DeviceEnergyManagementTestEventTriggerHandler sDeviceEnergyManagementTestEventTriggerHandler;
sTestEventTriggerDelegate.AddHandler(&sDeviceEnergyManagementTestEventTriggerHandler);
#endif
#if CHIP_CONFIG_ENABLE_ICD_SERVER
sTestEventTriggerDelegate.AddHandler(&Server::GetInstance().GetICDManager());
#endif

initParams.testEventTriggerDelegate = &sTestEventTriggerDelegate;

Expand Down
4 changes: 4 additions & 0 deletions examples/platform/linux/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import("//build_overrides/chip.gni")
import("${chip_root}/examples/common/pigweed/pigweed_rpcs.gni")
import("${chip_root}/src/app/common_flags.gni")
import("${chip_root}/src/app/icd/icd.gni")
import("${chip_root}/src/lib/core/core.gni")
import("${chip_root}/src/lib/lib.gni")
import("${chip_root}/src/tracing/tracing_args.gni")
Expand Down Expand Up @@ -133,6 +134,9 @@ source_set("app-main") {
"${chip_root}/src/tracing",
]
}
if (chip_enable_icd_server) {
deps += [ "${chip_root}/src/app/icd/server:manager" ]
}

defines += [
"CHIP_DEVICE_CONFIG_ENABLE_SMOKE_CO_TRIGGER=${chip_enable_smoke_co_trigger}",
Expand Down
67 changes: 5 additions & 62 deletions examples/platform/silabs/provision/ProvisionStorageDefault.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#include "AttestationKey.h"
#include "ProvisionStorage.h"
#include <credentials/examples/DeviceAttestationCredsExample.h>
#include <em_device.h>
#include <lib/support/BytesToHex.h>
#include <lib/support/CHIPMemString.h>
#include <lib/support/CodeUtils.h>
Expand All @@ -28,6 +27,7 @@
#include <platform/CHIPDeviceConfig.h>
#include <platform/silabs/MigrationManager.h>
#include <platform/silabs/SilabsConfig.h>
#include <platform/silabs/platformAbstraction/SilabsPlatform.h>
#include <silabs_creds.h>
#ifndef NDEBUG
#if defined(SL_MATTER_TEST_EVENT_TRIGGER_ENABLED) && (SL_MATTER_GN_BUILD == 0)
Expand All @@ -37,16 +37,7 @@
#ifdef OTA_ENCRYPTION_ENABLE
#include <platform/silabs/multi-ota/OtaTlvEncryptionKey.h>
#endif // OTA_ENCRYPTION_ENABLE
#ifdef SLI_SI91X_MCU_INTERFACE
#include <sl_si91x_common_flash_intf.h>
#else
#ifdef _SILICON_LABS_32B_SERIES_2
#include <em_msc.h>
#elif defined(_SILICON_LABS_32B_SERIES_3)
#include "sl_se_manager.h"
#include "sl_se_manager_types.h"
#include <sl_se_manager_extmem.h>
#endif // _SILICON_LABS_32B_SERIES_2
#ifndef SLI_SI91X_MCU_INTERFACE
#include <psa/crypto.h>
#endif

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

#if defined(_SILICON_LABS_32B_SERIES_3)
// To remove any ambiguities regarding the Flash aliases, use the below macro to ignore the 8 MSB.
#define FLASH_GENERIC_MASK 0x00FFFFFF
#define GENERIC_ADDRESS(addr) ((addr) &FLASH_GENERIC_MASK)

// Transforms any address into an address using the same alias as FLASH_BASE from the CMSIS.
#define CMSIS_CONVERTED_ADDRESS(addr) (GENERIC_ADDRESS(addr) | FLASH_BASE)
sl_se_command_context_t cmd_ctx;
#endif // _SILICON_LABS_32B_SERIES_3

extern uint8_t linker_nvm_end[];

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

CHIP_ERROR ErasePage(uint32_t addr)
{
#ifdef SLI_SI91X_MCU_INTERFACE
rsi_flash_erase_sector((uint32_t *) addr);
#elif defined(_SILICON_LABS_32B_SERIES_2)
MSC_ErasePage((uint32_t *) addr);
#elif defined(_SILICON_LABS_32B_SERIES_3)
sl_status_t status;
uint32_t * data_start = NULL;
size_t data_size;

status = sl_se_data_region_get_location(&cmd_ctx, (void **) &data_start, &data_size);
VerifyOrReturnError(status == SL_STATUS_OK, CHIP_ERROR(status));
VerifyOrReturnError(GENERIC_ADDRESS(addr) > GENERIC_ADDRESS((uint32_t) data_start), CHIP_ERROR_INVALID_ADDRESS);
status = sl_se_data_region_erase(&cmd_ctx, (void *) addr, 1); // Erase one page
VerifyOrReturnError(status == SL_STATUS_OK, CHIP_ERROR(status));
#endif
return CHIP_NO_ERROR;
return chip::DeviceLayer::Silabs::GetPlatform().FlashErasePage(addr);
}

CHIP_ERROR WritePage(uint32_t addr, const uint8_t * data, size_t size)
{
#ifdef SLI_SI91X_MCU_INTERFACE
rsi_flash_write((uint32_t *) addr, (unsigned char *) data, size);
#elif defined(_SILICON_LABS_32B_SERIES_2)
MSC_WriteWord((uint32_t *) addr, data, size);
#elif defined(_SILICON_LABS_32B_SERIES_3)
sl_status_t status;
uint32_t * data_start = NULL;
size_t data_size;

status = sl_se_data_region_get_location(&cmd_ctx, (void **) &data_start, &data_size);
VerifyOrReturnError(status == SL_STATUS_OK, CHIP_ERROR(status));
VerifyOrReturnError(GENERIC_ADDRESS(addr) > GENERIC_ADDRESS((uint32_t) data_start), CHIP_ERROR_INVALID_ADDRESS);
status = sl_se_data_region_write(&cmd_ctx, (void *) addr, data, size);
VerifyOrReturnError(status == SL_STATUS_OK, CHIP_ERROR(status));
#endif
return CHIP_NO_ERROR;
return chip::DeviceLayer::Silabs::GetPlatform().FlashWritePage(addr, data, size);
}

size_t RoundNearest(size_t n, size_t multiple)
Expand Down Expand Up @@ -203,16 +154,8 @@ CHIP_ERROR Storage::Initialize(uint32_t flash_addr, uint32_t flash_size)
{
#ifndef SLI_SI91X_MCU_INTERFACE
base_addr = (flash_addr + flash_size - FLASH_PAGE_SIZE);

#ifdef _SILICON_LABS_32B_SERIES_2
MSC_Init();
#elif defined(_SILICON_LABS_32B_SERIES_3)
sl_status_t status;
status = sl_se_init();
VerifyOrReturnError(status == SL_STATUS_OK, CHIP_ERROR_INTERNAL);
status = sl_se_init_command_context(&cmd_ctx);
#endif // _SILICON_LABS_32B_SERIES
#endif // SLI_SI91X_MCU_INTERFACE
chip::DeviceLayer::Silabs::GetPlatform().FlashInit();
#ifdef SL_PROVISION_GENERATOR
setNvm3End(base_addr);
#endif
Expand Down
2 changes: 1 addition & 1 deletion scripts/tests/cirque_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ CIRQUE_TESTS=(
"FailsafeTest"
"MobileDeviceTest"
"CommissioningTest"
"IcdWaitForActiveTest"
"IcdDeviceTest"
"SplitCommissioningTest"
"CommissioningFailureTest"
"CommissioningFailureOnReportTest"
Expand Down
6 changes: 3 additions & 3 deletions src/app/tests/suites/certification/Test_TC_DEMM_1_2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ tests:
- Verify that each ModeOptionsStruct entry’s ModeTags field has:
at least one entry the values of the Value fields that are not larger than 16 bits
- 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
- 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)
- Verify that at least one ModeOptionsStruct entry includes either the RapidCool semantic tag or the RapidFreeze semantic tag in the SemanticTags field
- 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)
- Verify that at least one SupportedModes entry includes the No Optimization mode tag or Local Optimization mode tag or Grid Optimization mode tag.
- 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.
- 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:
[1705923890.093456][23589:23591] CHIP:DMG: }
[1705923890.094137][23589:23591] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_009F Attribute 0x0000_0000 DataVersion: 2217281174
[1705923890.094312][23589:23591] CHIP:TOO: SupportedModes: 5 entries
Expand Down
6 changes: 3 additions & 3 deletions src/controller/python/test/test_scripts/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1159,18 +1159,18 @@ def TestResolve(self, nodeid):
return False

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

async def TestWaitForActive(self, nodeid):
async def TestWaitForActive(self, nodeid, stayActiveDurationMs=30000):
self.logger.info("Test wait for device = %08x", nodeid)
try:
await self.devCtrl.WaitForActive(nodeid)
await self.devCtrl.WaitForActive(nodeid, stayActiveDurationMs=stayActiveDurationMs)
return True
except Exception as ex:
self.logger.exception("Failed to wait for active. {}".format(ex))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,15 @@


async def waitForActiveAndTriggerCheckIn(test, nodeid):
coro = test.TestWaitForActive(nodeid=nodeid)
await test.TestTriggerTestEventHandler(nodeid, bytes.fromhex("00112233445566778899aabbccddeeff"), 0x0046 << 48)
coro = test.TestWaitForActive(nodeid=nodeid, stayActiveDurationMs=10)
return await coro


async def invalidateHalfCounterValuesAndWaitForCheckIn(test, nodeid, testEventKey):
await test.TestTriggerTestEventHandler(nodeid, bytes.fromhex(testEventKey), 0x0046_0000_0000_0003)
return await waitForActiveAndTriggerCheckIn(test, nodeid)


async def main():
optParser = OptionParser()
optParser.add_option(
Expand Down Expand Up @@ -108,6 +112,15 @@ async def main():
help="Discovery type of commissioning. (0: networkOnly 1: networkOnlyWithoutPASEAutoRetry 2: All<Ble & Network>)",
metavar="<discovery-type>"
)
optParser.add_option(
"--test-event-key",
action="store",
dest="testEventKey",
default="00112233445566778899aabbccddeeff",
type=str,
help="Enable key of Test event trigger.",
metavar="<test-event-key>"
)

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

Expand All @@ -125,9 +138,14 @@ async def main():
nodeid=options.nodeid),
"Failed to finish key exchange")
logger.info("Commissioning completed")

logger.info("Testing wait for active")
FailIfNot(await waitForActiveAndTriggerCheckIn(test, nodeid=options.nodeid), "Failed to test wait for active")
logger.info('Successfully handled wait-for-active')
logger.info("Successfully handled wait-for-active")

logger.info("Testing InvalidateHalfCounterValues for refresh key")
FailIfNot(await invalidateHalfCounterValuesAndWaitForCheckIn(test, nodeid=options.nodeid, testEventKey=options.testEventKey), "Failed to test wait for active")
logger.info("Successfully handled key refresh")

timeoutTicker.stop()

Expand Down
71 changes: 69 additions & 2 deletions src/platform/silabs/platformAbstraction/GsdkSpam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,17 @@
* limitations under the License.
*/

#include <em_device.h>
#include <lib/support/CodeUtils.h>
#include <platform/silabs/platformAbstraction/SilabsPlatform.h>

#if defined(_SILICON_LABS_32B_SERIES_2)
#include "em_msc.h"
#include "em_rmu.h"
#else
#elif defined(_SILICON_LABS_32B_SERIES_3)
#include "sl_hal_emu.h"
#include "sl_se_manager.h"
#include "sl_se_manager_types.h"
#include <sl_se_manager_extmem.h>
#endif // _SILICON_LABS_32B_SERIES_2
#include "sl_system_kernel.h"

Expand Down Expand Up @@ -65,6 +70,18 @@ extern "C" {
#include "silabs_utils.h"
#endif

#if defined(_SILICON_LABS_32B_SERIES_3)
// To remove any ambiguities regarding the Flash aliases, use the below macro to ignore the 8 MSB.
#define FLASH_GENERIC_MASK 0x00FFFFFF
#define GENERIC_ADDRESS(addr) ((addr) &FLASH_GENERIC_MASK)

// Transforms any address into an address using the same alias as FLASH_BASE from the CMSIS.
#define CMSIS_CONVERTED_ADDRESS(addr) (GENERIC_ADDRESS(addr) | FLASH_BASE)
namespace {
sl_se_command_context_t cmd_ctx;
}
#endif // _SILICON_LABS_32B_SERIES_3

namespace chip {
namespace DeviceLayer {
namespace Silabs {
Expand Down Expand Up @@ -107,6 +124,56 @@ CHIP_ERROR SilabsPlatform::Init(void)
return CHIP_NO_ERROR;
}

CHIP_ERROR SilabsPlatform::FlashInit()
{
#if defined(_SILICON_LABS_32B_SERIES_2)
MSC_Init();
#elif defined(_SILICON_LABS_32B_SERIES_3)
sl_status_t status;
status = sl_se_init();
VerifyOrReturnError(status == SL_STATUS_OK, CHIP_ERROR(status));
status = sl_se_init_command_context(&cmd_ctx);
VerifyOrReturnError(status == SL_STATUS_OK, CHIP_ERROR(status));
#endif
return CHIP_NO_ERROR;
}

CHIP_ERROR SilabsPlatform::FlashErasePage(uint32_t addr)
{
#if defined(_SILICON_LABS_32B_SERIES_2)
MSC_ErasePage((uint32_t *) addr);
#elif defined(_SILICON_LABS_32B_SERIES_3)
sl_status_t status;
uint32_t * data_start = NULL;
size_t data_size;

status = sl_se_data_region_get_location(&cmd_ctx, (void **) &data_start, &data_size);
VerifyOrReturnError(status == SL_STATUS_OK, CHIP_ERROR(status));
VerifyOrReturnError(GENERIC_ADDRESS(addr) > GENERIC_ADDRESS((uint32_t) data_start), CHIP_ERROR_INVALID_ADDRESS);
status = sl_se_data_region_erase(&cmd_ctx, (void *) addr, 1); // Erase one page
VerifyOrReturnError(status == SL_STATUS_OK, CHIP_ERROR(status));
#endif
return CHIP_NO_ERROR;
}

CHIP_ERROR SilabsPlatform::FlashWritePage(uint32_t addr, const uint8_t * data, size_t size)
{
#if defined(_SILICON_LABS_32B_SERIES_2)
MSC_WriteWord((uint32_t *) addr, data, size);
#elif defined(_SILICON_LABS_32B_SERIES_3)
sl_status_t status;
uint32_t * data_start = NULL;
size_t data_size;

status = sl_se_data_region_get_location(&cmd_ctx, (void **) &data_start, &data_size);
VerifyOrReturnError(status == SL_STATUS_OK, CHIP_ERROR(status));
VerifyOrReturnError(GENERIC_ADDRESS(addr) > GENERIC_ADDRESS((uint32_t) data_start), CHIP_ERROR_INVALID_ADDRESS);
status = sl_se_data_region_write(&cmd_ctx, (void *) addr, data, size);
VerifyOrReturnError(status == SL_STATUS_OK, CHIP_ERROR(status));
#endif
return CHIP_NO_ERROR;
}

#ifdef ENABLE_WSTK_LEDS
void SilabsPlatform::InitLed(void)
{
Expand Down
4 changes: 4 additions & 0 deletions src/platform/silabs/platformAbstraction/SilabsPlatform.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ class SilabsPlatform : virtual public SilabsPlatformAbstractionBase

void StartScheduler(void) override;

CHIP_ERROR FlashInit() override;
CHIP_ERROR FlashErasePage(uint32_t addr) override;
CHIP_ERROR FlashWritePage(uint32_t addr, const uint8_t * data, size_t size) override;

private:
friend SilabsPlatform & GetPlatform(void);

Expand Down
Loading

0 comments on commit 833e33a

Please sign in to comment.