From 58e8c2e2aee06fb8769367869bc1641d773d19de Mon Sep 17 00:00:00 2001 From: Sergei Lissianoi <54454955+selissia@users.noreply.github.com> Date: Thu, 27 Apr 2023 16:53:53 -0400 Subject: [PATCH] [Silabs] Move NVM semaphore creation to nvm3_lockBegin() (#26270) * Move NVM initialization to sl_platform_init() in matter_support submodule Also move nvm3_Sem creation to nvm3_lockBegin() * Restore the call to nvm3_open(), it's safe to call multiple times --- src/platform/silabs/SilabsConfig.cpp | 15 +++++++-------- third_party/silabs/matter_support | 2 +- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/platform/silabs/SilabsConfig.cpp b/src/platform/silabs/SilabsConfig.cpp index d07b9ced36cfc0..950b6040490c0a 100644 --- a/src/platform/silabs/SilabsConfig.cpp +++ b/src/platform/silabs/SilabsConfig.cpp @@ -43,6 +43,12 @@ static StaticSemaphore_t nvm3_SemStruct; void nvm3_lockBegin(void) { + if (nvm3_Sem == NULL) + { + nvm3_Sem = xSemaphoreCreateBinaryStatic(&nvm3_SemStruct); + xSemaphoreGive(nvm3_Sem); + } + VerifyOrDie(nvm3_Sem != NULL); xSemaphoreTake(nvm3_Sem, portMAX_DELAY); } @@ -65,15 +71,8 @@ namespace Internal { CHIP_ERROR SilabsConfig::Init() { -#ifndef BRD4325A // TODO: fix semaphore usage in nvm3_lock for siwx917. use weak implementation for that board instead - nvm3_Sem = xSemaphoreCreateBinaryStatic(&nvm3_SemStruct); + // nvm3_Sem is created in nvm3_lockBegin() - if (nvm3_Sem == NULL) - { - return CHIP_ERROR_NO_MEMORY; - } - xSemaphoreGive(nvm3_Sem); -#endif // not BRD4325A return MapNvm3Error(nvm3_open(nvm3_defaultHandle, nvm3_defaultInit)); } diff --git a/third_party/silabs/matter_support b/third_party/silabs/matter_support index 4d93227fc8679d..2bc3f28d778850 160000 --- a/third_party/silabs/matter_support +++ b/third_party/silabs/matter_support @@ -1 +1 @@ -Subproject commit 4d93227fc8679d66f0dd8d408b114425ca73bc0c +Subproject commit 2bc3f28d778850417f34c7201cbe78bd72e3ee78