Skip to content

Commit

Permalink
[Silabs]Provision storage sourceset (project-chip#34929)
Browse files Browse the repository at this point in the history
* Create a separte source_set for the provision storage implementation

* Fix efr32 build using provision flash storage

* fix argument duplication which is not needed.

* apply suggested renames
  • Loading branch information
jmartinez-silabs authored and PeterC1965 committed Aug 28, 2024
1 parent e3cadb8 commit da91d46
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 15 deletions.
10 changes: 1 addition & 9 deletions examples/platform/silabs/SiWx917/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,6 @@ source_set("siwx917-matter-shell") {

config("siwx917-common-config") {
defines = [ "OTA_PERIODIC_TIMEOUT=${ota_periodic_query_timeout_sec}" ]
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 Expand Up @@ -177,7 +171,7 @@ config("silabs-wifi-config") {
}

source_set("siwx917-common") {
deps = [ "${chip_root}/src/platform/silabs/provision:provision-headers" ]
deps = [ "${silabs_common_plat_dir}/provision:storage" ]
defines = []
public_deps = []
public_configs = [
Expand All @@ -197,8 +191,6 @@ source_set("siwx917-common") {
"${silabs_common_plat_dir}/LEDWidget.cpp",
"${silabs_common_plat_dir}/MatterConfig.cpp",
"${silabs_common_plat_dir}/SoftwareFaultReports.cpp",
"${silabs_common_plat_dir}/provision/ProvisionStorageCustom.cpp",
"${silabs_common_plat_dir}/provision/ProvisionStorageFlash.cpp",
"${silabs_common_plat_dir}/silabs_utils.cpp",
"${silabs_common_plat_dir}/syscalls_stubs.cpp",
"${silabs_plat_si91x_wifi_dir}/dhcp_client.cpp",
Expand Down
7 changes: 1 addition & 6 deletions examples/platform/silabs/efr32/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,6 @@ source_set("efr-matter-shell") {

config("efr32-common-config") {
defines = [ "OTA_PERIODIC_TIMEOUT=${ota_periodic_query_timeout_sec}" ]
libs = [
"${sdk_support_root}/matter/provision/lib/libProvision_${silabs_family}.a",
]

if (!disable_lcd) {
include_dirs = [ "${silabs_common_plat_dir}/display" ]
Expand Down Expand Up @@ -212,7 +209,7 @@ config("silabs-wifi-config") {
}

source_set("efr32-common") {
deps = [ "${chip_root}/src/platform/silabs/provision:provision-headers" ]
deps = [ "${silabs_common_plat_dir}/provision:storage" ]
defines = []
public_deps = []
public_configs = [
Expand Down Expand Up @@ -241,8 +238,6 @@ source_set("efr32-common") {
"${silabs_common_plat_dir}/LEDWidget.cpp",
"${silabs_common_plat_dir}/MatterConfig.cpp",
"${silabs_common_plat_dir}/SoftwareFaultReports.cpp",
"${silabs_common_plat_dir}/provision/ProvisionStorageCustom.cpp",
"${silabs_common_plat_dir}/provision/ProvisionStorageDefault.cpp",
"${silabs_common_plat_dir}/silabs_utils.cpp",
"${silabs_common_plat_dir}/syscalls_stubs.cpp",
]
Expand Down
52 changes: 52 additions & 0 deletions examples/platform/silabs/provision/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Copyright (c) 2024 Project CHIP Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import("//build_overrides/chip.gni")
import("//build_overrides/efr32_sdk.gni")
import("${efr32_sdk_build_root}/silabs_board.gni")

if (wifi_soc) {
import("${efr32_sdk_build_root}/SiWx917_sdk.gni")
} else {
import("${efr32_sdk_build_root}/efr32_sdk.gni")
}

source_set("storage") {
sources = [ "ProvisionStorageCustom.cpp" ]

if (use_provision_flash_storage) {
sources += [ "ProvisionStorageFlash.cpp" ]
} else {
sources += [ "ProvisionStorageDefault.cpp" ]
}

if (wifi_soc) {
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" ]
}
} else {
if (use_provision_flash_storage) {
libs = [ "${sdk_support_root}/matter/provision/lib/libProvisionFlash_${silabs_family}.a" ]
} else {
libs = [ "${sdk_support_root}/matter/provision/lib/libProvision_${silabs_family}.a" ]
}
}

deps = [ "${chip_root}/src/lib" ]
public_deps =
[ "${chip_root}/src/platform/silabs/provision:provision-headers" ]
}
6 changes: 6 additions & 0 deletions src/platform/silabs/efr32/efr32-chip-mbedtls-config.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,12 @@
#define PSA_WANT_ALG_SOME_PAKE
#endif // SL_USE_COAP_CONFIG

#if SL_MATTER_PROVISION_FLASH
#define MBEDTLS_SHA256_C
#define MBEDTLS_HMAC_DRBG_C
#define MBEDTLS_ECDSA_DETERMINISTIC
#endif // SL_MATTER_PROVISION_FLASH

#define MBEDTLS_PLATFORM_SNPRINTF_MACRO snprintf

#define MBEDTLS_AES_ROM_TABLES
Expand Down
9 changes: 9 additions & 0 deletions third_party/silabs/efr32_sdk.gni
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ declare_args() {
chip_enable_multi_ota_requestor = false
chip_enable_multi_ota_encryption = false
chip_enable_ota_custom_tlv_testing = false

# Factory Provision storage
use_provision_flash_storage = wifi_soc
}

examples_plat_dir = "${chip_root}/examples/platform/silabs/efr32"
Expand Down Expand Up @@ -469,6 +472,12 @@ template("efr32_sdk") {
defines += [ "SL_USE_COAP_CONFIG=0" ]
}

if (use_provision_flash_storage) {
defines += [ "SL_MATTER_PROVISION_FLASH=1" ]
} else {
defines += [ "SL_MATTER_PROVISION_FLASH=0" ]
}

if (chip_enable_ble_rs911x) {
defines += [
"RSI_BLE_ENABLE=1",
Expand Down

0 comments on commit da91d46

Please sign in to comment.