Skip to content

Commit

Permalink
Fix si917 init failure due to missing platform defines. Support facto…
Browse files Browse the repository at this point in the history
…ry provisioning with PSA for si917 (#34197)
  • Loading branch information
jmartinez-silabs authored Jul 5, 2024
1 parent fc52c4a commit 3761447
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 25 deletions.
7 changes: 6 additions & 1 deletion examples/platform/silabs/SiWx917/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,12 @@ source_set("siwx917-matter-shell") {

config("siwx917-common-config") {
defines = [ "OTA_PERIODIC_TIMEOUT=${ota_periodic_query_timeout_sec}" ]
libs = [ "${sdk_support_root}/matter/provision/lib/libProvision_si917.a" ]
if (sl_si91x_crypto_flavor == "psa") {
libs =
[ "${sdk_support_root}/matter/provision/lib/libProvisionPSA_si917.a" ]
} else {
libs = [ "${sdk_support_root}/matter/provision/lib/libProvision_si917.a" ]
}

if (!disable_lcd) {
include_dirs = [ "${silabs_common_plat_dir}/display" ]
Expand Down
37 changes: 16 additions & 21 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_msc.h>
#include <lib/support/BytesToHex.h>
#include <lib/support/CHIPMemString.h>
#include <lib/support/CodeUtils.h>
Expand All @@ -26,15 +25,20 @@
#include <nvm3_default.h>
#include <nvm3_hal_flash.h>
#include <platform/CHIPDeviceConfig.h>
#include <platform/silabs/MigrationManager.h>
#include <platform/silabs/SilabsConfig.h>
#include <psa/crypto.h>
#include <silabs_creds.h>
#ifdef SLI_SI91X_MCU_INTERFACE
#include <sl_si91x_common_flash_intf.h>
#else
#include <em_msc.h>
#include <psa/crypto.h>
#endif

#ifdef SL_PROVISION_GENERATOR
extern void setNvm3End(uint32_t addr);
#elif !SL_MATTER_GN_BUILD
#include <sl_matter_provision_config.h>
#endif

extern uint8_t linker_nvm_end[];
Expand Down Expand Up @@ -535,7 +539,7 @@ CHIP_ERROR Storage::GetDeviceAttestationCert(MutableByteSpan & value)
return err;
}

#ifdef SLI_SI91X_MCU_INTERFACE
#if defined(SLI_SI91X_MCU_INTERFACE) && defined(SL_MBEDTLS_USE_TINYCRYPT)
CHIP_ERROR Storage::SetDeviceAttestationKey(const ByteSpan & value)
{
return SilabsConfig::WriteConfigValueBin(SilabsConfig::kConfigKey_Creds_KeyId, value.data(), value.size());
Expand Down Expand Up @@ -573,7 +577,7 @@ CHIP_ERROR Storage::SignWithDeviceAttestationKey(const ByteSpan & message, Mutab
}
}

#else // SLI_SI91X_MCU_INTERFACEX_MCU_INTERFACEX_MCU_INTERFACE
#else

CHIP_ERROR Storage::SetDeviceAttestationKey(const ByteSpan & value)
{
Expand Down Expand Up @@ -696,15 +700,6 @@ CHIP_ERROR Storage::GetTestEventTriggerKey(MutableByteSpan & keySpan)

} // namespace Provision

void MigrateUint32(uint32_t old_key, uint32_t new_key)
{
uint32_t value = 0;
if (SilabsConfig::ConfigValueExists(old_key) && (CHIP_NO_ERROR == SilabsConfig::ReadConfigValue(old_key, value)))
{
SilabsConfig::WriteConfigValue(new_key, value);
}
}

void MigrateDacProvider(void)
{
constexpr uint32_t kOldKey_Creds_KeyId = SilabsConfigKey(SilabsConfig::kMatterConfig_KeyBase, 0x21);
Expand All @@ -716,14 +711,14 @@ void MigrateDacProvider(void)
constexpr uint32_t kOldKey_Creds_CD_Offset = SilabsConfigKey(SilabsConfig::kMatterConfig_KeyBase, 0x27);
constexpr uint32_t kOldKey_Creds_CD_Size = SilabsConfigKey(SilabsConfig::kMatterConfig_KeyBase, 0x28);

MigrateUint32(kOldKey_Creds_KeyId, SilabsConfig::kConfigKey_Creds_KeyId);
MigrateUint32(kOldKey_Creds_Base_Addr, SilabsConfig::kConfigKey_Creds_Base_Addr);
MigrateUint32(kOldKey_Creds_DAC_Offset, SilabsConfig::kConfigKey_Creds_DAC_Offset);
MigrateUint32(kOldKey_Creds_DAC_Size, SilabsConfig::kConfigKey_Creds_DAC_Size);
MigrateUint32(kOldKey_Creds_PAI_Offset, SilabsConfig::kConfigKey_Creds_PAI_Offset);
MigrateUint32(kOldKey_Creds_PAI_Size, SilabsConfig::kConfigKey_Creds_PAI_Size);
MigrateUint32(kOldKey_Creds_CD_Offset, SilabsConfig::kConfigKey_Creds_CD_Offset);
MigrateUint32(kOldKey_Creds_CD_Size, SilabsConfig::kConfigKey_Creds_CD_Size);
MigrationManager::MigrateUint32(kOldKey_Creds_KeyId, SilabsConfig::kConfigKey_Creds_KeyId);
MigrationManager::MigrateUint32(kOldKey_Creds_Base_Addr, SilabsConfig::kConfigKey_Creds_Base_Addr);
MigrationManager::MigrateUint32(kOldKey_Creds_DAC_Offset, SilabsConfig::kConfigKey_Creds_DAC_Offset);
MigrationManager::MigrateUint32(kOldKey_Creds_DAC_Size, SilabsConfig::kConfigKey_Creds_DAC_Size);
MigrationManager::MigrateUint32(kOldKey_Creds_PAI_Offset, SilabsConfig::kConfigKey_Creds_PAI_Offset);
MigrationManager::MigrateUint32(kOldKey_Creds_PAI_Size, SilabsConfig::kConfigKey_Creds_PAI_Size);
MigrationManager::MigrateUint32(kOldKey_Creds_CD_Offset, SilabsConfig::kConfigKey_Creds_CD_Offset);
MigrationManager::MigrateUint32(kOldKey_Creds_CD_Size, SilabsConfig::kConfigKey_Creds_CD_Size);
}

} // namespace Silabs
Expand Down
14 changes: 12 additions & 2 deletions third_party/silabs/SiWx917_sdk.gni
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ template("siwx917_sdk") {
"SL_HEAP_SIZE=32768",
"SL_WIFI=1",
"CCP_SI917_BRINGUP=1",
"SL_COMPONENT_CATALOG_PRESENT",
"SL_COMPONENT_CATALOG_PRESENT=1",
"RS911X_WIFI=1",
"RSI_WLAN_ENABLE",
"SLI_SI91X_ENABLE_OS=1",
Expand Down Expand Up @@ -226,7 +226,7 @@ template("siwx917_sdk") {
"SL_SI91X_SI917_RAM_MEM_CONFIG=3",
"SL_SI91x_DUAL_INTERRUPTS_ERRATA=1",
"EXT_IRQ_COUNT=75",
"FLASH_PAGE_SIZE=1",
"FLASH_PAGE_SIZE=4096",
"DEBUG_ENABLE=1",
"ENABLE_DEBUG_MODULE=1",
"SI91X_SYSRTC_PRESENT=1",
Expand All @@ -240,6 +240,16 @@ template("siwx917_sdk") {
"configUSE_POSIX_ERRNO=1",
"NVM3_LOCK_OVERRIDE=1",
"SL_MEMORY_POOL_LIGHT=1",
"SL_CODE_COMPONENT_CORE=core",
"SLI_SI91X_MCU_EXTERNAL_LDO_FOR_PSRAM=1",
"CLOCK_ROMDRIVER_PRESENT=1",
"ULPSS_CLOCK_ROMDRIVER_PRESENT=1",
"SL_SI91X_BOARD_INIT=1",
"CRC_ROMDRIVER_PRESENT=1",
"TIMER_ROMDRIVER_PRESENT=1",
"UDMA_ROMDRIVER_PRESENT=1",
"PLL_ROMDRIVER_PRESENT=1",
"SL_MATTER_GN_BUILD=1",
]

if (silabs_log_enabled && chip_logging) {
Expand Down
1 change: 1 addition & 0 deletions third_party/silabs/efr32_sdk.gni
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,7 @@ template("efr32_sdk") {
"SL_RAIL_UTIL_PA_CONFIG_HEADER=<sl_rail_util_pa_config.h>",
"RADIO_CONFIG_DMP_SUPPORT=1",
"SL_MATTER_BLE_EXTENDED_ADV=${sl_matter_ble_extended_adv}",
"SL_MATTER_GN_BUILD=1",
"SL_MEMORY_POOL_LIGHT=1",
"SL_OPENTHREAD_STACK_FEATURES_CONFIG_FILE=\"sl_openthread_features_config.h\"",
"SL_CSL_TIMEOUT=${sl_ot_csl_timeout_sec}",
Expand Down

0 comments on commit 3761447

Please sign in to comment.