diff --git a/examples/platform/silabs/MatterConfig.cpp b/examples/platform/silabs/MatterConfig.cpp index f9a1b7188beed9..1197e4d48cd83b 100644 --- a/examples/platform/silabs/MatterConfig.cpp +++ b/examples/platform/silabs/MatterConfig.cpp @@ -296,5 +296,11 @@ CHIP_ERROR SilabsMatterConfig::InitWiFi(void) // ================================================================================ extern "C" void vApplicationIdleHook(void) { - // FreeRTOS Idle callback +#if SIWX_917 && CHIP_CONFIG_ENABLE_ICD_SERVER + if (ConnectivityMgr().IsWiFiStationConnected()) + { + // Let the M4 sleep once commissioning is done and device is in idle state + sl_wfx_host_si91x_sleep_wakeup(); + } +#endif } diff --git a/examples/platform/silabs/SiWx917/SiWx917/sl_wifi_if.c b/examples/platform/silabs/SiWx917/SiWx917/sl_wifi_if.c index 6e91f2a8c52fa7..f78539d9817170 100644 --- a/examples/platform/silabs/SiWx917/SiWx917/sl_wifi_if.c +++ b/examples/platform/silabs/SiWx917/SiWx917/sl_wifi_if.c @@ -41,6 +41,16 @@ #include "ble_config.h" +#if SL_ICD_ENABLED && SIWX_917 +#include "rsi_rom_power_save.h" +#include "sl_si91x_button_pin_config.h" +#include "sl_si91x_m4_ps.h" + +// TODO: should be removed once we are getting the press interrupt for button 0 with sleep +#define BUTTON_PRESSED 1 +bool btn0_pressed = false; +#endif // SL_ICD_ENABLED && SIWX_917 + #include "dhcp_client.h" #include "sl_wifi.h" #include "wfx_host_events.h" @@ -203,6 +213,44 @@ sl_status_t join_callback_handler(sl_wifi_event_t event, char * result, uint32_t } #if SL_ICD_ENABLED + +#if SIWX_917 +/****************************************************************** + * @fn sl_wfx_host_si91x_sleep_wakeup() + * @brief + * M4 going to sleep + * + * @param[in] None + * @return + * None + *********************************************************************/ +void sl_wfx_host_si91x_sleep_wakeup() +{ + if (wfx_rsi.dev_state & WFX_RSI_ST_SLEEP_READY) + { + // TODO: should be removed once we are getting the press interrupt for button 0 with sleep + if (!RSI_NPSSGPIO_GetPin(SL_BUTTON_BTN0_PIN) && !btn0_pressed) + { + sl_button_on_change(SL_BUTTON_BTN0_NUMBER, BUTTON_PRESSED); + btn0_pressed = true; + } + if (RSI_NPSSGPIO_GetPin(SL_BUTTON_BTN0_PIN)) + { +#ifdef DISPLAY_ENABLED + // if LCD is enabled, power down the lcd before setting the M4 to sleep + sl_si91x_hardware_setup(); +#endif + btn0_pressed = false; + /* Configure RAM Usage and Retention Size */ + sl_si91x_m4_sleep_wakeup(); +#if SILABS_LOG_ENABLED + silabsInitLog(); +#endif + } + } +} +#endif /* SIWX_917 */ + /****************************************************************** * @fn wfx_rsi_power_save() * @brief @@ -222,14 +270,14 @@ int32_t wfx_rsi_power_save() return status; } - sl_wifi_performance_profile_t wifi_profile = { ASSOCIATED_POWER_SAVE }; + sl_wifi_performance_profile_t wifi_profile = { .profile = ASSOCIATED_POWER_SAVE }; status = sl_wifi_set_performance_profile(&wifi_profile); if (status != RSI_SUCCESS) { SILABS_LOG("Powersave Config Failed, Error Code : 0x%lX", status); return status; } - SILABS_LOG("Powersave Config Success"); + wfx_rsi.dev_state |= WFX_RSI_ST_SLEEP_READY; return status; } #endif /* SL_ICD_ENABLED */ @@ -288,7 +336,17 @@ static sl_status_t wfx_rsi_init(void) SILABS_LOG("wfx_rsi_init failed %x", status); return status; } -#endif +#else // For SoC +#if SL_ICD_ENABLED + uint8_t xtal_enable = 1; + status = sl_si91x_m4_ta_secure_handshake(SL_SI91X_ENABLE_XTAL, 1, &xtal_enable, 0, NULL); + if (status != SL_STATUS_OK) + { + SILABS_LOG("Failed to bring m4_ta_secure_handshake: 0x%lx\r\n", status); + return status; + } +#endif /* SL_ICD_ENABLED */ +#endif /* SLI_SI91X_MCU_INTERFACE */ sl_wifi_firmware_version_t version = { 0 }; status = sl_wifi_get_firmware_version(&version); @@ -524,6 +582,10 @@ static sl_status_t wfx_rsi_do_join(void) sl_wifi_set_join_callback(join_callback_handler, NULL); + // Setting the listen interval to 0 which will set it to DTIM interval + sl_wifi_listen_interval_t sleep_interval = { .listen_interval = 0 }; + status = sl_wifi_set_listen_interval(SL_WIFI_CLIENT_INTERFACE, sleep_interval); + /* Try to connect Wifi with given Credentials * untill there is a success or maximum number of tries allowed */ diff --git a/examples/platform/silabs/SiWx917/SiWx917/sl_wlan_config.h b/examples/platform/silabs/SiWx917/SiWx917/sl_wlan_config.h index add60ffafeef0c..d73989617fe6e3 100644 --- a/examples/platform/silabs/SiWx917/SiWx917/sl_wlan_config.h +++ b/examples/platform/silabs/SiWx917/SiWx917/sl_wlan_config.h @@ -28,8 +28,6 @@ //! Disable feature #define RSI_DISABLE 0 -#define SI91X_LISTEN_INTERVAL 0 - static const sl_wifi_device_configuration_t config = { .boot_option = LOAD_NWP_FW, .mac_address = NULL, diff --git a/examples/platform/silabs/SiWx917/SiWx917/wfx_rsi.h b/examples/platform/silabs/SiWx917/SiWx917/wfx_rsi.h index e7869cfa688790..6721071a1de181 100644 --- a/examples/platform/silabs/SiWx917/SiWx917/wfx_rsi.h +++ b/examples/platform/silabs/SiWx917/SiWx917/wfx_rsi.h @@ -53,6 +53,7 @@ #define WFX_RSI_ST_STA_READY (WFX_RSI_ST_STA_CONNECTED | WFX_RSI_ST_STA_DHCP_DONE) #define WFX_RSI_ST_STARTED (0x200) /* RSI task started */ #define WFX_RSI_ST_SCANSTARTED (0x400) /* Scan Started */ +#define WFX_RSI_ST_SLEEP_READY (0x800) /* Notify the M4 to go to sleep*/ struct wfx_rsi { @@ -92,6 +93,10 @@ int32_t wfx_rsi_get_ap_ext(wfx_wifi_scan_ext_t * extra_info); int32_t wfx_rsi_reset_count(); int32_t wfx_rsi_disconnect(); int32_t wfx_wifi_rsi_init(void); +#if SL_ICD_ENABLED +void sl_wfx_host_si91x_sleep_wakeup(); +int32_t wfx_rsi_power_save(); +#endif /* SL_ICD_ENABLED */ #ifdef __cplusplus } diff --git a/examples/platform/silabs/display/demo-ui.c b/examples/platform/silabs/display/demo-ui.c index 082f79eea0e10f..ff207fa26656a7 100644 --- a/examples/platform/silabs/display/demo-ui.c +++ b/examples/platform/silabs/display/demo-ui.c @@ -23,6 +23,7 @@ #include "dmd/dmd.h" #include "em_types.h" #include "glib.h" +#include "sl_memlcd.h" #if SL_WIFI && !SIWX_917 #include "spi_multiplex.h" #endif // SL_WIFI && !SIWX_917 @@ -102,6 +103,9 @@ void demoUIInit(GLIB_Context_t * context) sl_status_t updateDisplay(void) { +#if SIWX_917 && SL_ICD_ENABLED && DISPLAY_ENABLED + sl_memlcd_post_wakeup_init(); +#endif // SIWX_917 && SL_ICD_ENABLED && DISPLAY_ENABLED #if SL_LCDCTRL_MUX sl_wfx_host_pre_lcd_spi_transfer(); #endif // SL_LCDCTRL_MUX diff --git a/scripts/examples/gn_silabs_example.sh b/scripts/examples/gn_silabs_example.sh index d9b78bc7892f8d..b3f9906e0dae38 100755 --- a/scripts/examples/gn_silabs_example.sh +++ b/scripts/examples/gn_silabs_example.sh @@ -113,6 +113,10 @@ if [ "$#" == "0" ]; then Use provided hardware version at build time siwx917_commissionable_data Build with the commissionable data given in DeviceConfig.h (only for SiWx917) + si91x_alarm_based_wakeup + Enable the Alarm Based Wakeup for 917 SoC when sleep is enabled (Default false) + si91x_alarm_periodic_time + Periodic time at which the 917 SoC should wakeup (Default: 30sec) Presets --icd enable ICD features, set thread mtd diff --git a/src/platform/silabs/KeyValueStoreManagerImpl.cpp b/src/platform/silabs/KeyValueStoreManagerImpl.cpp index 012c951aaaa729..5dbeba3e35edcd 100644 --- a/src/platform/silabs/KeyValueStoreManagerImpl.cpp +++ b/src/platform/silabs/KeyValueStoreManagerImpl.cpp @@ -164,9 +164,15 @@ void KeyValueStoreManagerImpl::ScheduleKeyMapSave(void) During commissioning, the key map will be modified multiples times subsequently. Commit the key map in nvm once it as stabilized. */ +#if SIWX_917 && CHIP_CONFIG_ENABLE_ICD_SERVER + // TODO: Remove this when RTC timer is added MATTER-2705 + SilabsConfig::WriteConfigValueBin(SilabsConfig::kConfigKey_KvsStringKeyMap, reinterpret_cast(mKvsKeyMap), + sizeof(mKvsKeyMap)); +#else SystemLayer().StartTimer( std::chrono::duration_cast(System::Clock::Seconds32(SILABS_KVS_SAVE_DELAY_SECONDS)), KeyValueStoreManagerImpl::OnScheduledKeyMapSave, NULL); +#endif // defined(SIWX_917) && CHIP_CONFIG_ENABLE_ICD_SERVER } CHIP_ERROR KeyValueStoreManagerImpl::_Get(const char * key, void * value, size_t value_size, size_t * read_bytes_size, diff --git a/src/platform/silabs/rs911x/BLEManagerImpl.cpp b/src/platform/silabs/rs911x/BLEManagerImpl.cpp index ca0e489616f368..749ff8614220ee 100644 --- a/src/platform/silabs/rs911x/BLEManagerImpl.cpp +++ b/src/platform/silabs/rs911x/BLEManagerImpl.cpp @@ -182,6 +182,13 @@ void sl_ble_event_handling_task(void) default: break; } + + if (chip::DeviceLayer::ConnectivityMgr().IsWiFiStationConnected()) + { + // Once DUT is connected adding a 500ms delay + // TODO: Fix this with a better event handling + vTaskDelay(pdMS_TO_TICKS(500)); + } } } diff --git a/third_party/silabs/SiWx917_sdk.gni b/third_party/silabs/SiWx917_sdk.gni index 5e14a44ac090a3..fd560b150c0d53 100644 --- a/third_party/silabs/SiWx917_sdk.gni +++ b/third_party/silabs/SiWx917_sdk.gni @@ -24,6 +24,14 @@ import("silabs_board.gni") examples_plat_dir = "${chip_root}/examples/platform/silabs/SiWx917" +declare_args() { + # Enable the Alarm Based Wakeup for 917 SoC when sleep is enabled + si91x_alarm_based_wakeup = false + + # Periodic time at which the 917 SoC should wakeup + si91x_alarm_periodic_time = 30 +} + # Defines an siwx917 SDK build target. # # Parameters: @@ -147,12 +155,12 @@ template("siwx917_sdk") { "SILABS_LOG_ENABLED=${silabs_log_enabled}", "SL_HEAP_SIZE=32768", "SL_WIFI=1", - "CCP_SI917_BRINGUP", + "CCP_SI917_BRINGUP=1", "SL_COMPONENT_CATALOG_PRESENT", - "RS911X_WIFI", + "RS911X_WIFI=1", "RSI_WLAN_ENABLE", - "SLI_SI91X_ENABLE_OS", - "SLI_SI91X_MCU_INTERFACE", #Enable CCP bus Interface + "SLI_SI91X_ENABLE_OS=1", + "SLI_SI91X_MCU_INTERFACE=1", #Enable CCP bus Interface "RSI_WLAN_API_ENABLE", "NVM3_DEFAULT_NVM_SIZE=40960", "NVM3_DEFAULT_MAX_OBJECT_SIZE=4092", @@ -163,43 +171,46 @@ template("siwx917_sdk") { "__HEAP_SIZE=0", "PLATFORM_HEADER=\"platform-header.h\"", "USE_NVM3=1", - "RSI_ARM_CM4F", - "SIWX_917", - "CHIP_9117", + "SIWX_917=1", + "CHIP_9117=1", "SLI_SI91X_ENABLE_BLE=1", "SL_SI91X_ENABLE_LITTLE_ENDIAN=1", "TINYCRYPT_PRIMITIVES", "OPTIMIZE_TINYCRYPT_ASM", "__error_t_defined", "RSI_SAMPLE_HAL", - "ENABLE_IPMU_APIS", - "SLI_SI91X_MCU_MOV_ROM_API_TO_FLASH", - "DEBUG_UART", - "SLI_SI91X_MCU_ENABLE_FLASH_BASED_EXECUTION", - "SL_WIFI_COMPONENT_INCLUDED", + "DEBUG_UART=1", + "SLI_SI91X_MCU_ENABLE_FLASH_BASED_EXECUTION=1", + "SL_WIFI_COMPONENT_INCLUDED=1", "SLI_SI917=1", + "SI917=1", "ROMDRIVER_PRESENT=1", "SL_CATALOG_FREERTOS_KERNEL_PRESENT=1", - "SL_PLATFORM_EXAMPLES_ENABLE", "SLI_SI91X_MCU_CONFIG_RADIO_BOARD_BASE_VER=1", - "FLASH_PAGE_SIZE", - "SL_NVM3_PRESENT", - "ROM_WIRELESS", "BRD4325A", #TODO: should be removed after SoC macro clean-up - "CONNECTIVITY_PLATFORM", - "SLI_SI917B0 = 1", + "SLI_SI917B0=1", "SLI_SI91X_MCU_COMMON_FLASH_MODE=1", - "EXECUTION_FROM_RAM", "SLI_SI91X_MCU_CONFIG_RADIO_BOARD_VER2=1", "SL_BOARD_REV=\"A00\"", "SPI_MULTI_SLAVE=1", "SYSCALLS_WRITE=1", - "SI91X_SYSRTC_COUNT=1", - "SSI_ULP_MASTER=1", - "SL_MEMLCD_EXTCOMIN_PORT=0", "__STATIC_INLINE=static inline", - "SL_SI91X_SI917_RAM_MEM_CONFIG=3", + "SL_SI91X_SI917_RAM_MEM_CONFIG=2", "SL_SI91x_DUAL_INTERRUPTS_ERRATA=1", + "EXT_IRQ_COUNT=75", + "FLASH_PAGE_SIZE=1", + "DEBUG_ENABLE=1", + "ENABLE_DEBUG_MODULE=1", + "SI91X_SYSRTC_PRESENT=1", + "TA_DEEP_SLEEP_COMMON_FLASH=1", + "SI917_SOC=1", + "SI91X_PLATFORM=1", + "SL_NET_COMPONENT_INCLUDED=1", + "SRAM_BASE=0x0cUL", + "SRAM_SIZE=0x4fc00UL", + "SLI_SI91X_MCU_ENABLE_IPMU_APIS=1", + "RADIO_CONFIG_DMP_SUPPORT=1", + "configUSE_POSIX_ERRNO=1", ] if (chip_build_libshell) { @@ -254,13 +265,21 @@ template("siwx917_sdk") { if (chip_enable_icd_server) { defines += [ - "WIFI_DEBUG_ENABLED=1", "SL_ICD_ENABLED=1", "SL_ACTIVE_MODE_THRESHOLD=${sl_active_mode_threshold_ms}", "SL_ACTIVE_MODE_INTERVAL=${sl_active_mode_interval_ms}", "SL_IDLE_MODE_INTERVAL=${sl_idle_mode_interval_s}", "SL_ICD_SUPPORTED_CLIENTS_PER_FABRIC=${sl_icd_supported_clients_per_fabric}", + "SL_SI91X_MCU_WIRELESS_BASED_WAKEUP=1", + "SL_SI91X_MCU_BUTTON_BASED_WAKEUP=1", ] + + if (si91x_alarm_based_wakeup) { + defines += [ + "SL_SI91X_MCU_ALARM_BASED_WAKEUP=1", + "ALARM_PERIODIC_TIME=${si91x_alarm_periodic_time}", + ] + } } if (chip_build_libshell) { # matter shell @@ -477,6 +496,13 @@ template("siwx917_sdk") { ] } + if (chip_enable_icd_server) { + sources += [ + "${sdk_support_root}/matter/si91x/siwx917/BRD4338A/support/src/sl_si91x_m4_ps.c", + "${wifi_sdk_root}/components/device/silabs/si91x/mcu/drivers/systemlevel/src/rsi_rtc.c", + "${wifi_sdk_root}/components/device/silabs/si91x/mcu/drivers/systemlevel/src/rsi_time_period.c", + ] + } public_deps = [ ":siwx917_mbedtls_config", "${segger_rtt_root}:segger_rtt", @@ -506,6 +532,9 @@ template("siwx917_sdk") { ] } - public_configs = [ ":${sdk_target_name}_config" ] + public_configs = [ + ":${sdk_target_name}_config", + "${examples_plat_dir}:siwx917-common-config", + ] } } diff --git a/third_party/silabs/matter_support b/third_party/silabs/matter_support index 0802242ab9ad37..73fcd8b084355b 160000 --- a/third_party/silabs/matter_support +++ b/third_party/silabs/matter_support @@ -1 +1 @@ -Subproject commit 0802242ab9ad37baac84df3621af3cbca754cfaf +Subproject commit 73fcd8b084355babbab333ebeaaa36323fdb4d8a diff --git a/third_party/silabs/silabs_board.gni b/third_party/silabs/silabs_board.gni index 55777dae54b5a7..5141824f50c599 100644 --- a/third_party/silabs/silabs_board.gni +++ b/third_party/silabs/silabs_board.gni @@ -108,8 +108,6 @@ if (silabs_board == "BRD4304A") { } else if (silabs_board == "BRD4338A") { silabs_family = "SiWx917-common" silabs_mcu = "SiWG917M111MGTBA" - disable_lcd = false - show_qr_code = true wifi_soc = true } else if (silabs_board == "BRD4180A") { assert(