Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Silabs] Enabling sleepy for 917soc with power manager #34086

Merged
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 15 additions & 14 deletions examples/platform/silabs/FreeRTOSConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,10 @@ extern "C" {
#ifdef SLI_SI91X_MCU_INTERFACE
#include "si91x_device.h"
extern uint32_t SystemCoreClock;
#else // For EFR32
#if SL_ICD_ENABLED
#include "sl_si91x_m4_ps.h"
#endif // SL_ICD_ENABLED
#else // For EFR32
#include "RTE_Components.h"
#include CMSIS_device_header

Expand Down Expand Up @@ -141,21 +144,18 @@ extern uint32_t SystemCoreClock;
/* Energy saving modes. */
#if defined(SL_CATALOG_POWER_MANAGER_PRESENT)
#define configUSE_TICKLESS_IDLE 1
#elif SL_ICD_ENABLED && SI917_M4_SLEEP_ENABLED
#elif (SLI_SI91X_MCU_INTERFACE && SL_ICD_ENABLED)
#define configUSE_TICKLESS_IDLE 1
#define configEXPECTED_IDLE_TIME_BEFORE_SLEEP 70
#define configPRE_SUPPRESS_TICKS_AND_SLEEP_PROCESSING(x) vTaskPreSuppressTicksAndSleepProcessing(&x)
#define configPRE_SLEEP_PROCESSING(x) sl_wfx_host_si91x_sleep(&x)
#define configPOST_SLEEP_PROCESSING(x) sl_si91x_post_sleep_update_ticks(&x)
#define configPRE_SLEEP_PROCESSING(x)
#define configPOST_SLEEP_PROCESSING(x)
#define configPRE_SUPPRESS_TICKS_AND_SLEEP_PROCESSING(x) sl_si91x_pre_supress_ticks_and_sleep(&x)
#else
#define configUSE_TICKLESS_IDLE 0
#endif // SL_CATALOG_POWER_MANAGER_PRESENT

#if defined(SLI_SI91X_MCU_INTERFACE)
#define configTICK_RATE_HZ (1000)
#else
#define configTICK_RATE_HZ (1024)
#endif // SLI_SI91X_MCU_INTERFACE

/* Definition used by Keil to replace default system clock source. */
#define configOVERRIDE_DEFAULT_TICK_CONFIGURATION 1

Expand All @@ -175,7 +175,11 @@ extern uint32_t SystemCoreClock;

/* Software timer related definitions. */
#define configUSE_TIMERS (1)
#ifdef SLI_SI917
#define configTIMER_TASK_PRIORITY (55) /* Highest priority */
#else
#define configTIMER_TASK_PRIORITY (40) /* Highest priority */
#endif // SLI_SI917
#define configTIMER_QUEUE_LENGTH (10)
#define configTIMER_TASK_STACK_DEPTH (1024)

Expand Down Expand Up @@ -211,11 +215,8 @@ See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */
#define configUSE_PORT_OPTIMISED_TASK_SELECTION (0)
#define configUSE_TICKLESS_IDLE_SIMPLE_DEBUG (1) /* See into vPortSuppressTicksAndSleep source code for explanation */
#define configMAX_PRIORITIES (56)
#if SLI_SI91X_MCU_INTERFACE && SL_ICD_ENABLED
#define configMINIMAL_STACK_SIZE (1024) /* Number of words to use for Idle and Timer stacks */
#else // For EFR32
#define configMINIMAL_STACK_SIZE (320) /* Number of words to use for Idle and Timer stacks */
#endif // SLI_SI91X_MCU_INTERFACE && SL_ICD_ENABLED
#define configMINIMAL_STACK_SIZE (320) /* Number of words to use for Idle and Timer stacks */

#ifdef HEAP_MONITORING
#define configMAX_TASK_NAME_LEN (24)
#else
Expand Down
65 changes: 4 additions & 61 deletions examples/platform/silabs/MatterConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,7 @@

#ifdef SLI_SI91X_MCU_INTERFACE
#include "wfx_rsi.h"
#if CHIP_CONFIG_ENABLE_ICD_SERVER && SI917_M4_SLEEP_ENABLED
#include "rsi_m4.h"
#endif // CHIP_CONFIG_ENABLE_ICD_SERVER && SI917_M4_SLEEP_ENABLED
#endif // SLI_SI91X_MCU_INTERFACE
#endif /* SLI_SI91X_MCU_INTERFACE */

#include <crypto/CHIPCryptoPAL.h>
// If building with the EFR32-provided crypto backend, we can use the
Expand Down Expand Up @@ -356,63 +353,9 @@ CHIP_ERROR SilabsMatterConfig::InitWiFi(void)
// ================================================================================
// FreeRTOS Callbacks
// ================================================================================
#if CHIP_CONFIG_ENABLE_ICD_SERVER && SI917_M4_SLEEP_ENABLED
static bool is_sleep_ready = false;
void vTaskPreSuppressTicksAndSleepProcessing(uint16_t * xExpectedIdleTime)
{
// pointer check
if (xExpectedIdleTime == NULL)
{
return;
}

if (!is_sleep_ready)
{
*xExpectedIdleTime = 0;
}
else
{
// a preliminary check of the expected idle time is performed without making M4 inactive
if (*xExpectedIdleTime >= configEXPECTED_IDLE_TIME_BEFORE_SLEEP)
{
// Indicate M4 is Inactive
P2P_STATUS_REG &= ~M4_is_active;
// Waiting for one more clock cycle to make sure M4 H/W Register is updated
P2P_STATUS_REG;

// TODO: This delay is added to sync between M4 and TA. It should be removed once the logic is moved to wifi SDK
for (uint8_t delay = 0; delay < 10; delay++)
{
__ASM("NOP");
}
// Checking if TA has already triggered a packet to M4
// RX_BUFFER_VALID will be cleared by TA if any packet is triggered
if ((P2P_STATUS_REG & TA_wakeup_M4) || (P2P_STATUS_REG & M4_wakeup_TA) || (!(M4SS_P2P_INTR_SET_REG & RX_BUFFER_VALID)))
{
P2P_STATUS_REG |= M4_is_active;
*xExpectedIdleTime = 0;
}
else
{
M4SS_P2P_INTR_CLR_REG = RX_BUFFER_VALID;
M4SS_P2P_INTR_CLR_REG;

TASS_P2P_INTR_MASK_SET = (TX_PKT_TRANSFER_DONE_INTERRUPT | RX_PKT_TRANSFER_DONE_INTERRUPT |
TA_WRITING_ON_COMM_FLASH | NWP_DEINIT_IN_COMM_FLASH
#ifdef SL_SI91X_SIDE_BAND_CRYPTO
| SIDE_BAND_CRYPTO_DONE
#endif
);
}
}
}
}
#endif // CHIP_CONFIG_ENABLE_ICD_SERVER && SI917_M4_SLEEP_ENABLED
extern "C" void vApplicationIdleHook(void)
{
#if CHIP_CONFIG_ENABLE_ICD_SERVER && SI917_M4_SLEEP_ENABLED
invoke_btn_press_event();
// is_sleep_ready is required since wfx_is_sleep_ready() is not FreeRTOS scheduler agnostic
is_sleep_ready = wfx_is_sleep_ready();
#endif // CHIP_CONFIG_ENABLE_ICD_SERVER && SI917_M4_SLEEP_ENABLED
#if (SLI_SI91X_MCU_INTERFACE && CHIP_CONFIG_ENABLE_ICD_SERVER)
sl_si91x_invoke_btn_press_event();
#endif
}
1 change: 1 addition & 0 deletions examples/platform/silabs/SiWx917/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ source_set("siwx917-common") {
public_configs = [
":siwx917-common-config",
"${efr32_sdk_build_root}:silabs_config",
":chip_examples_project_config",
]

include_dirs = [
Expand Down
50 changes: 25 additions & 25 deletions examples/platform/silabs/ldscripts/SiWx917-common.ld
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ SECTIONS
{
KEEP(*(.isr_vector))
KEEP(*(.reset_handler))
*(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*)
*(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*)

/* .ctors */
*crtbegin.o(.ctors)
Expand Down Expand Up @@ -127,30 +127,30 @@ SECTIONS
*(.rodata*)
*(vtable)
*(.data*)
*sl_si91x_bus.o(.text*)
*sl_si91x_driver.o(.text*)
*sli_si91x_multithreaded.o(.text*)
*rsi_hal_mcu_m4_ram.o(.text*)
*rsi_hal_mcu_m4_rom.o(.text*)
*rsi_deepsleep_soc.o(.text*)
*croutine.o(.text*)
*event_groups.o(.text*)
*list.o(.text*)
*queue.o(.text*)
*cmsis_os2.o(.text*)
*stream_buffer.o(.text*)
*tasks.o(.text*)
*timers.o(.text*)
*freertos_umm_malloc_host.o(.text*)
*malloc_buffers.o(.text*)
*sl_rsi_utility.o(.text*)
*port.o(.text*)
*heap_*.o(.text*)
*sl_sleeptimer.o(.text*)
*sl_sleeptimer_hal_si91x_sysrtc.o(.text*)
*rsi_sysrtc.o(.text*)
*sl_si91x_low_power_tickless_mode.o(.text*)
*sl_core_cortexm.o(.text*)
*sl_si91x_bus.c.o(.text*)
*sl_si91x_driver.c.o(.text*)
*sli_si91x_multithreaded.c.o(.text*)
*rsi_hal_mcu_m4_ram.c.o(.text*)
*rsi_hal_mcu_m4_rom.c.o(.text*)
*rsi_deepsleep_soc.c.o(.text*)
*croutine.c.o(.text*)
*event_groups.c.o(.text*)
*list.c.o(.text*)
*queue.c.o(.text*)
*cmsis_os2.c.o(.text*)
*stream_buffer.c.o(.text*)
*tasks.c.o(.text*)
*timers.c.o(.text*)
*freertos_umm_malloc_host.c.o(.text*)
*malloc_buffers.c.o(.text*)
*sl_rsi_utility.c.o(.text*)
*port.c.o(.text*)
*heap_*.c.o(.text*)
*sl_sleeptimer.c.o(.text*)
*sl_sleeptimer_hal_si91x_sysrtc.c.o(.text*)
*rsi_sysrtc.c.o(.text*)
*sl_si91x_low_power_tickless_mode.c.o(.text*)
*sl_core_cortexm.c.o(.text*)

. = ALIGN(4);
/* preinit data */
Expand Down
7 changes: 5 additions & 2 deletions examples/platform/silabs/wfx_rsi.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/
#pragma once

#include <app/icd/server/ICDServerConfig.h>
#include <event_groups.h>
#include <wfx_host_events.h>

Expand Down Expand Up @@ -112,8 +113,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();
#if CHIP_CONFIG_ENABLE_ICD_SERVER
#if SLI_SI91X_MCU_INTERFACE
void sl_si91x_invoke_btn_press_event();
#endif // SLI_SI91X_MCU_INTERFACE
#if SLI_SI917
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);
#else
Expand Down
4 changes: 4 additions & 0 deletions src/lwip/silabs/lwipopts-rs911x.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,10 @@
#define DEFAULT_UDP_RECVMBOX_SIZE 6
#define DEFAULT_TCP_RECVMBOX_SIZE 6

#if SL_ICD_ENABLED
#define SL_LWIP_MLD6_TIMERS_ONDEMAND 1
#endif // CHIP_CONFIG_ENABLE_ICD_SERVER

#ifdef LWIP_DEBUG

#define MEMP_OVERFLOW_CHECK (0)
Expand Down
4 changes: 4 additions & 0 deletions src/lwip/silabs/lwipopts-wf200.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,10 @@
#define DEFAULT_UDP_RECVMBOX_SIZE 6
#define DEFAULT_TCP_RECVMBOX_SIZE 6

#if SL_ICD_ENABLED
#define SL_LWIP_MLD6_TIMERS_ONDEMAND 1
#endif // CHIP_CONFIG_ENABLE_ICD_SERVER

#ifdef LWIP_DEBUG

#define MEMP_OVERFLOW_CHECK (0)
Expand Down
16 changes: 12 additions & 4 deletions third_party/silabs/SiWx917_sdk.gni
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ template("siwx917_sdk") {
"${wifi_sdk_root}/components/device/silabs/si91x/wireless/firmware_upgrade",
"${wifi_sdk_root}/components/device/silabs/si91x/mcu/hal/inc",
"${wifi_sdk_root}/components/device/silabs/si91x/mcu/drivers/systemlevel/inc",

"${wifi_sdk_root}/components/device/silabs/si91x/mcu/drivers/service/power_manager/inc",
]

if (use_system_view) {
Expand Down Expand Up @@ -303,9 +305,9 @@ template("siwx917_sdk") {
"SL_ACTIVE_MODE_DURATION_MS=${sl_active_mode_duration_ms}",
"SL_IDLE_MODE_DURATION_S=${sl_idle_mode_duration_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",
"SL_SI91X_MCU_ALARM_BASED_WAKEUP=1",
"SL_SI91X_NPSS_GPIO_BTN_HANDLER=1",
"SL_SI91X_POWER_MANAGER_UC_AVAILABLE=1",
"SL_SI91X_TICKLESS_MODE=1",
]

if (si91x_alarm_based_periodic_wakeup) {
Expand Down Expand Up @@ -412,6 +414,7 @@ template("siwx917_sdk") {
"${wifi_sdk_root}/components/board/silabs/src/rsi_board.c",
"${wifi_sdk_root}/components/common/src/sl_utility.c",
"${wifi_sdk_root}/components/device/silabs/si91x/mcu/core/chip/src/rsi_deepsleep_soc.c",
"${wifi_sdk_root}/components/device/silabs/si91x/mcu/core/chip/src/rsi_ps_ram_func.c",
"${wifi_sdk_root}/components/device/silabs/si91x/mcu/core/chip/src/rsi_system_config.c",
"${wifi_sdk_root}/components/device/silabs/si91x/mcu/core/chip/src/system_si91x.c",
"${wifi_sdk_root}/components/device/silabs/si91x/mcu/core/common/src/rsi_debug.c",
Expand Down Expand Up @@ -574,9 +577,14 @@ template("siwx917_sdk") {

if (chip_enable_icd_server) {
sources += [
"${sdk_support_root}/matter/si91x/siwx917/BRD4338A/autogen/sl_si91x_power_manager_handler.c",
"${sdk_support_root}/matter/si91x/siwx917/BRD4338A/autogen/sl_si91x_power_manager_wakeup_handler.c",
"${wifi_sdk_root}/components/device/silabs/si91x/mcu/drivers/peripheral_drivers/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/service/power_manager/src/sl_si91x_power_manager.c",
"${wifi_sdk_root}/components/device/silabs/si91x/mcu/drivers/service/power_manager/src/sli_si91x_power_manager.c",
"${wifi_sdk_root}/components/device/silabs/si91x/mcu/drivers/service/power_manager/src/sli_si91x_power_manager_wakeup_init.c",
"${wifi_sdk_root}/components/device/silabs/si91x/mcu/drivers/systemlevel/src/rsi_time_period.c",
"${wifi_sdk_root}/third_party/silicon_labs/freertos/src/sl_si91x_low_power_tickless_mode.c",
]
}
public_deps = [
Expand Down
6 changes: 5 additions & 1 deletion third_party/silabs/efr32_sdk.gni
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ template("efr32_sdk") {
sdk_target_name = target_name

config("${sdk_target_name}_config") {
cflags = []
include_dirs = []
libs = []
if (defined(invoker.include_dirs)) {
Expand Down Expand Up @@ -480,6 +481,10 @@ template("efr32_sdk") {
# TODO: Remove this flag, once the communication is fixed
"WIFI_DEBUG_ENABLED=1",
]

# This is kept due to the warning on the LWIP when on demand timer is added
# TODO: remove this flag once the warning is fixed in SiSDK MATTER-3946
cflags += [ "-Wno-error" ]
chirag-silabs marked this conversation as resolved.
Show resolved Hide resolved
}
}

Expand Down Expand Up @@ -605,7 +610,6 @@ template("efr32_sdk") {
]
}

cflags = []
foreach(include_dir, _include_dirs) {
cflags += [ "-isystem" + rebase_path(include_dir, root_build_dir) ]
}
Expand Down
Loading