modules: mbedtls: set mbedTLS debug threshold during module initialization

mbedTLS library threshold initialization was done in native TLS socket
implementation (which tends to use mbedTLS now) and inside mbedTLS
benchmark test. Move that to mbedTLS module initialization, as this is a
global setting.

Update description of CONFIG_MBEDTLS_DEBUG_LEVEL to clarify when
mbedtls_debug_set_threshold() is called.

Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
This commit is contained in:
Marcin Niestroj 2022-06-15 00:47:21 +02:00 committed by Carles Cufí
commit 6653fd945f
4 changed files with 9 additions and 6 deletions

View file

@ -108,6 +108,9 @@ config MBEDTLS_DEBUG_LEVEL
3 Information
4 Verbose
This makes Zephyr call mbedtls_debug_set_threshold() function during
mbedTLS initialization, with the configured debug log level.
config MBEDTLS_MEMORY_DEBUG
bool "mbed TLS memory debug activation"
depends on MBEDTLS_BUILTIN

View file

@ -16,6 +16,8 @@
#include <zephyr/random/rand32.h>
#include <mbedtls/entropy.h>
#include <mbedtls/debug.h>
#if defined(CONFIG_MBEDTLS)
#if !defined(CONFIG_MBEDTLS_CFG_FILE)
#include "mbedtls/config.h"
@ -85,6 +87,10 @@ static int _mbedtls_init(const struct device *device)
init_heap();
#if defined(CONFIG_MBEDTLS_DEBUG_LEVEL)
mbedtls_debug_set_threshold(CONFIG_MBEDTLS_DEBUG_LEVEL);
#endif
return 0;
}