mirror of
https://github.com/espressif/openthread.git
synced 2026-10-06 07:47:41 +00:00
[nrf52840] add flag for enabling mbedTLS built-in threading support (#3828)
This commit is contained in:
committed by
Jonathan Hui
parent
7f0168cbc7
commit
4ee45b67d8
@@ -124,6 +124,15 @@ ifeq ($(DISABLE_CC310), 1)
|
||||
NRF52840_MBEDTLS_CPPFLAGS += -DDISABLE_CC310=1
|
||||
endif
|
||||
|
||||
ifeq ($(MBEDTLS_THREADING), 1)
|
||||
NRF52840_MBEDTLS_CPPFLAGS += -DDISABLE_CC310=1
|
||||
NRF52840_MBEDTLS_CPPFLAGS += -DMBEDTLS_THREADING=1
|
||||
endif
|
||||
|
||||
ifdef MBEDTLS_THREADING_MUTEX_DEF
|
||||
NRF52840_MBEDTLS_CPPFLAGS += -DMBEDTLS_THREADING_MUTEX_DEF='\"$(MBEDTLS_THREADING_MUTEX_DEF)\"'
|
||||
endif
|
||||
|
||||
ifeq ($(shell expr $(GCCVersion) \>= 7), 1)
|
||||
COMMONCFLAGS += -Wno-expansion-to-defined
|
||||
endif
|
||||
|
||||
@@ -121,6 +121,31 @@ By default, mbedTLS library is built with support for CryptoCell 310 hardware ac
|
||||
$ make -f examples/Makefile-nrf52840 DISABLE_CC310=1
|
||||
```
|
||||
|
||||
### Optional mbedTLS threading support
|
||||
By default, mbedTLS library is built without support for multiple threads. You can enable this built-in support by building OpenThread with the following parameter:
|
||||
|
||||
```
|
||||
$ make -f examples/Makefile-nrf52840 MBEDTLS_THREADING=1
|
||||
```
|
||||
|
||||
The simple mutex definition is used as shown below:
|
||||
|
||||
```
|
||||
typedef void * mbedtls_threading_mutex_t;
|
||||
```
|
||||
|
||||
However, you can modify it, by providing a path to a header file with proper definition. To do that, build OpenThread with the following parameter:
|
||||
|
||||
```
|
||||
$ make -f examples/Makefile-nrf52840 MBEDTLS_THREADING=1 MBEDTLS_THREADING_MUTEX_DEF="path_to_a_header_file_with_mutex_definition.h"
|
||||
```
|
||||
|
||||
See [mbedTls Thread Safety and Multi Threading][mbedtls-thread-safety-and-multi-threading] for more details.
|
||||
|
||||
Note that as a temporary limitation CryptoCell 310 hardware acceleration is disabled when using mbedTLS threading.
|
||||
|
||||
[mbedtls-thread-safety-and-multi-threading]: https://tls.mbed.org/kb/development/thread-safety-and-multi-threading
|
||||
|
||||
### IEEE EUI-64 address
|
||||
|
||||
When the Thread device is configured to obtain the Thread Network security credentials with either Thread Commissioning or an out-of-band method, the extended MAC address should be constructed out of the globally unique IEEE EUI-64.
|
||||
|
||||
@@ -32,6 +32,11 @@
|
||||
#define MBEDTLS_SHA256_ALT
|
||||
#endif // DISABLE_CC310
|
||||
|
||||
#ifdef MBEDTLS_THREADING
|
||||
#define MBEDTLS_THREADING_C
|
||||
#define MBEDTLS_THREADING_ALT
|
||||
#endif // MBEDTLS_THREADING
|
||||
|
||||
#if defined(__ICCARM__)
|
||||
_Pragma("diag_suppress=Pe550")
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright (c) 2019, The OpenThread Authors.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the copyright holder nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef THREADING_ALT_H_
|
||||
#define THREADING_ALT_H_
|
||||
|
||||
#ifdef MBEDTLS_THREADING_MUTEX_DEF
|
||||
#include MBEDTLS_THREADING_MUTEX_DEF
|
||||
#else
|
||||
typedef void * mbedtls_threading_mutex_t;
|
||||
#endif // MBEDTLS_THREADING_MUTEX_DEF
|
||||
|
||||
#endif // THREADING_ALT_H_
|
||||
Vendored
+1
@@ -75,6 +75,7 @@ libmbedcrypto_a_SOURCES = \
|
||||
repo/library/ssl_srv.c \
|
||||
repo/library/ssl_ticket.c \
|
||||
repo/library/ssl_tls.c \
|
||||
repo/library/threading.c \
|
||||
repo/library/x509.c \
|
||||
repo/library/x509_crt.c \
|
||||
$(NULL)
|
||||
|
||||
Reference in New Issue
Block a user