blob: beefb835d64172115cd68cbc2a9110a71d1c637c [file] [log] [blame]
# Copyright (c) 2020 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("${chip_root}/examples/common/pigweed/pigweed_rpcs.gni")
import("${chip_root}/src/lib/lib.gni")
import("${chip_root}/src/platform/device.gni")
import("${chip_root}/third_party/silabs/silabs_board.gni")
import("${efr32_sdk_build_root}/SiWx917_sdk.gni")
silabs_common_plat_dir = "${chip_root}/examples/platform/silabs"
wifi_sdk_dir = "${chip_root}/src/platform/silabs/SiWx917/wifi"
declare_args() {
enable_heap_monitoring = false
# OTA timeout in seconds
ota_periodic_query_timeout_sec = 86400
# Wifi related stuff - they are overridden by gn -args="use_wf200=true"
sl_wfx_config_softap = false
sl_wfx_config_scan = true
# Argument to force enable WPA3 security on rs91x
rs91x_wpa3_only = false
# use commissionable data for SiWx917
siwx917_commissionable_data = false
#default WiFi SSID
chip_default_wifi_ssid = ""
#default Wifi Password
chip_default_wifi_psk = ""
}
import("${chip_root}/src/platform/silabs/wifi_args.gni")
import("${silabs_common_plat_dir}/args.gni")
# Sanity check
assert(chip_enable_wifi)
wisemcu_sdk_root = "${chip_root}/third_party/silabs/wisemcu-wifi-bt-sdk"
silabs_common_plat_dir = "${chip_root}/examples/platform/silabs"
config("chip_examples_project_config") {
include_dirs = [ "project_include" ]
# Link options that provide a replacement for dynamic memory operations in standard
# library with the FreeRTOS malloc in platform code.
ldflags = [
# memory allocation -- these must be re-entrant and do locking
"-Wl,--wrap=malloc",
"-Wl,--wrap=free",
"-Wl,--wrap=realloc",
"-Wl,--wrap=calloc",
"-Wl,--wrap=MemoryAlloc",
# Wrap these in case internal newlib call them (e.g. strdup will)
# directly call _malloc_r)
"-Wl,--wrap=_malloc_r",
"-Wl,--wrap=_realloc_r",
"-Wl,--wrap=_free_r",
"-Wl,--wrap=_calloc_r",
]
}
if (enable_dic) {
config("efr32_dic_config") {
include_dirs = [
"${chip_root}/third_party/silabs/mqtt/stack",
"${chip_root}/third_party/silabs/mqtt/mqtt_transport_interface/include",
"${chip_root}/examples/platform/silabs/DIC/matter_abs_interface/include",
]
}
source_set("efr32-dic") {
sources = [
"${chip_root}/examples/platform/silabs/DIC/matter_abs_interface/src/dic.c",
"${chip_root}/third_party/silabs/mqtt/mqtt_transport_interface/src/MQTT_transport.c",
"${chip_root}/third_party/silabs/mqtt/mqtt_transport_interface/src/altcp.c",
"${chip_root}/third_party/silabs/mqtt/mqtt_transport_interface/src/altcp_alloc.c",
"${chip_root}/third_party/silabs/mqtt/mqtt_transport_interface/src/altcp_tcp.c",
"${chip_root}/third_party/silabs/mqtt/mqtt_transport_interface/src/altcp_tls_mbedtls.c",
"${chip_root}/third_party/silabs/mqtt/mqtt_transport_interface/src/altcp_tls_mbedtls_mem.c",
]
public_deps = [
"${chip_root}/src/inet",
"${chip_root}/src/lwip",
]
public_configs = [ ":efr32_dic_config" ]
}
}
source_set("siwx917-matter-shell") {
if (chip_build_libshell) {
defines = [ "ENABLE_CHIP_SHELL" ]
sources = [
"${silabs_common_plat_dir}/matter_shell.cpp",
"${wisemcu_sdk_root}/platforms/si91x/drivers/cmsis_driver/UDMA.c",
"${wisemcu_sdk_root}/platforms/si91x/drivers/cmsis_driver/USART.c",
]
include_dirs = [
".",
"${silabs_common_plat_dir}",
]
public_deps = [
"${chip_root}/examples/shell/shell_common:shell_common",
"${chip_root}/src/lib/shell:shell",
"${chip_root}/src/lib/shell:shell_core",
]
}
}
config("attestation-credentials-config") {
include_dirs = [ "${chip_root}" ]
defines = [
# Set to 1 to enable SI917 attestation credentials
"SILABS_ATTESTATION_CREDENTIALS",
]
}
source_set("siwx917-attestation-credentials") {
sources = [
"${silabs_common_plat_dir}/SilabsDeviceAttestationCreds.cpp",
"${silabs_common_plat_dir}/SilabsDeviceAttestationCreds.h",
]
public_deps = [
"${chip_root}/src/credentials",
"${chip_root}/src/platform:platform_base",
]
public_configs = [ ":attestation-credentials-config" ]
}
source_set("silabs-factory-data-provider") {
sources = [
"${silabs_common_plat_dir}/SilabsDeviceDataProvider.cpp",
"${silabs_common_plat_dir}/SilabsDeviceDataProvider.h",
]
public_deps = [
"${chip_root}/src/credentials",
"${chip_root}/src/platform:platform_base",
"${chip_root}/src/setup_payload",
]
public_configs = [ ":siwx917-common-config" ]
}
config("siwx917-common-config") {
defines = [ "OTA_PERIODIC_TIMEOUT=${ota_periodic_query_timeout_sec}" ]
if (!disable_lcd) {
include_dirs = [ "${silabs_common_plat_dir}/display" ]
defines += [ "DISPLAY_ENABLED" ]
}
if (show_qr_code) {
defines += [ "QR_CODE_ENABLED" ]
}
if (chip_enable_ota_requestor) {
defines += [ "SILABS_OTA_ENABLED" ]
}
if (enable_heap_monitoring) {
defines += [ "HEAP_MONITORING" ]
}
if (siwx917_commissionable_data) {
defines += [ "SIWX917_USE_COMISSIONABLE_DATA=1" ]
}
ldflags = [ "-Wl,--no-warn-rwx-segment" ]
}
config("silabs-wifi-config") {
defines = []
include_dirs = []
if (chip_default_wifi_ssid != "") {
defines += [
"SL_ONNETWORK_PAIRING=1",
"SL_WIFI_SSID=\"${chip_default_wifi_ssid}\"",
]
}
if (chip_default_wifi_psk != "") {
assert(chip_default_wifi_ssid != "",
"ssid can't be null if psk is provided")
defines += [ "SL_WIFI_PSK=\"${chip_default_wifi_psk}\"" ]
}
if (sl_wfx_config_softap) {
defines += [ "SL_WFX_CONFIG_SOFTAP" ]
}
if (sl_wfx_config_scan) {
defines += [ "SL_WFX_CONFIG_SCAN" ]
}
if (chip_enable_wifi_ipv4) {
defines += [ "CHIP_DEVICE_CONFIG_ENABLE_IPV4" ]
}
if (rs91x_wpa3_only) {
defines += [ "WIFI_ENABLE_SECURITY_WPA3=1" ]
}
}
source_set("siwx917-common") {
deps = []
public_deps = []
public_configs = [
":siwx917-common-config",
"${efr32_sdk_build_root}:silabs_config",
]
include_dirs = [
".",
"SiWx917/",
"${wifi_sdk_dir}",
]
sources = [
"${silabs_common_plat_dir}/LEDWidget.cpp",
"${silabs_common_plat_dir}/heap_4_silabs.c",
"${silabs_common_plat_dir}/silabs_utils.cpp",
"${silabs_common_plat_dir}/syscalls_stubs.cpp",
"${wifi_sdk_dir}/dhcp_client.cpp",
"${wifi_sdk_dir}/ethernetif.cpp",
"${wifi_sdk_dir}/lwip_netif.cpp",
"${wifi_sdk_dir}/wfx_notify.cpp",
"SiWx917/rsi_if.c",
"SiWx917/wfx_rsi_host.c",
"init_ccpPlatform.cpp",
"matter_config.cpp",
]
if (use_base_app) {
sources += [ "BaseApplication.cpp" ]
}
if (chip_enable_pw_rpc || chip_build_libshell) {
sources += [ "uart.cpp" ]
}
if (chip_enable_ota_requestor) {
# TODO: OTA For CCP Platform
}
if (!disable_lcd) {
sources += [
"${silabs_common_plat_dir}/display/demo-ui.c",
"${silabs_common_plat_dir}/display/lcd.cpp",
]
include_dirs += [ "${silabs_common_plat_dir}/display" ]
public_deps += [ "${chip_root}/examples/common/QRCode" ]
}
if (enable_heap_monitoring) {
sources += [ "${silabs_common_plat_dir}/MemMonitoring.cpp" ]
}
if (chip_enable_wifi) {
public_configs += [ ":silabs-wifi-config" ]
}
if (chip_build_libshell) {
deps += [ ":siwx917-matter-shell" ]
}
# Attestation Credentials
if (chip_build_platform_attestation_credentials_provider) {
deps += [ ":siwx917-attestation-credentials" ]
}
# Factory Data Provider
if (use_efr32_factory_data_provider) {
public_deps += [ ":silabs-factory-data-provider" ]
}
public_deps += [
"${chip_root}/examples/providers:device_info_provider",
"${chip_root}/src/lib",
"${chip_root}/src/setup_payload",
]
if (app_data_model != "") {
public_deps += [ app_data_model ]
}
}