Skip to content

Commit 64449a1

Browse files
[Silabs] Enabling Sleepy on 917 SoC device (project-chip#31299)
* sleep enabled on 917 soc * some cleanup and changes * removing alarm based wakeup by default and adding a parameter * cleanup of logging and updating matter support pointer * adding the header and removing the extern C * Restyled by whitespace * Restyled by clang-format * Restyled by gn * addressing the review comments * renaming the API name * adding the display enabled define * adding the config which was adding the define * Restyled by gn --------- Co-authored-by: Restyled.io <commits@restyled.io>
1 parent 1b6a04a commit 64449a1

File tree

11 files changed

+153
-34
lines changed

11 files changed

+153
-34
lines changed

examples/platform/silabs/MatterConfig.cpp

+7-1
Original file line numberDiff line numberDiff line change
@@ -296,5 +296,11 @@ CHIP_ERROR SilabsMatterConfig::InitWiFi(void)
296296
// ================================================================================
297297
extern "C" void vApplicationIdleHook(void)
298298
{
299-
// FreeRTOS Idle callback
299+
#if SIWX_917 && CHIP_CONFIG_ENABLE_ICD_SERVER
300+
if (ConnectivityMgr().IsWiFiStationConnected())
301+
{
302+
// Let the M4 sleep once commissioning is done and device is in idle state
303+
sl_wfx_host_si91x_sleep_wakeup();
304+
}
305+
#endif
300306
}

examples/platform/silabs/SiWx917/SiWx917/sl_wifi_if.c

+65-3
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,16 @@
4141

4242
#include "ble_config.h"
4343

44+
#if SL_ICD_ENABLED && SIWX_917
45+
#include "rsi_rom_power_save.h"
46+
#include "sl_si91x_button_pin_config.h"
47+
#include "sl_si91x_m4_ps.h"
48+
49+
// TODO: should be removed once we are getting the press interrupt for button 0 with sleep
50+
#define BUTTON_PRESSED 1
51+
bool btn0_pressed = false;
52+
#endif // SL_ICD_ENABLED && SIWX_917
53+
4454
#include "dhcp_client.h"
4555
#include "sl_wifi.h"
4656
#include "wfx_host_events.h"
@@ -203,6 +213,44 @@ sl_status_t join_callback_handler(sl_wifi_event_t event, char * result, uint32_t
203213
}
204214

205215
#if SL_ICD_ENABLED
216+
217+
#if SIWX_917
218+
/******************************************************************
219+
* @fn sl_wfx_host_si91x_sleep_wakeup()
220+
* @brief
221+
* M4 going to sleep
222+
*
223+
* @param[in] None
224+
* @return
225+
* None
226+
*********************************************************************/
227+
void sl_wfx_host_si91x_sleep_wakeup()
228+
{
229+
if (wfx_rsi.dev_state & WFX_RSI_ST_SLEEP_READY)
230+
{
231+
// TODO: should be removed once we are getting the press interrupt for button 0 with sleep
232+
if (!RSI_NPSSGPIO_GetPin(SL_BUTTON_BTN0_PIN) && !btn0_pressed)
233+
{
234+
sl_button_on_change(SL_BUTTON_BTN0_NUMBER, BUTTON_PRESSED);
235+
btn0_pressed = true;
236+
}
237+
if (RSI_NPSSGPIO_GetPin(SL_BUTTON_BTN0_PIN))
238+
{
239+
#ifdef DISPLAY_ENABLED
240+
// if LCD is enabled, power down the lcd before setting the M4 to sleep
241+
sl_si91x_hardware_setup();
242+
#endif
243+
btn0_pressed = false;
244+
/* Configure RAM Usage and Retention Size */
245+
sl_si91x_m4_sleep_wakeup();
246+
#if SILABS_LOG_ENABLED
247+
silabsInitLog();
248+
#endif
249+
}
250+
}
251+
}
252+
#endif /* SIWX_917 */
253+
206254
/******************************************************************
207255
* @fn wfx_rsi_power_save()
208256
* @brief
@@ -222,14 +270,14 @@ int32_t wfx_rsi_power_save()
222270
return status;
223271
}
224272

225-
sl_wifi_performance_profile_t wifi_profile = { ASSOCIATED_POWER_SAVE };
273+
sl_wifi_performance_profile_t wifi_profile = { .profile = ASSOCIATED_POWER_SAVE };
226274
status = sl_wifi_set_performance_profile(&wifi_profile);
227275
if (status != RSI_SUCCESS)
228276
{
229277
SILABS_LOG("Powersave Config Failed, Error Code : 0x%lX", status);
230278
return status;
231279
}
232-
SILABS_LOG("Powersave Config Success");
280+
wfx_rsi.dev_state |= WFX_RSI_ST_SLEEP_READY;
233281
return status;
234282
}
235283
#endif /* SL_ICD_ENABLED */
@@ -288,7 +336,17 @@ static sl_status_t wfx_rsi_init(void)
288336
SILABS_LOG("wfx_rsi_init failed %x", status);
289337
return status;
290338
}
291-
#endif
339+
#else // For SoC
340+
#if SL_ICD_ENABLED
341+
uint8_t xtal_enable = 1;
342+
status = sl_si91x_m4_ta_secure_handshake(SL_SI91X_ENABLE_XTAL, 1, &xtal_enable, 0, NULL);
343+
if (status != SL_STATUS_OK)
344+
{
345+
SILABS_LOG("Failed to bring m4_ta_secure_handshake: 0x%lx\r\n", status);
346+
return status;
347+
}
348+
#endif /* SL_ICD_ENABLED */
349+
#endif /* SLI_SI91X_MCU_INTERFACE */
292350

