Pull request #11: Provisioning series 3 (#35733)
Merge in WMN_TOOLS/matter_sdk from feature/provisioning_api_series3 to feature/rainier-ifc2
Squashed commit of the following:
commit 0f219b792349f77756e33fe820fdb549376bb146
Author: lpbeliveau-silabs <louis-philip.beliveau@silabs.com>
Date: Tue Sep 10 14:14:52 2024 -0400
Added series 3 API to replace MSC and updated to support series3 flash api
diff --git a/examples/platform/silabs/provision/ProvisionStorageDefault.cpp b/examples/platform/silabs/provision/ProvisionStorageDefault.cpp
index 801eb9e..6a889b5 100644
--- a/examples/platform/silabs/provision/ProvisionStorageDefault.cpp
+++ b/examples/platform/silabs/provision/ProvisionStorageDefault.cpp
@@ -17,6 +17,7 @@
#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>
@@ -34,7 +35,13 @@
#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
#include <psa/crypto.h>
#endif
@@ -44,6 +51,16 @@
#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;
@@ -66,8 +83,18 @@
{
#ifdef SLI_SI91X_MCU_INTERFACE
rsi_flash_erase_sector((uint32_t *) addr);
-#else
+#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;
}
@@ -76,8 +103,18 @@
{
#ifdef SLI_SI91X_MCU_INTERFACE
rsi_flash_write((uint32_t *) addr, (unsigned char *) data, size);
-#else
+#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;
}
@@ -161,7 +198,15 @@
{
#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
#ifdef SL_PROVISION_GENERATOR
setNvm3End(base_addr);
diff --git a/src/platform/silabs/platformAbstraction/GsdkSpam.cpp b/src/platform/silabs/platformAbstraction/GsdkSpam.cpp
index eb8704e..92ddd28 100644
--- a/src/platform/silabs/platformAbstraction/GsdkSpam.cpp
+++ b/src/platform/silabs/platformAbstraction/GsdkSpam.cpp
@@ -21,7 +21,7 @@
#include "em_rmu.h"
#else
#include "sl_hal_emu.h"
-#endif
+#endif // _SILICON_LABS_32B_SERIES_2
#include "sl_system_kernel.h"
#ifdef ENABLE_WSTK_LEDS