From b7ed82c06006da0bc59952c17a06cc97689ae189 Mon Sep 17 00:00:00 2001 From: Maochen Wang Date: Thu, 20 Jun 2024 15:05:48 +0800 Subject: [PATCH] modules: mbedtls: Fix init hang issue In device init phase, it will call _mbedtls_init before malloc_prepare as mbedtls has higher priority defined in SYS_INIT.. _mbedtls_init() will call psa_crypto_init() and malloc buffer, but z_malloc_heap is not initialized, which will cause device hang. Should call malloc_prepare() before _mbedtls_init to fix this issue, so decrease the priority of mbedtls to default 40. Signed-off-by: Maochen Wang --- modules/mbedtls/zephyr_init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/mbedtls/zephyr_init.c b/modules/mbedtls/zephyr_init.c index bfdc8386346..89720fb9aa0 100644 --- a/modules/mbedtls/zephyr_init.c +++ b/modules/mbedtls/zephyr_init.c @@ -104,7 +104,7 @@ static int _mbedtls_init(void) } #if defined(CONFIG_MBEDTLS_INIT) -SYS_INIT(_mbedtls_init, POST_KERNEL, 0); +SYS_INIT(_mbedtls_init, POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT); #endif /* if CONFIG_MBEDTLS_INIT is not defined then this function