Skip to content

Commit a475d54

Browse files
[Silabs] Enabling sleepy for 917soc with power manager (#34086)
* Enabling sleepy for 917soc with power manager * removing the commentted code * Restyled by clang-format * Restyled by gn * moving the files from .o to .c.o * updating with matter support pointer * warning skip to fix the ncp lwip sleepy * Restyled by gn * Removing the warning error to only the specified error --------- Co-authored-by: Restyled.io <commits@restyled.io>
1 parent 71d9f61 commit a475d54

File tree

10 files changed

+75
-107
lines changed

10 files changed

+75
-107
lines changed

examples/platform/silabs/FreeRTOSConfig.h

+15-14
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,10 @@ extern "C" {
110110
#ifdef SLI_SI91X_MCU_INTERFACE
111111
#include "si91x_device.h"
112112
extern uint32_t SystemCoreClock;
113-
#else // For EFR32
113+
#if SL_ICD_ENABLED
114+
#include "sl_si91x_m4_ps.h"
115+
#endif // SL_ICD_ENABLED
116+
#else // For EFR32
114117
#include "RTE_Components.h"
115118
#include CMSIS_device_header
116119

@@ -141,21 +144,18 @@ extern uint32_t SystemCoreClock;
141144
/* Energy saving modes. */
142145
#if defined(SL_CATALOG_POWER_MANAGER_PRESENT)
143146
#define configUSE_TICKLESS_IDLE 1
144-
#elif SL_ICD_ENABLED && SI917_M4_SLEEP_ENABLED
147+
#elif (SLI_SI91X_MCU_INTERFACE && SL_ICD_ENABLED)
145148
#define configUSE_TICKLESS_IDLE 1
146149
#define configEXPECTED_IDLE_TIME_BEFORE_SLEEP 70
147-
#define configPRE_SUPPRESS_TICKS_AND_SLEEP_PROCESSING(x) vTaskPreSuppressTicksAndSleepProcessing(&x)
148-
#define configPRE_SLEEP_PROCESSING(x) sl_wfx_host_si91x_sleep(&x)
149-
#define configPOST_SLEEP_PROCESSING(x) sl_si91x_post_sleep_update_ticks(&x)
150+
#define configPRE_SLEEP_PROCESSING(x)
151+
#define configPOST_SLEEP_PROCESSING(x)
152+
#define configPRE_SUPPRESS_TICKS_AND_SLEEP_PROCESSING(x) sl_si91x_pre_supress_ticks_and_sleep(&x)
150153
#else
151154
#define configUSE_TICKLESS_IDLE 0
152155
#endif // SL_CATALOG_POWER_MANAGER_PRESENT
153156

154-
#if defined(SLI_SI91X_MCU_INTERFACE)
155-
#define configTICK_RATE_HZ (1000)
156-
#else
157157
#define configTICK_RATE_HZ (1024)
158-
#endif // SLI_SI91X_MCU_INTERFACE
158+
159159
/* Definition used by Keil to replace default system clock source. */
160160
#define configOVERRIDE_DEFAULT_TICK_CONFIGURATION 1
161161

@@ -175,7 +175,11 @@ extern uint32_t SystemCoreClock;
175175

176176
/* Software timer related definitions. */
177177
#define configUSE_TIMERS (1)
178+
#ifdef SLI_SI917
179+
#define configTIMER_TASK_PRIORITY (55) /* Highest priority */
180+
#else
178181
#define configTIMER_TASK_PRIORITY (40) /* Highest priority */
182+
#endif // SLI_SI917
179183
#define configTIMER_QUEUE_LENGTH (10)
180184
#define configTIMER_TASK_STACK_DEPTH (1024)
181185

@@ -211,11 +215,8 @@ See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */
211215
#define configUSE_PORT_OPTIMISED_TASK_SELECTION (0)
212216
#define configUSE_TICKLESS_IDLE_SIMPLE_DEBUG (1) /* See into vPortSuppressTicksAndSleep source code for explanation */
213217
#define configMAX_PRIORITIES (56)
214-
#if SLI_SI91X_MCU_INTERFACE && SL_ICD_ENABLED
215-
#define configMINIMAL_STACK_SIZE (1024) /* Number of words to use for Idle and Timer stacks */
216-
#else // For EFR32
217-
#define configMINIMAL_STACK_SIZE (320) /* Number of words to use for Idle and Timer stacks */
218-
#endif // SLI_SI91X_MCU_INTERFACE && SL_ICD_ENABLED
218+
#define configMINIMAL_STACK_SIZE (320) /* Number of words to use for Idle and Timer stacks */
219+
219220
#ifdef HEAP_MONITORING
220221
#define configMAX_TASK_NAME_LEN (24)
221222
#else

examples/platform/silabs/MatterConfig.cpp

+4-61
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,7 @@
4343

4444
#ifdef SLI_SI91X_MCU_INTERFACE
4545
#include "wfx_rsi.h"
46-
#if CHIP_CONFIG_ENABLE_ICD_SERVER && SI917_M4_SLEEP_ENABLED
47-
#include "rsi_m4.h"
48-
#endif // CHIP_CONFIG_ENABLE_ICD_SERVER && SI917_M4_SLEEP_ENABLED
49-
#endif // SLI_SI91X_MCU_INTERFACE
46+
#endif /* SLI_SI91X_MCU_INTERFACE */
5047

5148
#include <crypto/CHIPCryptoPAL.h>
5249
// If building with the EFR32-provided crypto backend, we can use the
@@ -356,63 +353,9 @@ CHIP_ERROR SilabsMatterConfig::InitWiFi(void)
356353
// ================================================================================
357354
// FreeRTOS Callbacks
358355
// ================================================================================
359-
#if CHIP_CONFIG_ENABLE_ICD_SERVER && SI917_M4_SLEEP_ENABLED
360-
static bool is_sleep_ready = false;
361-
void vTaskPreSuppressTicksAndSleepProcessing(uint16_t * xExpectedIdleTime)
362-
{
363-
// pointer check
364-
if (xExpectedIdleTime == NULL)
365-
{
366-
return;
367-
}
368-
369-
if (!is_sleep_ready)
370-
{
371-
*xExpectedIdleTime = 0;
372-
}
373-
else
374-
{
375-
// a preliminary check of the expected idle time is performed without making M4 inactive
376-
if (*xExpectedIdleTime >= configEXPECTED_IDLE_TIME_BEFORE_SLEEP)
377-
{
378-
// Indicate M4 is Inactive
379-
P2P_STATUS_REG &= ~M4_is_active;
380-
// Waiting for one more clock cycle to make sure M4 H/W Register is updated
381-
P2P_STATUS_REG;
382-
383-
// TODO: This delay is added to sync between M4 and TA. It should be removed once the logic is moved to wifi SDK
384-
for (uint8_t delay = 0; delay < 10; delay++)
385-
{
386-
__ASM("NOP");
387-
}
388-
// Checking if TA has already triggered a packet to M4
389-
// RX_BUFFER_VALID will be cleared by TA if any packet is triggered
390-
if ((P2P_STATUS_REG & TA_wakeup_M4) || (P2P_STATUS_REG & M4_wakeup_TA) || (!(M4SS_P2P_INTR_SET_REG & RX_BUFFER_VALID)))
391-
{
392-
P2P_STATUS_REG |= M4_is_active;
393-
*xExpectedIdleTime = 0;
394-
}
395-
else
396-
{
397-
M4SS_P2P_INTR_CLR_REG = RX_BUFFER_VALID;
398-
M4SS_P2P_INTR_CLR_REG;
399-
400-
TASS_P2P_INTR_MASK_SET = (TX_PKT_TRANSFER_DONE_INTERRUPT | RX_PKT_TRANSFER_DONE_INTERRUPT |
401-
TA_WRITING_ON_COMM_FLASH | NWP_DEINIT_IN_COMM_FLASH
402-
#ifdef SL_SI91X_SIDE_BAND_CRYPTO
403-
| SIDE_BAND_CRYPTO_DONE
404-
#endif
405-
);
406-
}
407-
}
408-
}
409-
}
410-
#endif // CHIP_CONFIG_ENABLE_ICD_SERVER && SI917_M4_SLEEP_ENABLED
411356
extern "C" void vApplicationIdleHook(void)
412357
{
413-
#if CHIP_CONFIG_ENABLE_ICD_SERVER && SI917_M4_SLEEP_ENABLED
414-
invoke_btn_press_event();
415-
// is_sleep_ready is required since wfx_is_sleep_ready() is not FreeRTOS scheduler agnostic
416-
is_sleep_ready = wfx_is_sleep_ready();
417-
#endif // CHIP_CONFIG_ENABLE_ICD_SERVER && SI917_M4_SLEEP_ENABLED
358+
#if (SLI_SI91X_MCU_INTERFACE && CHIP_CONFIG_ENABLE_ICD_SERVER)
359+
sl_si91x_invoke_btn_press_event();
360+
#endif
418361
}

examples/platform/silabs/SiWx917/BUILD.gn

+1
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ source_set("siwx917-common") {
178178
public_configs = [
179179
":siwx917-common-config",
180180
"${efr32_sdk_build_root}:silabs_config",
181+
":chip_examples_project_config",
181182
]
182183

183184
include_dirs = [

examples/platform/silabs/ldscripts/SiWx917-common.ld

+25-25
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ SECTIONS
4040
{
4141
KEEP(*(.isr_vector))
4242
KEEP(*(.reset_handler))
43-
*(EXCLUDE_FILE(*sl_si91x_bus.o *sl_si91x_driver.o *sli_si91x_multithreaded.o *rsi_hal_mcu_m4_ram.o *rsi_hal_mcu_m4_rom.o *rsi_deepsleep_soc.o *croutine.o *event_groups.o *list.o *queue.o *stream_buffer.o *tasks.o *timers.o *cmsis_os2.o *freertos_umm_malloc_host.o *malloc_buffers.o *sl_rsi_utility.o *port.o *sl_sleeptimer.o *sl_sleeptimer_hal_si91x_sysrtc.o *rsi_sysrtc.o *sl_si91x_low_power_tickless_mode.o *heap_*.o *sl_core_cortexm.o) .text*)
43+
*(EXCLUDE_FILE(*sl_si91x_bus.c.o *sl_si91x_driver.c.o *sli_si91x_multithreaded.c.o *rsi_hal_mcu_m4_ram.c.o *rsi_hal_mcu_m4_rom.c.o *rsi_deepsleep_soc.c.o *croutine.c.o *event_groups.c.o *list.c.o *queue.c.o *stream_buffer.c.o *tasks.c.o *timers.c.o *cmsis_os2.c.o *freertos_umm_malloc_host.c.o *malloc_buffers.c.o *sl_rsi_utility.c.o *port.c.o *sl_sleeptimer.c.o *sl_sleeptimer_hal_si91x_sysrtc.c.o *rsi_sysrtc.c.o *sl_si91x_low_power_tickless_mode.c.o *heap_*.c.o *sl_core_cortexm.c.o) .text*)
4444

4545
/* .ctors */
4646
*crtbegin.o(.ctors)
@@ -127,30 +127,30 @@ SECTIONS
127127
*(.rodata*)
128128
*(vtable)
129129
*(.data*)
130-
*sl_si91x_bus.o(.text*)
131-
*sl_si91x_driver.o(.text*)
132-
*sli_si91x_multithreaded.o(.text*)
133-
*rsi_hal_mcu_m4_ram.o(.text*)
134-
*rsi_hal_mcu_m4_rom.o(.text*)
135-
*rsi_deepsleep_soc.o(.text*)
136-
*croutine.o(.text*)
137-
*event_groups.o(.text*)
138-
*list.o(.text*)
139-
*queue.o(.text*)
140-
*cmsis_os2.o(.text*)
141-
*stream_buffer.o(.text*)
142-
*tasks.o(.text*)
143-
*timers.o(.text*)
144-
*freertos_umm_malloc_host.o(.text*)
145-
*malloc_buffers.o(.text*)
146-
*sl_rsi_utility.o(.text*)
147-
*port.o(.text*)
148-
*heap_*.o(.text*)
149-
*sl_sleeptimer.o(.text*)
150-
*sl_sleeptimer_hal_si91x_sysrtc.o(.text*)
151-
*rsi_sysrtc.o(.text*)
152-
*sl_si91x_low_power_tickless_mode.o(.text*)
153-
*sl_core_cortexm.o(.text*)
130+
*sl_si91x_bus.c.o(.text*)
131+
*sl_si91x_driver.c.o(.text*)
132+
*sli_si91x_multithreaded.c.o(.text*)
133+
*rsi_hal_mcu_m4_ram.c.o(.text*)
134+
*rsi_hal_mcu_m4_rom.c.o(.text*)
135+
*rsi_deepsleep_soc.c.o(.text*)
136+
*croutine.c.o(.text*)
137+
*event_groups.c.o(.text*)
138+
*list.c.o(.text*)
139+
*queue.c.o(.text*)
140+
*cmsis_os2.c.o(.text*)
141+
*stream_buffer.c.o(.text*)
142+
*tasks.c.o(.text*)
143+
*timers.c.o(.text*)
144+
*freertos_umm_malloc_host.c.o(.text*)
145+
*malloc_buffers.c.o(.text*)
146+
*sl_rsi_utility.c.o(.text*)
147+
*port.c.o(.text*)
148+
*heap_*.c.o(.text*)
149+
*sl_sleeptimer.c.o(.text*)
150+
*sl_sleeptimer_hal_si91x_sysrtc.c.o(.text*)
151+
*rsi_sysrtc.c.o(.text*)
152+
*sl_si91x_low_power_tickless_mode.c.o(.text*)
153+
*sl_core_cortexm.c.o(.text*)
154154

155155
. = ALIGN(4);
156156
/* preinit data */

examples/platform/silabs/wfx_rsi.h

+5-2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
*/
1717
#pragma once
1818

19+
#include <app/icd/server/ICDServerConfig.h>
1920
#include <event_groups.h>
2021
#include <wfx_host_events.h>
2122

@@ -112,8 +113,10 @@ int32_t wfx_rsi_get_ap_ext(wfx_wifi_scan_ext_t * extra_info);
112113
int32_t wfx_rsi_reset_count();
113114
int32_t wfx_rsi_disconnect();
114115
int32_t wfx_wifi_rsi_init(void);
115-
#if SL_ICD_ENABLED
116-
void sl_wfx_host_si91x_sleep_wakeup();
116+
#if CHIP_CONFIG_ENABLE_ICD_SERVER
117+
#if SLI_SI91X_MCU_INTERFACE
118+
void sl_si91x_invoke_btn_press_event();
119+
#endif // SLI_SI91X_MCU_INTERFACE
117120
#if SLI_SI917
118121
int32_t wfx_rsi_power_save(rsi_power_save_profile_mode_t sl_si91x_ble_state, sl_si91x_performance_profile_t sl_si91x_wifi_state);
119122
#else

src/lwip/silabs/lwipopts-rs911x.h

+4
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,10 @@
158158
#define DEFAULT_UDP_RECVMBOX_SIZE 6
159159
#define DEFAULT_TCP_RECVMBOX_SIZE 6
160160

161+
#if SL_ICD_ENABLED
162+
#define SL_LWIP_MLD6_TIMERS_ONDEMAND 1
163+
#endif // CHIP_CONFIG_ENABLE_ICD_SERVER
164+
161165
#ifdef LWIP_DEBUG
162166

163167
#define MEMP_OVERFLOW_CHECK (0)

src/lwip/silabs/lwipopts-wf200.h

+4
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,10 @@
159159
#define DEFAULT_UDP_RECVMBOX_SIZE 6
160160
#define DEFAULT_TCP_RECVMBOX_SIZE 6
161161

162+
#if SL_ICD_ENABLED
163+
#define SL_LWIP_MLD6_TIMERS_ONDEMAND 1
164+
#endif // CHIP_CONFIG_ENABLE_ICD_SERVER
165+
162166
#ifdef LWIP_DEBUG
163167

164168
#define MEMP_OVERFLOW_CHECK (0)

third_party/silabs/SiWx917_sdk.gni

+12-4
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,8 @@ template("siwx917_sdk") {
160160
"${wifi_sdk_root}/components/device/silabs/si91x/wireless/firmware_upgrade",
161161
"${wifi_sdk_root}/components/device/silabs/si91x/mcu/hal/inc",
162162
"${wifi_sdk_root}/components/device/silabs/si91x/mcu/drivers/systemlevel/inc",
163+
164+
"${wifi_sdk_root}/components/device/silabs/si91x/mcu/drivers/service/power_manager/inc",
163165
]
164166

165167
if (use_system_view) {
@@ -307,9 +309,9 @@ template("siwx917_sdk") {
307309
"SL_ACTIVE_MODE_DURATION_MS=${sl_active_mode_duration_ms}",
308310
"SL_IDLE_MODE_DURATION_S=${sl_idle_mode_duration_s}",
309311
"SL_ICD_SUPPORTED_CLIENTS_PER_FABRIC=${sl_icd_supported_clients_per_fabric}",
310-
"SL_SI91X_MCU_WIRELESS_BASED_WAKEUP=1",
311-
"SL_SI91X_MCU_BUTTON_BASED_WAKEUP=1",
312-
"SL_SI91X_MCU_ALARM_BASED_WAKEUP=1",
312+
"SL_SI91X_NPSS_GPIO_BTN_HANDLER=1",
313+
"SL_SI91X_POWER_MANAGER_UC_AVAILABLE=1",
314+
"SL_SI91X_TICKLESS_MODE=1",
313315
]
314316

315317
if (si91x_alarm_based_periodic_wakeup) {
@@ -644,6 +646,7 @@ template("siwx917_sdk") {
644646
"${wifi_sdk_root}/components/board/silabs/src/rsi_board.c",
645647
"${wifi_sdk_root}/components/common/src/sl_utility.c",
646648
"${wifi_sdk_root}/components/device/silabs/si91x/mcu/core/chip/src/rsi_deepsleep_soc.c",
649+
"${wifi_sdk_root}/components/device/silabs/si91x/mcu/core/chip/src/rsi_ps_ram_func.c",
647650
"${wifi_sdk_root}/components/device/silabs/si91x/mcu/core/chip/src/rsi_system_config.c",
648651
"${wifi_sdk_root}/components/device/silabs/si91x/mcu/core/chip/src/system_si91x.c",
649652
"${wifi_sdk_root}/components/device/silabs/si91x/mcu/core/common/src/rsi_debug.c",
@@ -769,9 +772,14 @@ template("siwx917_sdk") {
769772

770773
if (chip_enable_icd_server) {
771774
sources += [
775+
"${sdk_support_root}/matter/si91x/siwx917/BRD4338A/autogen/sl_si91x_power_manager_handler.c",
776+
"${sdk_support_root}/matter/si91x/siwx917/BRD4338A/autogen/sl_si91x_power_manager_wakeup_handler.c",
772777
"${wifi_sdk_root}/components/device/silabs/si91x/mcu/drivers/peripheral_drivers/src/sl_si91x_m4_ps.c",
773-
"${wifi_sdk_root}/components/device/silabs/si91x/mcu/drivers/systemlevel/src/rsi_rtc.c",
778+
"${wifi_sdk_root}/components/device/silabs/si91x/mcu/drivers/service/power_manager/src/sl_si91x_power_manager.c",
779+
"${wifi_sdk_root}/components/device/silabs/si91x/mcu/drivers/service/power_manager/src/sli_si91x_power_manager.c",
780+
"${wifi_sdk_root}/components/device/silabs/si91x/mcu/drivers/service/power_manager/src/sli_si91x_power_manager_wakeup_init.c",
774781
"${wifi_sdk_root}/components/device/silabs/si91x/mcu/drivers/systemlevel/src/rsi_time_period.c",
782+
"${wifi_sdk_root}/third_party/silicon_labs/freertos/src/sl_si91x_low_power_tickless_mode.c",
775783
]
776784
}
777785

third_party/silabs/efr32_sdk.gni

+4
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,10 @@ template("efr32_sdk") {
480480
# TODO: Remove this flag, once the communication is fixed
481481
"WIFI_DEBUG_ENABLED=1",
482482
]
483+
484+
# This is kept due to the warning on the LWIP when on demand timer is added
485+
# TODO: remove this flag once the warning is fixed in SiSDK MATTER-3946
486+
cflags_c = [ "-Wno-implicit-function-declaration" ]
483487
}
484488
}
485489

0 commit comments

Comments
 (0)