Skip to content

Commit

Permalink
[Silabs] Refactor/Cleanup Si917 examples build files (#25682)
Browse files Browse the repository at this point in the history
* [Silabs] Refactor/Cleanup SiWx917 examples build files

* Silabs: [Wifi] fix to the Bluez disconnection issue

* Silabs : Review comment solved

* Silabs : Config cleanup for remaining Si917 Apps

* Some more fixes

* removing the --wifi SiWx917 flag, removing duplicates and address few review comments

* duplicate args and modifying ipv4 to ipv6

* Restyled by clang-format

* Restyled by gn

* removing efr32_arm, efr32_executable, siwx917_executable to silabs_arm and silabs_executable

* Restyled by gn

* Silabs : Updated new Wiseconnect branch for matter

* Silabs : Review comments solved

* Restyled by clang-format

* Silabs : 917NCP ble using wiseconnect files, updated gni file to use wisemcu files

* Restyled by gn

* Review Comments solved

* fixes required to use GSDK lwip

* Merge conflict solved

* Restyled by gn

* Solved Build error arise because of Merge Conflict

* Restyled by gn

---------

Co-authored-by: Chirag Bansal <[email protected]>
Co-authored-by: Restyled.io <[email protected]>
  • Loading branch information
3 people authored and pull[bot] committed Apr 17, 2023
1 parent 742376a commit 4524158
Show file tree
Hide file tree
Showing 54 changed files with 10,649 additions and 1,574 deletions.
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@
[submodule "third_party/silabs/wiseconnect-wifi-bt-sdk"]
path = third_party/silabs/wiseconnect-wifi-bt-sdk
url = https://github.com/SiliconLabs/wiseconnect-wifi-bt-sdk.git
branch = master
branch = 2.7.1-Matter
platforms = efr32,silabs_docker
[submodule "editline"]
path = third_party/editline/repo
Expand Down
4 changes: 2 additions & 2 deletions examples/chef/efr32/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import("//build_overrides/efr32_sdk.gni")
import("//build_overrides/pigweed.gni")

import("${build_root}/config/defaults.gni")
import("${efr32_sdk_build_root}/efr32_executable.gni")
import("${efr32_sdk_build_root}/efr32_sdk.gni")
import("${efr32_sdk_build_root}/silabs_executable.gni")

import("${chip_root}/examples/common/pigweed/pigweed_rpcs.gni")
import("${chip_root}/src/platform/device.gni")
Expand Down Expand Up @@ -81,7 +81,7 @@ efr32_sdk("sdk") {
}
}

