From 1316132cc7fee9796a8202f65846a41c8d4ac771 Mon Sep 17 00:00:00 2001 From: Jean-Francois Penven <67962328+jepenven-silabs@users.noreply.github.com> Date: Thu, 24 Mar 2022 01:18:47 -0400 Subject: [PATCH] [EFR32] Add comments to examples BUILD.gn (#16575) * Add coments to examples BUILD.gn * fix CI --- examples/light-switch-app/efr32/BUILD.gn | 123 +++++++++------- examples/lighting-app/efr32/BUILD.gn | 120 +++++++++------- examples/lock-app/efr32/BUILD.gn | 113 +++++++++------ .../platform/efr32/ldscripts/efr32mg12.ld | 2 +- examples/window-app/efr32/BUILD.gn | 136 ++++++++++-------- 5 files changed, 285 insertions(+), 209 deletions(-) diff --git a/examples/light-switch-app/efr32/BUILD.gn b/examples/light-switch-app/efr32/BUILD.gn index 62f164e933a0d3..599d6efa3ea182 100644 --- a/examples/light-switch-app/efr32/BUILD.gn +++ b/examples/light-switch-app/efr32/BUILD.gn @@ -62,6 +62,14 @@ declare_args() { show_qr_code = true } +# Sanity check +assert(!(chip_enable_wifi && chip_enable_openthread)) +assert(!(use_rs911x && chip_enable_openthread)) +assert(!(use_wf200 && chip_enable_openthread)) +if (chip_enable_wifi) { + assert(use_rs911x || use_wf200) +} + # BRD4166A --> ThunderBoard Sense 2 (No LCD) if (efr32_board == "BRD4166A" || efr32_board == "BRD4180A") { show_qr_code = false @@ -70,17 +78,10 @@ if (efr32_board == "BRD4166A" || efr32_board == "BRD4180A") { # Enables LCD on supported devices lcd_on = show_qr_code -if (use_rs911x || use_wf200) { +# WiFi settings +if (chip_enable_wifi) { wifi_sdk_dir = "${chip_root}/third_party/efr32_sdk/repo/matter/wifi" - if (use_rs911x) { - wiseconnect_sdk_root = "${chip_root}/third_party/wiseconnect-wifi-bt-sdk" - import("${wifi_sdk_dir}/rs911x/rs911x.gni") - } else { - import("${wifi_sdk_dir}/wf200/wf200.gni") - } -} -efr32_lwip_defs = [ "LWIP_NETIF_API=1" ] -if (use_rs911x || use_wf200) { + efr32_lwip_defs = [ "LWIP_NETIF_API=1" ] efr32_lwip_defs += [ "LWIP_IPV4=1", "LWIP_ARP=1", @@ -89,6 +90,13 @@ if (use_rs911x || use_wf200) { "LWIP_IPV6_ND=1", "LWIP_IGMP=1", ] + + if (use_rs911x) { + wiseconnect_sdk_root = "${chip_root}/third_party/wiseconnect-wifi-bt-sdk" + import("${wifi_sdk_dir}/rs911x/rs911x.gni") + } else { + import("${wifi_sdk_dir}/wf200/wf200.gni") + } } efr32_sdk("sdk") { @@ -117,25 +125,25 @@ efr32_sdk("sdk") { "PW_RPC_ENABLED", ] } - if (use_rs911x) { - 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 - # Thread also uses LWIP - # - defines += efr32_lwip_defs - } + # WiFi Settings + if (chip_enable_wifi) { + if (use_rs911x) { + 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 (use_rs911x || use_wf200) { if (sl_wfx_config_softap) { defines += [ "SL_WFX_CONFIG_SOFTAP" ] } @@ -171,7 +179,9 @@ efr32_executable("light_switch_app") { "${chip_root}/src/lib", "${chip_root}/src/setup_payload", ] - if (!use_rs911x && !use_wf200) { + + # OpenThread Settings + if (chip_enable_openthread) { deps += [ "${chip_root}/third_party/openthread/platforms:libopenthread-platform", "${chip_root}/third_party/openthread/platforms:libopenthread-platform-utils", @@ -195,30 +205,33 @@ efr32_executable("light_switch_app") { sources += [ "${examples_plat_dir}/OTAConfig.cpp" ] } - if (use_rs911x) { - 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 + # WiFi Settings + if (chip_enable_wifi) { + if (use_rs911x) { + 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 } - } else if (use_wf200) { - sources += wf200_plat_src - include_dirs += wf200_plat_incs } if (lcd_on) { @@ -285,6 +298,14 @@ efr32_executable("light_switch_app") { ] } + # WiFi Settings + if (chip_enable_wifi) { + ldflags += [ + "-Wl,--defsym", + "-Wl,SILABS_WIFI=1", + ] + } + output_dir = root_out_dir } diff --git a/examples/lighting-app/efr32/BUILD.gn b/examples/lighting-app/efr32/BUILD.gn index 9543da7df39507..3d93d8919e6ef7 100644 --- a/examples/lighting-app/efr32/BUILD.gn +++ b/examples/lighting-app/efr32/BUILD.gn @@ -62,6 +62,14 @@ declare_args() { show_qr_code = true } +# Sanity check +assert(!(chip_enable_wifi && chip_enable_openthread)) +assert(!(use_rs911x && chip_enable_openthread)) +assert(!(use_wf200 && chip_enable_openthread)) +if (chip_enable_wifi) { + assert(use_rs911x || use_wf200) +} + # BRD4166A --> ThunderBoard Sense 2 (No LCD) if (efr32_board == "BRD4166A" || efr32_board == "BRD4180A") { show_qr_code = false @@ -70,17 +78,10 @@ if (efr32_board == "BRD4166A" || efr32_board == "BRD4180A") { # Enables LCD on supported devices lcd_on = show_qr_code -if (use_rs911x || use_wf200) { +# WiFi settings +if (chip_enable_wifi) { wifi_sdk_dir = "${chip_root}/third_party/efr32_sdk/repo/matter/wifi" - if (use_rs911x) { - wiseconnect_sdk_root = "${chip_root}/third_party/wiseconnect-wifi-bt-sdk" - import("${wifi_sdk_dir}/rs911x/rs911x.gni") - } else { - import("${wifi_sdk_dir}/wf200/wf200.gni") - } -} -efr32_lwip_defs = [ "LWIP_NETIF_API=1" ] -if (use_rs911x || use_wf200) { + efr32_lwip_defs = [ "LWIP_NETIF_API=1" ] efr32_lwip_defs += [ "LWIP_IPV4=1", "LWIP_ARP=1", @@ -89,6 +90,13 @@ if (use_rs911x || use_wf200) { "LWIP_IPV6_ND=1", "LWIP_IGMP=1", ] + + if (use_rs911x) { + wiseconnect_sdk_root = "${chip_root}/third_party/wiseconnect-wifi-bt-sdk" + import("${wifi_sdk_dir}/rs911x/rs911x.gni") + } else { + import("${wifi_sdk_dir}/wf200/wf200.gni") + } } efr32_sdk("sdk") { @@ -117,24 +125,25 @@ efr32_sdk("sdk") { "PW_RPC_ENABLED", ] } - if (use_rs911x) { - 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 - # Thread also uses LWIP - # - defines += efr32_lwip_defs - } - if (use_rs911x || use_wf200) { + # WiFi Settings + if (chip_enable_wifi) { + if (use_rs911x) { + 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" ] } @@ -169,7 +178,9 @@ efr32_executable("lighting_app") { "${chip_root}/src/lib", "${chip_root}/src/setup_payload", ] - if (!use_rs911x && !use_wf200) { + + # OpenThread Settings + if (chip_enable_openthread) { deps += [ "${chip_root}/third_party/openthread/platforms:libopenthread-platform", "${chip_root}/third_party/openthread/platforms:libopenthread-platform-utils", @@ -193,30 +204,33 @@ efr32_executable("lighting_app") { sources += [ "${examples_plat_dir}/OTAConfig.cpp" ] } - if (use_rs911x) { - 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 + # WiFi Settings + if (chip_enable_wifi) { + if (use_rs911x) { + 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 } - } else if (use_wf200) { - sources += wf200_plat_src - include_dirs += wf200_plat_incs } if (lcd_on) { @@ -287,7 +301,9 @@ efr32_executable("lighting_app") { "-fstack-usage", ] } - if (use_rs911x || use_wf200) { + + # WiFi Settings + if (chip_enable_wifi) { ldflags += [ "-Wl,--defsym", "-Wl,SILABS_WIFI=1", diff --git a/examples/lock-app/efr32/BUILD.gn b/examples/lock-app/efr32/BUILD.gn index 4b28d1732ddcd2..2c4954f2a16899 100644 --- a/examples/lock-app/efr32/BUILD.gn +++ b/examples/lock-app/efr32/BUILD.gn @@ -61,6 +61,14 @@ declare_args() { show_qr_code = true } +# Sanity check +assert(!(chip_enable_wifi && chip_enable_openthread)) +assert(!(use_rs911x && chip_enable_openthread)) +assert(!(use_wf200 && chip_enable_openthread)) +if (chip_enable_wifi) { + assert(use_rs911x || use_wf200) +} + # BRD4166A --> ThunderBoard Sense 2 (No LCD) if (efr32_board == "BRD4166A" || efr32_board == "BRD4180A") { show_qr_code = false @@ -69,17 +77,10 @@ if (efr32_board == "BRD4166A" || efr32_board == "BRD4180A") { # Enables LCD on supported devices lcd_on = show_qr_code -if (use_rs911x || use_wf200) { +# WiFi settings +if (chip_enable_wifi) { wifi_sdk_dir = "${chip_root}/third_party/efr32_sdk/repo/matter/wifi" - if (use_rs911x) { - wiseconnect_sdk_root = "${chip_root}/third_party/wiseconnect-wifi-bt-sdk" - import("${wifi_sdk_dir}/rs911x/rs911x.gni") - } else { - import("${wifi_sdk_dir}/wf200/wf200.gni") - } -} -efr32_lwip_defs = [ "LWIP_NETIF_API=1" ] -if (use_rs911x || use_wf200) { + efr32_lwip_defs = [ "LWIP_NETIF_API=1" ] efr32_lwip_defs += [ "LWIP_IPV4=1", "LWIP_ARP=1", @@ -88,6 +89,13 @@ if (use_rs911x || use_wf200) { "LWIP_IPV6_ND=1", "LWIP_IGMP=1", ] + + if (use_rs911x) { + wiseconnect_sdk_root = "${chip_root}/third_party/wiseconnect-wifi-bt-sdk" + import("${wifi_sdk_dir}/rs911x/rs911x.gni") + } else { + import("${wifi_sdk_dir}/wf200/wf200.gni") + } } efr32_sdk("sdk") { @@ -123,16 +131,24 @@ efr32_sdk("sdk") { 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 - # Thread also uses LWIP - # - defines += efr32_lwip_defs - } - if (use_rs911x || use_wf200) { + # WiFi Settings + if (chip_enable_wifi) { + if (use_rs911x) { + 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" ] } @@ -171,7 +187,9 @@ efr32_executable("lock_app") { "${chip_root}/third_party/openthread/platforms:libopenthread-platform-utils", "${examples_plat_dir}:efr-matter-shell", ] - if (!use_rs911x && !use_wf200) { + + # OpenThread Settings + if (chip_enable_openthread) { deps += [ "${chip_root}/third_party/openthread/platforms:libopenthread-platform", "${chip_root}/third_party/openthread/platforms:libopenthread-platform-utils", @@ -195,30 +213,33 @@ efr32_executable("lock_app") { sources += [ "${examples_plat_dir}/OTAConfig.cpp" ] } - if (use_rs911x) { - 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 + # WiFi Settings + if (chip_enable_wifi) { + if (use_rs911x) { + 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 } - } else if (use_wf200) { - sources += wf200_plat_src - include_dirs += wf200_plat_incs } if (lcd_on) { @@ -289,7 +310,9 @@ efr32_executable("lock_app") { "-fstack-usage", ] } - if (use_rs911x || use_wf200) { + + # WiFi Settings + if (chip_enable_wifi) { ldflags += [ "-Wl,--defsym", "-Wl,SILABS_WIFI=1", diff --git a/examples/platform/efr32/ldscripts/efr32mg12.ld b/examples/platform/efr32/ldscripts/efr32mg12.ld index a2a81ed9ccc683..f55f03521bc1e4 100644 --- a/examples/platform/efr32/ldscripts/efr32mg12.ld +++ b/examples/platform/efr32/ldscripts/efr32mg12.ld @@ -284,6 +284,6 @@ SECTIONS /* Check if FLASH usage exceeds FLASH size */ - ASSERT( LENGTH(FLASH) >= (__etext + SIZEOF(.data)), "FLASH memory overflowed !") + ASSERT( LENGTH(FLASH) >= (__etext), "FLASH memory overflowed !") ASSERT((__etext + SIZEOF(.data)) <= __nvm3Base, "FLASH memory overlapped with NVM section.") } diff --git a/examples/window-app/efr32/BUILD.gn b/examples/window-app/efr32/BUILD.gn index 7d6e4961e71a9b..a8f69ee7228fd8 100644 --- a/examples/window-app/efr32/BUILD.gn +++ b/examples/window-app/efr32/BUILD.gn @@ -55,6 +55,14 @@ declare_args() { show_qr_code = true } +# Sanity check +assert(!(chip_enable_wifi && chip_enable_openthread)) +assert(!(use_rs911x && chip_enable_openthread)) +assert(!(use_wf200 && chip_enable_openthread)) +if (chip_enable_wifi) { + assert(use_rs911x || use_wf200) +} + # Enables LCD on supported devices lcd_on = true @@ -64,17 +72,10 @@ if (efr32_board == "BRD4166A" || efr32_board == "BRD4180A") { lcd_on = false } -if (use_rs911x || use_wf200) { +# WiFi settings +if (chip_enable_wifi) { wifi_sdk_dir = "${chip_root}/third_party/efr32_sdk/repo/matter/wifi" - if (use_rs911x) { - wiseconnect_sdk_root = "${chip_root}/third_party/wiseconnect-wifi-bt-sdk" - import("${wifi_sdk_dir}/rs911x/rs911x.gni") - } else { - import("${wifi_sdk_dir}/wf200/wf200.gni") - } -} -efr32_lwip_defs = [ "LWIP_NETIF_API=1" ] -if (use_rs911x || use_wf200) { + efr32_lwip_defs = [ "LWIP_NETIF_API=1" ] efr32_lwip_defs += [ "LWIP_IPV4=1", "LWIP_ARP=1", @@ -83,6 +84,13 @@ if (use_rs911x || use_wf200) { "LWIP_IPV6_ND=1", "LWIP_IGMP=1", ] + + if (use_rs911x) { + wiseconnect_sdk_root = "${chip_root}/third_party/wiseconnect-wifi-bt-sdk" + import("${wifi_sdk_dir}/rs911x/rs911x.gni") + } else { + import("${wifi_sdk_dir}/wf200/wf200.gni") + } } efr32_sdk("sdk") { @@ -103,24 +111,25 @@ efr32_sdk("sdk") { "CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE=${setupPinCode}", "OTA_PERIODIC_TIMEOUT=${OTA_periodic_query_timeout}", ] - if (use_rs911x) { - 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 - # Thread also uses LWIP - # - defines += efr32_lwip_defs - } - if (use_rs911x || use_wf200) { + # WiFi Settings + if (chip_enable_wifi) { + if (use_rs911x) { + 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" ] } @@ -149,40 +158,10 @@ efr32_executable("window_app") { "src/main.cpp", ] - if (chip_build_libshell || enable_openthread_cli) { + if (chip_build_libshell || enable_openthread_cli || enable_openthread_cli) { sources += [ "${examples_plat_dir}/uart.cpp" ] } - if (chip_enable_ota_requestor) { - defines += [ "EFR32_OTA_ENABLED" ] - sources += [ "${examples_plat_dir}/OTAConfig.cpp" ] - } - - if (use_rs911x) { - 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 - } deps = [ ":sdk", "${chip_root}/examples/window-app/common:window-common", @@ -190,7 +169,8 @@ efr32_executable("window_app") { "${chip_root}/src/setup_payload", ] - if (!use_rs911x && !use_wf200) { + # OpenThread Settings + if (chip_enable_openthread) { deps += [ "${chip_root}/third_party/openthread/platforms:libopenthread-platform", "${chip_root}/third_party/openthread/platforms:libopenthread-platform-utils", @@ -209,6 +189,40 @@ efr32_executable("window_app") { } } + if (chip_enable_ota_requestor) { + defines += [ "EFR32_OTA_ENABLED" ] + sources += [ "${examples_plat_dir}/OTAConfig.cpp" ] + } + + # WiFi Settings + if (chip_enable_wifi) { + if (use_rs911x) { + 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 (lcd_on) { sources += [ "${examples_plat_dir}/display/lcd.c", @@ -240,7 +254,9 @@ efr32_executable("window_app") { "-fstack-usage", ] } - if (use_rs911x || use_wf200) { + + # WiFi Settings + if (chip_enable_wifi) { ldflags += [ "-Wl,--defsym", "-Wl,SILABS_WIFI=1",