libc: common: 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 add new Kconfig to increase the priority of libc to deafult 30. Signed-off-by: Maochen Wang <maochen.wang@nxp.com>
This commit is contained in:
parent
b5be646e20
commit
e309f781ff
3 changed files with 10 additions and 2 deletions
|
|
@ -45,6 +45,14 @@ config KERNEL_INIT_PRIORITY_OBJECTS
|
|||
priority needs to be higher than minimal default initialization
|
||||
priority.
|
||||
|
||||
config KERNEL_INIT_PRIORITY_LIBC
|
||||
int "LIBC initialization priority"
|
||||
default 35
|
||||
help
|
||||
LIBC uses this priority for initialization. This
|
||||
priority needs to be higher than minimal default initialization
|
||||
priority.
|
||||
|
||||
config KERNEL_INIT_PRIORITY_DEFAULT
|
||||
int "Default init priority"
|
||||
default 40
|
||||
|
|
|
|||
|
|
@ -260,7 +260,7 @@ void free(void *ptr)
|
|||
malloc_unlock();
|
||||
}
|
||||
|
||||
SYS_INIT(malloc_prepare, POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT);
|
||||
SYS_INIT(malloc_prepare, POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_LIBC);
|
||||
#else /* No malloc arena */
|
||||
void *malloc(size_t size)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -142,7 +142,7 @@ static int malloc_prepare(void)
|
|||
return 0;
|
||||
}
|
||||
|
||||
SYS_INIT(malloc_prepare, POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT);
|
||||
SYS_INIT(malloc_prepare, POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_LIBC);
|
||||
|
||||
/* Current offset from HEAP_BASE of unused memory */
|
||||
LIBC_BSS static size_t heap_sz;
|
||||
|
|
|
|||
Loading…
Reference in a new issue