From f2af98cd8adade41cd894fd3a08336afe387ac07 Mon Sep 17 00:00:00 2001 From: Robert Lubos Date: Wed, 10 May 2017 17:58:47 +0200 Subject: [PATCH] Increase default mbedTLS heap size for nrf52840. (#1752) --- .../nrf52840/openthread-core-nrf52840-config.h | 8 ++++++++ src/core/crypto/mbedtls.hpp | 4 ++-- src/core/openthread-core-default-config.h | 10 ++++++++++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/examples/platforms/nrf52840/openthread-core-nrf52840-config.h b/examples/platforms/nrf52840/openthread-core-nrf52840-config.h index ee3367f49..7330486ac 100644 --- a/examples/platforms/nrf52840/openthread-core-nrf52840-config.h +++ b/examples/platforms/nrf52840/openthread-core-nrf52840-config.h @@ -123,4 +123,12 @@ */ #define OPENTHREAD_CONFIG_MBEDTLS_HEAP_SIZE (4096 * sizeof(void *)) +/** + * @def OPENTHREAD_CONFIG_MBEDTLS_HEAP_SIZE_NO_DTLS + * + * The size of mbedTLS heap buffer when DTLS is disabled. + * + */ +#define OPENTHREAD_CONFIG_MBEDTLS_HEAP_SIZE_NO_DTLS 2048 + #endif // OPENTHREAD_CORE_NRF52840_CONFIG_H_ diff --git a/src/core/crypto/mbedtls.hpp b/src/core/crypto/mbedtls.hpp index 67f999132..8afe3e536 100644 --- a/src/core/crypto/mbedtls.hpp +++ b/src/core/crypto/mbedtls.hpp @@ -64,9 +64,9 @@ public: enum { #if OPENTHREAD_ENABLE_DTLS - kMemorySize = OPENTHREAD_CONFIG_MBEDTLS_HEAP_SIZE, ///< Size of memory buffer (bytes). + kMemorySize = OPENTHREAD_CONFIG_MBEDTLS_HEAP_SIZE, ///< Size of memory buffer (bytes). #else - kMemorySize = 384, ///< Size of memory buffer (bytes). + kMemorySize = OPENTHREAD_CONFIG_MBEDTLS_HEAP_SIZE_NO_DTLS, ///< Size of memory buffer (bytes). #endif }; diff --git a/src/core/openthread-core-default-config.h b/src/core/openthread-core-default-config.h index 32fc4e50c..5847aac89 100644 --- a/src/core/openthread-core-default-config.h +++ b/src/core/openthread-core-default-config.h @@ -725,6 +725,16 @@ #define OPENTHREAD_CONFIG_MBEDTLS_HEAP_SIZE (2048 * sizeof(void *)) #endif +/** + * @def OPENTHREAD_CONFIG_MBEDTLS_HEAP_SIZE_NO_DTLS + * + * The size of mbedTLS heap buffer when DTLS is disabled. + * + */ +#ifndef OPENTHREAD_CONFIG_MBEDTLS_HEAP_SIZE_NO_DTLS +#define OPENTHREAD_CONFIG_MBEDTLS_HEAP_SIZE_NO_DTLS 384 +#endif + /** * @def OPENTHREAD_CONFIG_ENABLE_STEERING_DATA_SET_OOB *