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] Minor fixes for LWIP usage #34393

Merged
merged 4 commits into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions examples/platform/silabs/efr32/rs911x/rsi_if.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "em_ldma.h"
#include "em_usart.h"

#include "FreeRTOS.h"
mykrupp marked this conversation as resolved.
Show resolved Hide resolved
#include "sl_status.h"
#include <cmsis_os2.h>
// TODO Fix include order issue #33120
Expand Down
9 changes: 5 additions & 4 deletions src/platform/silabs/PlatformManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ namespace DeviceLayer {
PlatformManagerImpl PlatformManagerImpl::sInstance;

#if defined(SL_MBEDTLS_USE_TINYCRYPT)
sys_mutex_t PlatformManagerImpl::rngMutexHandle = NULL;
sys_mutex_t PlatformManagerImpl::rngMutexHandle = nullptr;
mykrupp marked this conversation as resolved.
Show resolved Hide resolved

int PlatformManagerImpl::uECC_RNG_Function(uint8_t * dest, unsigned int size)
{
sys_mutex_lock(&rngMutexHandle);
osMutexAcquire(rngMutexHandle, osWaitForever);
int res = (chip::Crypto::DRBG_get_bytes(dest, size) == CHIP_NO_ERROR) ? size : 0;
sys_mutex_unlock(&rngMutexHandle);
osMutexRelease(rngMutexHandle);

return res;
}
Expand Down Expand Up @@ -97,7 +97,8 @@ CHIP_ERROR PlatformManagerImpl::_InitChipStack(void)
ReturnErrorOnFailure(chip::Crypto::add_entropy_source(app_entropy_source, NULL, 16));
#endif // !SLI_SI91X_MCU_INTERFACE
/* Set RNG function for tinycrypt operations. */
VerifyOrExit(sys_mutex_new(&rngMutexHandle) == ERR_OK, err = CHIP_ERROR_NO_MEMORY);
rngMutexHandle = osMutexNew(nullptr);
VerifyOrExit((&rngMutexHandle != nullptr), err = CHIP_ERROR_NO_MEMORY);
uECC_set_rng(PlatformManagerImpl::uECC_RNG_Function);
#endif // SL_MBEDTLS_USE_TINYCRYPT

Expand Down
3 changes: 2 additions & 1 deletion src/platform/silabs/PlatformManagerImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#if CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION
#include "wfx_host_events.h"
#endif
#include <cmsis_os2.h>

namespace chip {
namespace DeviceLayer {
Expand All @@ -45,7 +46,7 @@ class PlatformManagerImpl final : public PlatformManager, public Internal::Gener
// Since the RNG callback will be called from multiple threads,
// use this mutex to lock/unlock the call to Matter RNG API, which
// uses some global variables.
static sys_mutex_t rngMutexHandle;
static osMutexId_t rngMutexHandle;

// Callback used by tinycrypt to generate random numbers.
// It must be set before calling any sign operations,
Expand Down
1 change: 1 addition & 0 deletions src/platform/silabs/SiWx917/wifi/ethernetif.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

/* Includes */

#include <FreeRTOS.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Expand Down
1 change: 0 additions & 1 deletion src/platform/silabs/SiWx917/wifi/wfx_host_events.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#include "wfx_msgs.h"

/* LwIP includes. */
#include "lwip/apps/httpd.h"
#include "lwip/ip_addr.h"
#include "lwip/netif.h"
#include "lwip/netifapi.h"
Expand Down
1 change: 0 additions & 1 deletion src/platform/silabs/efr32/wifi/wfx_host_events.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ typedef struct __attribute__((__packed__)) sl_wfx_mib_req_s
#endif /* WF200 */

/* LwIP includes. */
#include "lwip/apps/httpd.h"
#include "lwip/ip_addr.h"
#include "lwip/netif.h"
#include "lwip/netifapi.h"
Expand Down
Loading