Skip to content

Commit

Permalink
Merge branch 'master' of github.com:rosahay-silabs/connectedhomeip in…
Browse files Browse the repository at this point in the history
…to feature/adds-psa-crypto-support
  • Loading branch information
rosahay-silabs committed Jun 26, 2024
2 parents 532416c + 58536ba commit 9f27853
Show file tree
Hide file tree
Showing 33 changed files with 559 additions and 1,420 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/examples-efr32.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
if: github.actor != 'restyled-io[bot]'

container:
image: ghcr.io/project-chip/chip-build-efr32:54
image: ghcr.io/project-chip/chip-build-efr32:56
volumes:
- "/tmp/bloat_reports:/tmp/bloat_reports"
steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release_artifacts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ jobs:
runs-on: ubuntu-latest

container:
image: ghcr.io/project-chip/chip-build-efr32:54
image: ghcr.io/project-chip/chip-build-efr32:56
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
10 changes: 5 additions & 5 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -231,10 +231,10 @@
url = https://github.com/SiliconLabs/sdk_support.git
branch = main
platforms = silabs,silabs_docker
[submodule "third_party/silabs/gecko_sdk"]
path = third_party/silabs/gecko_sdk
url = https://github.com/SiliconLabs/gecko_sdk.git
branch = v4.4.2
[submodule "third_party/silabs/simplicity_sdk"]
path = third_party/silabs/simplicity_sdk
url = https://github.com/SiliconLabs/simplicity_sdk.git
branch = v2024.6.0
platforms = silabs
[submodule "third_party/silabs/wiseconnect-wifi-bt-sdk"]
path = third_party/silabs/wiseconnect-wifi-bt-sdk
Expand All @@ -244,7 +244,7 @@
[submodule "third_party/silabs/wifi_sdk"]
path = third_party/silabs/wifi_sdk
url = https://github.com/SiliconLabs/wiseconnect.git
branch = v3.1.3-matter-hotfix.4
branch = v3.3.0
platforms = silabs
[submodule "editline"]
path = third_party/editline/repo
Expand Down
2 changes: 1 addition & 1 deletion examples/light-switch-app/silabs/.gn
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ check_system_includes = true
default_args = {
target_cpu = "arm"
target_os = "freertos"
chip_openthread_ftd = true
chip_openthread_ftd = false

import("//openthread.gni")
}
8 changes: 1 addition & 7 deletions examples/platform/silabs/SiWx917/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,8 @@ config("chip_examples_project_config") {
include_dirs = [ "project_include" ]

# Link options that provide a replacement for dynamic memory operations in standard
# library with the FreeRTOS malloc in platform code.
# library with the sl_memory_manager in platform code.
ldflags = [
# memory allocation -- these must be re-entrant and do locking
"-Wl,--wrap=malloc",
"-Wl,--wrap=free",
"-Wl,--wrap=realloc",
"-Wl,--wrap=calloc",
"-Wl,--wrap=MemoryAlloc",

# Wrap these in case internal newlib call them (e.g. strdup will)
Expand Down Expand Up @@ -234,7 +229,6 @@ source_set("siwx917-common") {
"${silabs_common_plat_dir}/LEDWidget.cpp",
"${silabs_common_plat_dir}/MatterConfig.cpp",
"${silabs_common_plat_dir}/SoftwareFaultReports.cpp",
"${silabs_common_plat_dir}/heap_4_silabs.c",
"${silabs_common_plat_dir}/silabs_utils.cpp",
"${silabs_common_plat_dir}/syscalls_stubs.cpp",
"${silabs_plat_si91x_wifi_dir}/dhcp_client.cpp",
Expand Down
160 changes: 50 additions & 110 deletions examples/platform/silabs/SiWx917/SiWx917/sl_wifi_if.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

#include "silabs_utils.h"
#include "sl_status.h"
#include <app/icd/server/ICDServerConfig.h>

#include "FreeRTOS.h"
#include "event_groups.h"
Expand All @@ -39,9 +40,12 @@ extern "C" {

#include "ble_config.h"

#if SL_ICD_ENABLED && SLI_SI91X_MCU_INTERFACE
#if CHIP_CONFIG_ENABLE_ICD_SERVER && SLI_SI91X_MCU_INTERFACE
#include "rsi_rom_power_save.h"
#include "sl_si91x_button_pin_config.h"
#if DISPLAY_ENABLED
#include "sl_memlcd.h"
#endif // DISPLAY_ENABLED
extern "C" {
#include "sl_si91x_driver.h"
#include "sl_si91x_m4_ps.h"
Expand All @@ -50,7 +54,7 @@ extern "C" {
// 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 && SLI_SI91X_MCU_INTERFACE
#endif // CHIP_CONFIG_ENABLE_ICD_SERVER && SLI_SI91X_MCU_INTERFACE

#include "dhcp_client.h"
#include "wfx_host_events.h"
Expand Down Expand Up @@ -78,11 +82,6 @@ extern "C" {

WfxRsi_t wfx_rsi;

// TODO: remove this. Added only to monitor how many watch dog reset have happened during testing.
#ifdef SLI_SI91X_MCU_INTERFACE
volatile uint32_t watchdog_reset = 0;
#endif // SLI_SI91X_MCU_INTERFACE

/* Declare a variable to hold the data associated with the created event group. */
StaticEventGroup_t rsiDriverEventGroup;

Expand Down Expand Up @@ -246,10 +245,9 @@ sl_status_t join_callback_handler(sl_wifi_event_t event, char * result, uint32_t
wfx_rsi.dev_state &= ~(WFX_RSI_ST_STA_CONNECTING);
if (SL_WIFI_CHECK_IF_EVENT_FAILED(event))
{
SILABS_LOG("F: Join Event received with %u bytes payload\n", result_length);
callback_status = *(sl_status_t *) result;
SILABS_LOG("join_callback_handler: failed: 0x%X", callback_status);
wfx_rsi.dev_state &= ~(WFX_RSI_ST_STA_CONNECTED);
is_wifi_disconnection_event = true;
wfx_retry_interval_handler(is_wifi_disconnection_event, wfx_rsi.join_retries++);
if (is_wifi_disconnection_event || wfx_rsi.join_retries <= WFX_RSI_CONFIG_MAX_JOIN)
{
Expand All @@ -262,26 +260,22 @@ sl_status_t join_callback_handler(sl_wifi_event_t event, char * result, uint32_t
* Join was complete - Do the DHCP
*/
memset(&temp_reset, 0, sizeof(wfx_wifi_scan_ext_t));
SILABS_LOG("join_callback_handler: join completed.");
SILABS_LOG("%c: Join Event received with %u bytes payload\n", *result, result_length);
SILABS_LOG("join_callback_handler: success");

WfxEvent.eventType = WFX_EVT_STA_CONN;
WfxPostEvent(&WfxEvent);
wfx_rsi.join_retries = 0;
retryInterval = WLAN_MIN_RETRY_TIMER_MS;
if (is_wifi_disconnection_event)
{
is_wifi_disconnection_event = false;
}
callback_status = SL_STATUS_OK;
// Once the join passes setting the disconnection event to true to differentiate between the first connection and reconnection
is_wifi_disconnection_event = true;
callback_status = SL_STATUS_OK;
return SL_STATUS_OK;
}

#if SL_ICD_ENABLED

#if SI917_M4_SLEEP_ENABLED
#if CHIP_CONFIG_ENABLE_ICD_SERVER
#if SLI_SI91X_MCU_INTERFACE
// Required to invoke button press event during sleep as falling edge is not detected
void invoke_btn_press_event()
void sl_si91x_invoke_btn_press_event()
{
// 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)
Expand All @@ -295,36 +289,28 @@ void invoke_btn_press_event()
}
}

/**
* @brief Checks if the Wi-Fi module is ready for sleep.
*
* This function checks if the Wi-Fi module is ready to enter sleep mode.
*
* @return true if the Wi-Fi module is ready for sleep, false otherwise.
*/
bool wfx_is_sleep_ready()
{
// BRD4002A board BTN_PRESS is 0 when pressed, release is 1
// sli_si91x_is_sleep_ready requires OS Scheduler to be active
return ((RSI_NPSSGPIO_GetPin(SL_BUTTON_BTN0_PIN) != 0) && (wfx_rsi.dev_state & WFX_RSI_ST_SLEEP_READY) &&
sli_si91x_is_sleep_ready());
}

/**
* @brief Sleeps for a specified duration and then wakes up.
*
* This function puts the SI91x host into sleep mode for the specified duration
* in milliseconds and then wakes it up.
*
* @param sleep_time_ms The duration in milliseconds to sleep.
*/
void sl_wfx_host_si91x_sleep(uint16_t * sleep_time_ms)
/******************************************************************
* @fn sl_app_sleep_ready()
* @brief
* Called from the supress ticks from tickless to check if it
* is ok to go to sleep
* @param[in] None
* @return
* None
*********************************************************************/
uint32_t sl_app_sleep_ready()
{
SL_ASSERT(sleep_time_ms != NULL);
sl_si91x_m4_sleep_wakeup(sleep_time_ms);
if (wfx_rsi.dev_state & WFX_RSI_ST_SLEEP_READY)
{
#if DISPLAY_ENABLED
// Powering down the LCD
sl_memlcd_power_on(NULL, false);
#endif /* DISPLAY_ENABLED */
return true;
}
return false;
}

#endif // SI917_M4_SLEEP_ENABLED
#endif // SLI_SI91X_MCU_INTERFACE

/******************************************************************
* @fn wfx_rsi_power_save()
Expand Down Expand Up @@ -363,7 +349,7 @@ int32_t wfx_rsi_power_save(rsi_power_save_profile_mode_t sl_si91x_ble_state, sl_
}
return status;
}
#endif /* SL_ICD_ENABLED */
#endif /* CHIP_CONFIG_ENABLE_ICD_SERVER */

/*************************************************************************************
* @fn static int32_t wfx_wifi_rsi_init(void)
Expand All @@ -378,13 +364,6 @@ int32_t wfx_wifi_rsi_init(void)
SILABS_LOG("wfx_wifi_rsi_init started");
sl_status_t status;
status = sl_wifi_init(&config, NULL, sl_wifi_default_event_handler);
#ifdef SLI_SI91X_MCU_INTERFACE
// TODO: remove this. Added only to monitor how many watch dog reset have happened during testing.
if ((MCU_FSM->MCU_FSM_WAKEUP_STATUS_REG) & BIT(5))
{
watchdog_reset++;
}
#endif // SLI_SI91X_MCU_INTERFACE
if (status != SL_STATUS_OK)
{
return status;
Expand Down Expand Up @@ -449,15 +428,15 @@ static sl_status_t wfx_rsi_init(void)
return status;
}
#else // For SoC
#if SL_ICD_ENABLED
#if CHIP_CONFIG_ENABLE_ICD_SERVER
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 /* CHIP_CONFIG_ENABLE_ICD_SERVER */
#endif /* SLI_SI91X_MCU_INTERFACE */

sl_wifi_firmware_version_t version = { 0 };
Expand Down Expand Up @@ -520,12 +499,13 @@ sl_status_t scan_callback_handler(sl_wifi_event_t event, sl_wifi_scan_result_t *
{
if (SL_WIFI_CHECK_IF_EVENT_FAILED(event))
{
callback_status = *(sl_status_t *) scan_result;
callback_status = *(sl_status_t *) scan_result;
SILABS_LOG("scan_callback_handler: failed: 0x%X", callback_status);
scan_results_complete = true;
#if WIFI_ENABLE_SECURITY_WPA3_TRANSITION
wfx_rsi.sec.security = WFX_SEC_WPA3;
#else
wfx_rsi.sec.security = WFX_SEC_WPA2;
wfx_rsi.sec.security = WFX_SEC_WPA2;
#endif /* WIFI_ENABLE_SECURITY_WPA3_TRANSITION */

osSemaphoreRelease(sScanSemaphore);
Expand All @@ -541,9 +521,9 @@ sl_status_t scan_callback_handler(sl_wifi_event_t event, sl_wifi_scan_result_t *
break;
case SL_WIFI_WPA:
case SL_WIFI_WPA_ENTERPRISE:
case SL_WIFI_WPA_WPA2_MIXED:
wfx_rsi.sec.security = WFX_SEC_WPA;
break;
case SL_WIFI_WPA_WPA2_MIXED:
case SL_WIFI_WPA2:
case SL_WIFI_WPA2_ENTERPRISE:
wfx_rsi.sec.security = WFX_SEC_WPA2;
Expand All @@ -556,7 +536,7 @@ sl_status_t scan_callback_handler(sl_wifi_event_t event, sl_wifi_scan_result_t *
case SL_WIFI_WPA3:
wfx_rsi.sec.security = WFX_SEC_WPA3;
#else
wfx_rsi.sec.security = WFX_SEC_WPA2;
wfx_rsi.sec.security = WFX_SEC_WPA2;
#endif /* WIFI_ENABLE_SECURITY_WPA3_TRANSITION */
break;
default:
Expand Down Expand Up @@ -661,14 +641,18 @@ static sl_status_t wfx_rsi_do_join(void)
connect_security_mode = SL_WIFI_WEP;
break;
case WFX_SEC_WPA:
case WFX_SEC_WPA2:
connect_security_mode = SL_WIFI_WPA_WPA2_MIXED;
break;
case WFX_SEC_WPA2:
#if WIFI_ENABLE_SECURITY_WPA3_TRANSITION
connect_security_mode = SL_WIFI_WPA3_TRANSITION;
break;
case WFX_SEC_WPA3:
connect_security_mode = SL_WIFI_WPA3_TRANSITION;
#else
connect_security_mode = SL_WIFI_WPA_WPA2_MIXED;
#endif // WIFI_ENABLE_SECURITY_WPA3_TRANSITION
break;
#endif /*WIFI_ENABLE_SECURITY_WPA3_TRANSITION*/
case WFX_SEC_NONE:
connect_security_mode = SL_WIFI_OPEN;
break;
Expand All @@ -695,14 +679,14 @@ static sl_status_t wfx_rsi_do_join(void)

sl_wifi_set_join_callback(join_callback_handler, NULL);

#if SL_ICD_ENABLED
#if CHIP_CONFIG_ENABLE_ICD_SERVER
// 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);

sl_wifi_advanced_client_configuration_t client_config = { .max_retry_attempts = 5 };
sl_wifi_set_advanced_client_configuration(SL_WIFI_CLIENT_INTERFACE, &client_config);
#endif // SL_ICD_ENABLED
#endif // CHIP_CONFIG_ENABLE_ICD_SERVER
/* Try to connect Wifi with given Credentials
* untill there is a success or maximum number of tries allowed
*/
Expand Down Expand Up @@ -1006,47 +990,3 @@ void wfx_dhcp_got_ipv4(uint32_t ip)
wfx_rsi.dev_state |= WFX_RSI_ST_STA_READY;
}
#endif /* CHIP_DEVICE_CONFIG_ENABLE_IPV4 */

/********************************************************************************************
* @fn void wfx_rsi_pkt_add_data(void *p, uint8_t *buf, uint16_t len, uint16_t off)
* @brief
* add the data into packet
* @param[in] p:
* @param[in] buf:
* @param[in] len:
* @param[in] off:
* @return
* None
**********************************************************************************************/
void wfx_rsi_pkt_add_data(void * p, uint8_t * buf, uint16_t len, uint16_t off)
{
sl_si91x_packet_t * pkt;
pkt = (sl_si91x_packet_t *) p;
memcpy(((char *) pkt->data) + off, buf, len);
}

#if !EXP_BOARD
/********************************************************************************************
* @fn int32_t wfx_rsi_send_data(void *p, uint16_t len)
* @brief
* Driver send a data
* @param[in] p:
* @param[in] len:
* @return
* None
**********************************************************************************************/
int32_t wfx_rsi_send_data(void * p, uint16_t len)
{
int32_t status;
sl_wifi_buffer_t * buffer;
buffer = (sl_wifi_buffer_t *) p;

if (sl_si91x_driver_send_data_packet(SI91X_WLAN_CMD_QUEUE, buffer, RSI_SEND_RAW_DATA_RESPONSE_WAIT_TIME))
{
SILABS_LOG("*ERR*EN-RSI:Send fail");
return ERR_IF;
}
return status;
}

#endif
Loading

0 comments on commit 9f27853

Please sign in to comment.