efr32_executable("chef_app") {
silabs_executable("chef_app") {
output_name = "chip-efr32-chef-example.out"
include_dirs = [ "include" ]
defines = []
Expand Down
2 changes: 0 additions & 2 deletions examples/light-switch-app/silabs/SiWx917/.gn
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,5 @@ check_system_includes = true
default_args = {
target_cpu = "arm"
target_os = "freertos"
chip_openthread_ftd = true

import("//args.gni")
}
220 changes: 10 additions & 210 deletions examples/light-switch-app/silabs/SiWx917/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import("//build_overrides/pigweed.gni")

import("${build_root}/config/defaults.gni")
import("${efr32_sdk_build_root}/SiWx917_sdk.gni")
import("${efr32_sdk_build_root}/efr32_executable.gni")
import("${efr32_sdk_build_root}/silabs_executable.gni")

import("${chip_root}/examples/common/pigweed/pigweed_rpcs.gni")
import("${chip_root}/src/platform/device.gni")
Expand All @@ -35,101 +35,14 @@ efr32_project_dir = "${chip_root}/examples/light-switch-app/silabs/SiWx917"
examples_plat_dir = "${chip_root}/examples/platform/silabs/SiWx917"
examples_common_plat_dir = "${chip_root}/examples/platform/silabs"

import("${examples_plat_dir}/args.gni")

declare_args() {
# Dump memory usage at link time.
chip_print_memory_usage = false

# Monitor & log memory usage at runtime.
enable_heap_monitoring = false

# Enable Sleepy end device
enable_sleepy_device = false

# OTA timeout in seconds
OTA_periodic_query_timeout = 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
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 = ""
}

# Sanity check
assert(!(chip_enable_wifi && chip_enable_openthread))
assert(!(use_SiWx917 && chip_enable_openthread))
assert(!(use_wf200 && chip_enable_openthread))
if (chip_enable_wifi) {
assert(use_SiWx917 || use_wf200)
enable_openthread_cli = false
import("${chip_root}/src/platform/silabs/SiWx917/wifi_args.gni")
}

# ThunderBoards, Explorer Kit and MGM240L do not support LCD (No LCD)
if (silabs_board == "BRD4166A" || silabs_board == "BRD2601B" ||
silabs_board == "BRD2703A" || silabs_board == "BRD4319A") {
show_qr_code = false
disable_lcd = true
}

defines = []

if (siwx917_commissionable_data) {
defines += [ "SIWX917_USE_COMISSIONABLE_DATA=1" ]
}

# WiFi settings
if (chip_enable_wifi) {
if (chip_default_wifi_ssid != "") {
defines += [
"CHIP_ONNETWORK_PAIRING=1",
"CHIP_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 += [ "CHIP_WIFI_PSK=\"${chip_default_wifi_psk}\"" ]
}
wifi_sdk_dir = "${chip_root}/src/platform/silabs/SiWx917/wifi"
efr32_lwip_defs = [ "LWIP_NETIF_API=1" ]
if (lwip_ipv4) {
efr32_lwip_defs += [
"LWIP_IPV4=1",

# adds following options to provide
# them to .cpp source files
# flags ported from lwipopts file
# TODO: move lwipopts to one location
"LWIP_ARP=1",
"LWIP_ICMP=1",
"LWIP_IGMP=1",
"LWIP_DHCP=1",
"LWIP_DNS=0",
]
} else {
efr32_lwip_defs += [ "LWIP_IPV4=0" ]
}
if (lwip_ipv6) {
efr32_lwip_defs += [ "LWIP_IPV6=1" ]
} else {
efr32_lwip_defs += [ "LWIP_IPV6=0" ]
}

import("${examples_plat_dir}/SiWx917/rs911x.gni")
}

efr32_sdk("sdk") {
siwx917_sdk("sdk") {
sources = [
"${efr32_project_dir}/include/CHIPProjectConfig.h",
"${examples_plat_dir}/FreeRTOSConfig.h",
Expand All @@ -144,79 +57,31 @@ efr32_sdk("sdk") {
"${examples_common_plat_dir}",
]

defines += [
"BOARD_ID=${silabs_board}",
"OTA_PERIODIC_TIMEOUT=${OTA_periodic_query_timeout}",
]

if (chip_enable_pw_rpc) {
defines += [
"HAL_VCOM_ENABLE=1",
"PW_RPC_ENABLED",
]
}

# WiFi Settings
if (chip_enable_wifi) {
if (use_SiWx917) {
defines += rs911x_defs
include_dirs += rs911x_plat_incs
} else if (use_wf200) {
defines += wf200_defs
include_dirs += wf200_plat_incs
}

if (use_rs911x_sockets) {
include_dirs += [ "${examples_plat_dir}/wifi/rsi-sockets" ]
defines += rs911x_sock_defs
} else {
# Using LWIP instead of the native TCP/IP stack
defines += efr32_lwip_defs
}

if (sl_wfx_config_softap) {
defines += [ "SL_WFX_CONFIG_SOFTAP" ]
}
if (sl_wfx_config_scan) {
defines += [ "SL_WFX_CONFIG_SCAN" ]
}
}
}

efr32_executable("light_switch_app") {
output_name = "chip-efr32-light-switch-example.out"
public_configs = [ "${efr32_sdk_build_root}:silabs_config" ]
silabs_executable("light_switch_app") {
output_name = "chip-siwx917-light-switch-example.out"
include_dirs = [ "include" ]
defines = []

sources = [
"${chip_root}/examples/light-switch-app/silabs/common/BindingHandler.cpp",
"${chip_root}/examples/light-switch-app/silabs/common/LightSwitchMgr.cpp",
"${examples_common_plat_dir}/heap_4_silabs.c",
"${examples_plat_dir}/BaseApplication.cpp",
"${examples_plat_dir}/init_ccpPlatform.cpp",
"${examples_plat_dir}/matter_config.cpp",
"${examples_plat_dir}/siwx917_utils.cpp",
"src/AppTask.cpp",
"src/ZclCallbacks.cpp",
"src/main.cpp",
]

if (use_wstk_leds) {
sources += [ "${examples_plat_dir}/LEDWidget.cpp" ]
}

if (chip_enable_pw_rpc || chip_build_libshell || enable_openthread_cli ||
use_wf200 || use_SiWx917) {
#sources += [ "${examples_plat_dir}/uart.cpp" ]
}

deps = [
":sdk",
"${chip_root}/examples/light-switch-app/light-switch-common",
"${chip_root}/examples/providers:device_info_provider",
"${chip_root}/src/lib",
"${chip_root}/src/setup_payload",
"${examples_plat_dir}:siwx917-common",
app_data_model,
]

if (chip_build_libshell) {
Expand All @@ -225,66 +90,6 @@ efr32_executable("light_switch_app") {
]
}

# Attestation Credentials
if (chip_build_platform_attestation_credentials_provider) {
deps += [ "${examples_plat_dir}:siwx917-attestation-credentials" ]
}

# Factory Data Provider
if (use_efr32_factory_data_provider) {
deps += [ "${examples_plat_dir}:efr32-factory-data-provider" ]
}

# WiFi Settings
if (chip_enable_wifi) {
if (use_SiWx917) {
sources += rs911x_src_plat

# All the stuff from wiseconnect
sources += rs911x_src_sapi

# Apparently - the rsi library needs this (though we may not use use it)
sources += rs911x_src_sock
include_dirs += rs911x_inc_plat

if (use_rs911x_sockets) {
#
# Using native sockets inside RS911x
#
include_dirs += rs911x_sock_inc
} else {
#
# We use LWIP - not built-in sockets
#
sources += rs911x_src_lwip
}
} else if (use_wf200) {
sources += wf200_plat_src
include_dirs += wf200_plat_incs
}

if (rs91x_wpa3_only) {
# TODO: Change this macro once WF200 support is provided
defines += [ "WIFI_ENABLE_SECURITY_WPA3=1" ]
}
}

if (!disable_lcd) {
sources += [
"${examples_plat_dir}/display/demo-ui.c",
"${examples_plat_dir}/display/lcd.cpp",
]
include_dirs += [ "${examples_plat_dir}/display" ]
defines += [
"DISPLAY_ENABLED",
"IS_DEMO_SWITCH=1",
]
if (show_qr_code) {
defines += [ "QR_CODE_ENABLED" ]
deps += [ "${chip_root}/examples/common/QRCode" ]
}
}

if (chip_enable_pw_rpc) {
defines += [
"PW_RPC_ENABLED",
Expand Down Expand Up @@ -322,11 +127,6 @@ efr32_executable("light_switch_app") {
]
}

if (enable_heap_monitoring) {
sources += [ "${examples_common_plat_dir}/MemMonitoring.cpp" ]
defines += [ "HEAP_MONITORING" ]
}

ldscript = "${examples_plat_dir}/ldscripts/${silabs_family}.ld"

inputs = [ ldscript ]
Expand All @@ -351,10 +151,10 @@ efr32_executable("light_switch_app") {
output_dir = root_out_dir
}

group("efr32") {
group("siwx917") {
deps = [ ":light_switch_app" ]
}

group("default") {
deps = [ ":efr32" ]
deps = [ ":siwx917" ]
}
6 changes: 2 additions & 4 deletions examples/light-switch-app/silabs/SiWx917/args.gni
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ import("//build_overrides/chip.gni")
import("${chip_root}/config/standalone/args.gni")
import("${chip_root}/src/platform/silabs/SiWx917/args.gni")

efr32_sdk_target = get_label_info(":sdk", "label_no_toolchain")
siwx917_sdk_target = get_label_info(":sdk", "label_no_toolchain")

app_data_model = "${chip_root}/examples/light-switch-app/light-switch-common"
chip_enable_ota_requestor = true
chip_enable_openthread = true
openthread_external_platform =
"${chip_root}/third_party/openthread/platforms/efr32:libopenthread-efr32"
28 changes: 0 additions & 28 deletions examples/light-switch-app/silabs/SiWx917/build_for_wifi_gnfile.gn

This file was deleted.

4 changes: 2 additions & 2 deletions examples/light-switch-app/silabs/efr32/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import("//build_overrides/efr32_sdk.gni")
import("//build_overrides/pigweed.gni")

import("${build_root}/config/defaults.gni")
import("${efr32_sdk_build_root}/efr32_executable.gni")
import("${efr32_sdk_build_root}/efr32_sdk.gni")
import("${efr32_sdk_build_root}/silabs_executable.gni")

import("${chip_root}/examples/common/pigweed/pigweed_rpcs.gni")
import("${chip_root}/src/platform/device.gni")
Expand Down Expand Up @@ -83,7 +83,7 @@ efr32_sdk("sdk") {
}
}

efr32_executable("light_switch_app") {
silabs_executable("light_switch_app") {
output_name = "chip-efr32-light-switch-example.out"
include_dirs = [ "include" ]
defines = []
Expand Down
1 change: 0 additions & 1 deletion examples/lighting-app/silabs/SiWx917/.gn
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ check_system_includes = true
default_args = {
target_cpu = "arm"
target_os = "freertos"
chip_openthread_ftd = true

import("//args.gni")
}
Loading

0 comments on commit 4524158

Please sign in to comment.