293351
sl_wifi_firmware_version_t version = { 0 };
294352
status = sl_wifi_get_firmware_version(&version);
@@ -524,6 +582,10 @@ static sl_status_t wfx_rsi_do_join(void)
524582

525583
sl_wifi_set_join_callback(join_callback_handler, NULL);
526584

585+
// Setting the listen interval to 0 which will set it to DTIM interval
586+
sl_wifi_listen_interval_t sleep_interval = { .listen_interval = 0 };
587+
status = sl_wifi_set_listen_interval(SL_WIFI_CLIENT_INTERFACE, sleep_interval);
588+
527589
/* Try to connect Wifi with given Credentials
528590
* untill there is a success or maximum number of tries allowed
529591
*/

examples/platform/silabs/SiWx917/SiWx917/sl_wlan_config.h

-2
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@
2828
//! Disable feature
2929
#define RSI_DISABLE 0
3030

31-
#define SI91X_LISTEN_INTERVAL 0
32-
3331
static const sl_wifi_device_configuration_t config = {
3432
.boot_option = LOAD_NWP_FW,
3533
.mac_address = NULL,

examples/platform/silabs/SiWx917/SiWx917/wfx_rsi.h

+5
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
#define WFX_RSI_ST_STA_READY (WFX_RSI_ST_STA_CONNECTED | WFX_RSI_ST_STA_DHCP_DONE)
5454
#define WFX_RSI_ST_STARTED (0x200) /* RSI task started */
5555
#define WFX_RSI_ST_SCANSTARTED (0x400) /* Scan Started */
56+
#define WFX_RSI_ST_SLEEP_READY (0x800) /* Notify the M4 to go to sleep*/
5657

5758
struct wfx_rsi
5859
{
@@ -92,6 +93,10 @@ int32_t wfx_rsi_get_ap_ext(wfx_wifi_scan_ext_t * extra_info);
9293
int32_t wfx_rsi_reset_count();
9394
int32_t wfx_rsi_disconnect();
9495
int32_t wfx_wifi_rsi_init(void);
96+
#if SL_ICD_ENABLED
97+
void sl_wfx_host_si91x_sleep_wakeup();
98+
int32_t wfx_rsi_power_save();
99+
#endif /* SL_ICD_ENABLED */
95100

96101
#ifdef __cplusplus
97102
}

examples/platform/silabs/display/demo-ui.c

+4
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "dmd/dmd.h"
2424
#include "em_types.h"
2525
#include "glib.h"
26+
#include "sl_memlcd.h"
2627
#if SL_WIFI && !SIWX_917
2728
#include "spi_multiplex.h"
2829
#endif // SL_WIFI && !SIWX_917
@@ -102,6 +103,9 @@ void demoUIInit(GLIB_Context_t * context)
102103

103104
sl_status_t updateDisplay(void)
104105
{
106+
#if SIWX_917 && SL_ICD_ENABLED && DISPLAY_ENABLED
107+
sl_memlcd_post_wakeup_init();
108+
#endif // SIWX_917 && SL_ICD_ENABLED && DISPLAY_ENABLED
105109
#if SL_LCDCTRL_MUX
106110
sl_wfx_host_pre_lcd_spi_transfer();
107111
#endif // SL_LCDCTRL_MUX

scripts/examples/gn_silabs_example.sh

+4
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,10 @@ if [ "$#" == "0" ]; then
113113
Use provided hardware version at build time
114114
siwx917_commissionable_data
115115
Build with the commissionable data given in DeviceConfig.h (only for SiWx917)
116+
si91x_alarm_based_wakeup
117+
Enable the Alarm Based Wakeup for 917 SoC when sleep is enabled (Default false)
118+
si91x_alarm_periodic_time
119+
Periodic time at which the 917 SoC should wakeup (Default: 30sec)
116120
Presets
117121
--icd
118122
enable ICD features, set thread mtd

src/platform/silabs/KeyValueStoreManagerImpl.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,15 @@ void KeyValueStoreManagerImpl::ScheduleKeyMapSave(void)
164164
During commissioning, the key map will be modified multiples times subsequently.
165165
Commit the key map in nvm once it as stabilized.
166166
*/
167+
#if SIWX_917 && CHIP_CONFIG_ENABLE_ICD_SERVER
168+
// TODO: Remove this when RTC timer is added MATTER-2705
169+
SilabsConfig::WriteConfigValueBin(SilabsConfig::kConfigKey_KvsStringKeyMap, reinterpret_cast<const uint8_t *>(mKvsKeyMap),
170+
sizeof(mKvsKeyMap));
171+
#else
167172
SystemLayer().StartTimer(
168173
std::chrono::duration_cast<System::Clock::Timeout>(System::Clock::Seconds32(SILABS_KVS_SAVE_DELAY_SECONDS)),
169174
KeyValueStoreManagerImpl::OnScheduledKeyMapSave, NULL);
175+
#endif // defined(SIWX_917) && CHIP_CONFIG_ENABLE_ICD_SERVER
170176
}
171177

172178
CHIP_ERROR KeyValueStoreManagerImpl::_Get(const char * key, void * value, size_t value_size, size_t * read_bytes_size,

src/platform/silabs/rs911x/BLEManagerImpl.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,13 @@ void sl_ble_event_handling_task(void)
182182
default:
183183
break;
184184
}
185+
186+
if (chip::DeviceLayer::ConnectivityMgr().IsWiFiStationConnected())
187+
{
188+
// Once DUT is connected adding a 500ms delay
189+
// TODO: Fix this with a better event handling
190+
vTaskDelay(pdMS_TO_TICKS(500));
191+
}
185192
}
186193
}
187194

