Skip to content

Commit 5f28762

Browse files
[Zephyr][platform] Minimal adjustments in generic Zephyr platform abstraction layer (project-chip#71633)
* [Zephyr][platform] Updating the generic Zephyr platform layer to be compatible with Zephyr 4.4 baseline Signed-off-by: Dina Benamar <dina.benamarelmaaroufi@nxp.com> * Restyled by clang-format * Update comments in files to address review comments Signed-off-by: Dina Benamar <dina.benamarelmaaroufi@nxp.com> * Restyled by clang-format --------- Signed-off-by: Dina Benamar <dina.benamarelmaaroufi@nxp.com> Co-authored-by: Restyled.io <commits@restyled.io>
1 parent e2bb4a3 commit 5f28762

3 files changed

Lines changed: 19 additions & 7 deletions

File tree

config/zephyr/chip-module/CMakeLists.txt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,12 @@ if(CONFIG_CHIP)
5959
endif()
6060
endif()
6161

62-
# For ARM targets, use nosys.specs which provides stub implementations of
63-
# system calls for embedded environments without full OS support
64-
if (CONFIG_ARM)
65-
matter_add_cflags(--specs=nosys.specs)
62+
if(CONFIG_NEWLIB_LIBC)
63+
# For ARM targets, use nosys.specs which provides stub implementations of
64+
# system calls for embedded environments without full OS support
65+
if (CONFIG_ARM)
66+
matter_add_cflags(--specs=nosys.specs)
67+
endif()
6668
endif()
6769

6870
if(CONFIG_MBEDTLS)

src/platform/Zephyr/PlatformManagerImpl.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ PlatformManagerImpl PlatformManagerImpl::sInstance{ sChipThreadStack };
4949

5050
static k_timer sOperationalHoursSavingTimer;
5151

52-
#if !defined(CONFIG_NRF_SECURITY) && !defined(CONFIG_MBEDTLS_ZEPHYR_ENTROPY) && !defined(CONFIG_MBEDTLS_ENTROPY_POLL_ZEPHYR)
52+
#if !defined(CONFIG_NRF_SECURITY) && !defined(CONFIG_MBEDTLS_ZEPHYR_ENTROPY) && !defined(CONFIG_MBEDTLS_ENTROPY_POLL_ZEPHYR) && \
53+
!defined(CONFIG_MBEDTLS_PSA_DRIVER_GET_ENTROPY)
5354
static bool sChipStackEntropySourceAdded = false;
5455
static int app_entropy_source(void * data, unsigned char * output, size_t len, size_t * olen)
5556
{
@@ -121,16 +122,19 @@ CHIP_ERROR PlatformManagerImpl::_InitChipStack(void)
121122
{
122123
CHIP_ERROR err;
123124

124-
#if !defined(CONFIG_NRF_SECURITY) && !defined(CONFIG_MBEDTLS_ZEPHYR_ENTROPY) && !defined(CONFIG_MBEDTLS_ENTROPY_POLL_ZEPHYR)
125+
#if !defined(CONFIG_NRF_SECURITY) && !defined(CONFIG_MBEDTLS_ZEPHYR_ENTROPY) && !defined(CONFIG_MBEDTLS_ENTROPY_POLL_ZEPHYR) && \
126+
!defined(CONFIG_MBEDTLS_PSA_DRIVER_GET_ENTROPY)
125127
// Minimum required from source before entropy is released ( with mbedtls_entropy_func() ) (in bytes)
126128
const size_t kThreshold = 16;
127129
#endif // !defined(CONFIG_NRF_SECURITY) && !defined(CONFIG_MBEDTLS_ZEPHYR_ENTROPY) && !defined(CONFIG_MBEDTLS_ENTROPY_POLL_ZEPHYR)
130+
// && !defined(CONFIG_MBEDTLS_PSA_DRIVER_GET_ENTROPY)
128131

129132
// Initialize the configuration system.
130133
err = Internal::ZephyrConfig::Init();
131134
SuccessOrExit(err);
132135

133-
#if !defined(CONFIG_NRF_SECURITY) && !defined(CONFIG_MBEDTLS_ZEPHYR_ENTROPY) && !defined(CONFIG_MBEDTLS_ENTROPY_POLL_ZEPHYR)
136+
#if !defined(CONFIG_NRF_SECURITY) && !defined(CONFIG_MBEDTLS_ZEPHYR_ENTROPY) && !defined(CONFIG_MBEDTLS_ENTROPY_POLL_ZEPHYR) && \
137+
!defined(CONFIG_MBEDTLS_PSA_DRIVER_GET_ENTROPY)
134138
if (!sChipStackEntropySourceAdded)
135139
{
136140
// Add entropy source based on Zephyr entropy driver
@@ -139,6 +143,7 @@ CHIP_ERROR PlatformManagerImpl::_InitChipStack(void)
139143
sChipStackEntropySourceAdded = true;
140144
}
141145
#endif // !defined(CONFIG_NRF_SECURITY) && !defined(CONFIG_MBEDTLS_ZEPHYR_ENTROPY) && !defined(CONFIG_MBEDTLS_ENTROPY_POLL_ZEPHYR)
146+
// && !defined(CONFIG_MBEDTLS_PSA_DRIVER_GET_ENTROPY)
142147

143148
// Call _InitChipStack() on the generic implementation base class to finish the initialization process.
144149
err = Internal::GenericPlatformManagerImpl_Zephyr<PlatformManagerImpl>::_InitChipStack();

src/platform/Zephyr/SysHeapMalloc.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,9 @@ EXTERNALLY_VISIBLE void * WRAP(calloc)(size_t num, size_t size) ALIAS("_ZN4chip1
168168
EXTERNALLY_VISIBLE void * WRAP(realloc)(void * mem, size_t size) ALIAS("_ZN4chip11DeviceLayer6Malloc7ReallocEPvj");
169169
EXTERNALLY_VISIBLE void WRAP(free)(void * mem) ALIAS("_ZN4chip11DeviceLayer6Malloc4FreeEPv");
170170

171+
#if defined(CONFIG_NEWLIB_LIBC)
172+
/* Newlib-only reentrant hooks */
173+
171174
EXTERNALLY_VISIBLE void * WRAP(_malloc_r)(_reent *, size_t size)
172175
{
173176
return WRAP(malloc)(size);
@@ -188,6 +191,8 @@ EXTERNALLY_VISIBLE void WRAP(_free_r)(_reent *, void * mem)
188191
WRAP(free)(mem);
189192
}
190193

194+
#endif // CONFIG_NEWLIB_LIBC
195+
191196
} // extern "C"
192197

193198
#endif // CONFIG_CHIP_MALLOC_SYS_HEAP_OVERRIDE

0 commit comments

Comments
 (0)