third_party/silabs/SiWx917_sdk.gni

+54-25
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@ import("silabs_board.gni")
2424

2525
examples_plat_dir = "${chip_root}/examples/platform/silabs/SiWx917"
2626

27+
declare_args() {
28+
# Enable the Alarm Based Wakeup for 917 SoC when sleep is enabled
29+
si91x_alarm_based_wakeup = false
30+
31+
# Periodic time at which the 917 SoC should wakeup
32+
si91x_alarm_periodic_time = 30
33+
}
34+
2735
# Defines an siwx917 SDK build target.
2836
#
2937
# Parameters:
@@ -147,12 +155,12 @@ template("siwx917_sdk") {
147155
"SILABS_LOG_ENABLED=${silabs_log_enabled}",
148156
"SL_HEAP_SIZE=32768",
149157
"SL_WIFI=1",
150-
"CCP_SI917_BRINGUP",
158+
"CCP_SI917_BRINGUP=1",
151159
"SL_COMPONENT_CATALOG_PRESENT",
152-
"RS911X_WIFI",
160+
"RS911X_WIFI=1",
153161
"RSI_WLAN_ENABLE",
154-
"SLI_SI91X_ENABLE_OS",
155-
"SLI_SI91X_MCU_INTERFACE", #Enable CCP bus Interface
162+
"SLI_SI91X_ENABLE_OS=1",
163+
"SLI_SI91X_MCU_INTERFACE=1", #Enable CCP bus Interface
156164
"RSI_WLAN_API_ENABLE",
157165
"NVM3_DEFAULT_NVM_SIZE=40960",
158166
"NVM3_DEFAULT_MAX_OBJECT_SIZE=4092",
@@ -163,43 +171,46 @@ template("siwx917_sdk") {
163171
"__HEAP_SIZE=0",
164172
"PLATFORM_HEADER=\"platform-header.h\"",
165173
"USE_NVM3=1",
166-
"RSI_ARM_CM4F",
167-
"SIWX_917",
168-
"CHIP_9117",
174+
"SIWX_917=1",
175+
"CHIP_9117=1",
169176
"SLI_SI91X_ENABLE_BLE=1",
170177
"SL_SI91X_ENABLE_LITTLE_ENDIAN=1",
171178
"TINYCRYPT_PRIMITIVES",
172179
"OPTIMIZE_TINYCRYPT_ASM",
173180
"__error_t_defined",
174181
"RSI_SAMPLE_HAL",
175-
"ENABLE_IPMU_APIS",
176-
"SLI_SI91X_MCU_MOV_ROM_API_TO_FLASH",
177-
"DEBUG_UART",
178-
"SLI_SI91X_MCU_ENABLE_FLASH_BASED_EXECUTION",
179-
"SL_WIFI_COMPONENT_INCLUDED",
182+
"DEBUG_UART=1",
183+
"SLI_SI91X_MCU_ENABLE_FLASH_BASED_EXECUTION=1",
184+
"SL_WIFI_COMPONENT_INCLUDED=1",
180185
"SLI_SI917=1",
186+
"SI917=1",
181187
"ROMDRIVER_PRESENT=1",
182188
"SL_CATALOG_FREERTOS_KERNEL_PRESENT=1",
183-
"SL_PLATFORM_EXAMPLES_ENABLE",
184189
"SLI_SI91X_MCU_CONFIG_RADIO_BOARD_BASE_VER=1",
185-
"FLASH_PAGE_SIZE",
186-
"SL_NVM3_PRESENT",
187-
"ROM_WIRELESS",
188190
"BRD4325A", #TODO: should be removed after SoC macro clean-up
189-
"CONNECTIVITY_PLATFORM",
190-
"SLI_SI917B0 = 1",
191+
"SLI_SI917B0=1",
191192
"SLI_SI91X_MCU_COMMON_FLASH_MODE=1",
192-
"EXECUTION_FROM_RAM",
193193
"SLI_SI91X_MCU_CONFIG_RADIO_BOARD_VER2=1",
194194
"SL_BOARD_REV=\"A00\"",
195195
"SPI_MULTI_SLAVE=1",
196196
"SYSCALLS_WRITE=1",
197-
"SI91X_SYSRTC_COUNT=1",
198-
"SSI_ULP_MASTER=1",
199-
"SL_MEMLCD_EXTCOMIN_PORT=0",
200197
"__STATIC_INLINE=static inline",
201-
"SL_SI91X_SI917_RAM_MEM_CONFIG=3",
198+
"SL_SI91X_SI917_RAM_MEM_CONFIG=2",
202199
"SL_SI91x_DUAL_INTERRUPTS_ERRATA=1",
200+
"EXT_IRQ_COUNT=75",
201+
"FLASH_PAGE_SIZE=1",
202+
"DEBUG_ENABLE=1",
203+
"ENABLE_DEBUG_MODULE=1",
204+
"SI91X_SYSRTC_PRESENT=1",
205+
"TA_DEEP_SLEEP_COMMON_FLASH=1",
206+
"SI917_SOC=1",
207+
"SI91X_PLATFORM=1",
208+
"SL_NET_COMPONENT_INCLUDED=1",
209+
"SRAM_BASE=0x0cUL",
210+
"SRAM_SIZE=0x4fc00UL",
211+
"SLI_SI91X_MCU_ENABLE_IPMU_APIS=1",
212+
"RADIO_CONFIG_DMP_SUPPORT=1",
213+
"configUSE_POSIX_ERRNO=1",
203214
]
204215

205216
if (chip_build_libshell) {
@@ -254,13 +265,21 @@ template("siwx917_sdk") {
254265

255266
if (chip_enable_icd_server) {
256267
defines += [
257-
"WIFI_DEBUG_ENABLED=1",
258268
"SL_ICD_ENABLED=1",
259269
"SL_ACTIVE_MODE_THRESHOLD=${sl_active_mode_threshold_ms}",
260270
"SL_ACTIVE_MODE_INTERVAL=${sl_active_mode_interval_ms}",
261271
"SL_IDLE_MODE_INTERVAL=${sl_idle_mode_interval_s}",
262272
"SL_ICD_SUPPORTED_CLIENTS_PER_FABRIC=${sl_icd_supported_clients_per_fabric}",
273+
"SL_SI91X_MCU_WIRELESS_BASED_WAKEUP=1",
274+
"SL_SI91X_MCU_BUTTON_BASED_WAKEUP=1",
263275
]
276+
277+
if (si91x_alarm_based_wakeup) {
278+
defines += [
279+
"SL_SI91X_MCU_ALARM_BASED_WAKEUP=1",
280+
"ALARM_PERIODIC_TIME=${si91x_alarm_periodic_time}",
281+
]
282+
}
264283
}
265284

266285
if (chip_build_libshell) { # matter shell
@@ -477,6 +496,13 @@ template("siwx917_sdk") {
477496
]
478497
}
479498

499+
if (chip_enable_icd_server) {
500+
sources += [
501+
"${sdk_support_root}/matter/si91x/siwx917/BRD4338A/support/src/sl_si91x_m4_ps.c",
502+
"${wifi_sdk_root}/components/device/silabs/si91x/mcu/drivers/systemlevel/src/rsi_rtc.c",
503+
"${wifi_sdk_root}/components/device/silabs/si91x/mcu/drivers/systemlevel/src/rsi_time_period.c",
504+
]
505+
}
480506
public_deps = [
481507
":siwx917_mbedtls_config",
482508
"${segger_rtt_root}:segger_rtt",
@@ -506,6 +532,9 @@ template("siwx917_sdk") {
506532
]
507533
}
508534

509-
public_configs = [ ":${sdk_target_name}_config" ]
535+
public_configs = [
536+
":${sdk_target_name}_config",
537+
"${examples_plat_dir}:siwx917-common-config",
538+
]
510539
}
511540
}

third_party/silabs/silabs_board.gni

-2
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,6 @@ if (silabs_board == "BRD4304A") {
108108
} else if (silabs_board == "BRD4338A") {
109109
silabs_family = "SiWx917-common"
110110
silabs_mcu = "SiWG917M111MGTBA"
111-
disable_lcd = false
112-
show_qr_code = true
113111
wifi_soc = true
114112
} else if (silabs_board == "BRD4180A") {
115113
assert(

0 commit comments

Comments
 (0)