diff --git a/IDE/STM32Cube/README.md b/IDE/STM32Cube/README.md index 2710707b8..fffa166b6 100644 --- a/IDE/STM32Cube/README.md +++ b/IDE/STM32Cube/README.md @@ -14,8 +14,13 @@ These examples use the Cube HAL for STM32. ## Configuration -The settings for the wolfSTM32 project are located in `/IDE/STM32Cube/wolfSSL.wolfSSL_conf.h`. The section for "Hardware platform" may need to be adjusted depending on your processor and board: +The settings for the wolfSSL CubeMX pack are in the generated `wolfSSL.wolfSSL_conf.h` file. An example of this is located in `IDE/STM32Cube/wolfSSL_conf.h` (renamed to avoid possible conflicts with generated file). +The template used for generation is `IDE/STM32Cube/default_conf.ftl` which can be updated at `STM32Cube/Repository/Packs/wolfSSL/wolfSSL/[Version]/CubeMX/templates/default_conf.ftl`. + +The section for "Hardware platform" may need to be adjusted depending on your processor and board: + +* To enable STM32F1 support define `WOLFSSL_STM32F1`. * To enable STM32F2 support define `WOLFSSL_STM32F2`. * To enable STM32F4 support define `WOLFSSL_STM32F4`. * To enable STM32F7 support define `WOLFSSL_STM32F7`. @@ -39,7 +44,7 @@ If you'd like to use the older Standard Peripheral library undefine `WOLFSSL_STM If you are using FreeRTOS make sure your `FreeRTOSConfig.h` has its `configTOTAL_HEAP_SIZE` increased. -The TLS client/server benchmark example requires about 76 KB for allocated tasks (with stack) and peak heap. +The TLS client/server benchmark example requires about 76 KB for allocated tasks (with stack) and peak heap. This uses both a TLS client and server to test a TLS connection locally for each enabled TLS cipher suite. ## STM32 Cube Pack @@ -49,6 +54,7 @@ The TLS client/server benchmark example requires about 76 KB for allocated tasks 2. Run the “STM32CubeMX” tool. 3. Under “Manage software installations” click “INSTALL/REMOVE” button. 4. From Local and choose “I-CUBE-WOLFSSL-WOLFSSL.pack”. +5. Accept the GPLv2 license. Contact wolfSSL at sales@wolfssl.com for a commercial license and support/maintenance. ### STM32 Cube Pack Usage @@ -56,9 +62,10 @@ The TLS client/server benchmark example requires about 76 KB for allocated tasks 2. Under “Software Packs” choose “Select Components”. 3. Find and check all components for the wolfSSL.wolfSSL packs (wolfSSL / Core, wolfCrypt / Core and wolfCrypt / Test). Close 4. Under the “Software Packs” section click on “wolfSSL.wolfSSL” and configure the parameters. -5. For Cortex-M recommend “Math Configuration” -> “Single Precision Cortex-M Math” +5. For Cortex-M recommend “Math Configuration” -> “Single Precision Cortex-M Math” for the fastest option. 6. Generate Code 7. The Benchmark example uses float. To enable go to "Project Properties" -> "C/C++ Build" -> "Settings" -> "Tool Settings" -> "MCU Settings" -> Check "Use float with printf". +8. To enable printf make the `main.c` changes below in the [STM32 Printf](#stm32-printf) section. ### STM32 Cube Pack Examples @@ -87,6 +94,8 @@ Please select one of the above options: See [STM32_Benchmarks.md](STM32_Benchmarks.md). +Note: The Benchmark example uses float. To enable go to "Project Properties" -> "C/C++ Build" -> "Settings" -> "Tool Settings" -> "MCU Settings" -> Check "Use float with printf". + ## STM32 Printf In main.c make the following changes: diff --git a/IDE/STM32Cube/wolfSSL.wolfSSL_conf.h b/IDE/STM32Cube/wolfSSL_conf.h similarity index 99% rename from IDE/STM32Cube/wolfSSL.wolfSSL_conf.h rename to IDE/STM32Cube/wolfSSL_conf.h index 73c80623f..67e5c21e2 100644 --- a/IDE/STM32Cube/wolfSSL.wolfSSL_conf.h +++ b/IDE/STM32Cube/wolfSSL_conf.h @@ -1,4 +1,4 @@ -/* wolfSSL.wolfSSL_conf.h +/* wolfSSL_conf.h (example of generated wolfSSL.wolfSSL_conf.h) * * Copyright (C) 2006-2020 wolfSSL Inc. * @@ -19,11 +19,11 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA */ -/* STM32 Cube Configuration File +/* STM32 Cube Sample Configuration File + * Generated automatically using `default_conf.ftl` template + * * Included automatically when USE_HAL_DRIVER is defined * (and not WOLFSSL_USER_SETTINGS or HAVE_CONF_H). - * - * Generated automatically using `default_conf.ftl` template */ #ifndef __WOLFSSL_WOLFSSL_CONF_H__ diff --git a/IDE/STM32Cube/wolfssl_example.c b/IDE/STM32Cube/wolfssl_example.c index 7189977e4..f604c1788 100644 --- a/IDE/STM32Cube/wolfssl_example.c +++ b/IDE/STM32Cube/wolfssl_example.c @@ -510,11 +510,11 @@ static int ServerMemSend(info_t* info, char* buf, int sz) sz = MEM_BUFFER_SZ - info->to_client.write_idx; #endif + if (info->showVerbose >= 2) + printf("Server Send: %d\n", sz); XMEMCPY(&info->to_client.buf[info->to_client.write_idx], buf, sz); info->to_client.write_idx += sz; info->to_client.write_bytes += sz; - if (info->showVerbose >= 3) - printf("Server Send: %d\n", sz); #ifdef CMSIS_OS2_H_ osThreadFlagsSet(info->client.threadId, 1); @@ -565,17 +565,18 @@ static int ServerMemRecv(info_t* info, char* buf, int sz) XMEMCPY(buf, &info->to_server.buf[info->to_server.read_idx], sz); info->to_server.read_idx += sz; info->to_server.read_bytes += sz; - if (info->showVerbose >= 2) - printf("Server Recv: %d\n", sz); /* if the rx has caught up with pending then reset buffer positions */ if (info->to_server.read_bytes == info->to_server.write_bytes) { info->to_server.read_bytes = info->to_server.read_idx = 0; info->to_server.write_bytes = info->to_server.write_idx = 0; } + if (info->showVerbose >= 2) + printf("Server Recv: %d\n", sz); osSemaphoreRelease(info->server.mutex); + #ifdef BENCH_USE_NONBLOCK if (sz == 0) return WOLFSSL_CBIO_ERR_WANT_READ; @@ -660,14 +661,14 @@ static int ClientMemRecv(info_t* info, char* buf, int sz) XMEMCPY(buf, &info->to_client.buf[info->to_client.read_idx], sz); info->to_client.read_idx += sz; info->to_client.read_bytes += sz; - if (info->showVerbose >= 2) - printf("Client Recv: %d\n", sz); /* if the rx has caught up with pending then reset buffer positions */ if (info->to_client.read_bytes == info->to_client.write_bytes) { info->to_client.read_bytes = info->to_client.read_idx = 0; info->to_client.write_bytes = info->to_client.write_idx = 0; } + if (info->showVerbose >= 2) + printf("Client Recv: %d\n", sz); osSemaphoreRelease(info->client.mutex); diff --git a/wolfssl/wolfcrypt/settings.h b/wolfssl/wolfcrypt/settings.h index b683e73b0..f92b8d558 100644 --- a/wolfssl/wolfcrypt/settings.h +++ b/wolfssl/wolfcrypt/settings.h @@ -1259,11 +1259,11 @@ extern void uITRON4_free(void *p) ; #endif #define NO_OLD_RNGNAME #ifdef WOLFSSL_STM32_CUBEMX - #if defined(WOLFSSL_STM32F1) - #include "stm32f1xx_hal.h" + #if defined(WOLFSSL_STM32F1) + #include "stm32f1xx_hal.h" #elif defined(WOLFSSL_STM32F2) #include "stm32f2xx_hal.h" - #elif defined(WOLFSSL_STM32L5) + #elif defined(WOLFSSL_STM32L5) #include "stm32l5xx_hal.h" #elif defined(WOLFSSL_STM32L4) #include "stm32l4xx_hal.h" @@ -1302,7 +1302,7 @@ extern void uITRON4_free(void *p) ; #ifdef STM32_HASH #include "stm32f4xx_hash.h" #endif - #elif defined(WOLFSSL_STM32L5) + #elif defined(WOLFSSL_STM32L5) #include "stm32l5xx.h" #ifdef STM32_CRYPTO #include "stm32l5xx_cryp.h" @@ -1310,7 +1310,7 @@ extern void uITRON4_free(void *p) ; #ifdef STM32_HASH #include "stm32l5xx_hash.h" #endif - #elif defined(WOLFSSL_STM32L4) + #elif defined(WOLFSSL_STM32L4) #include "stm32l4xx.h" #ifdef STM32_CRYPTO #include "stm32l4xx_cryp.h" @@ -1327,7 +1327,7 @@ extern void uITRON4_free(void *p) ; #endif #endif /* WOLFSSL_STM32_CUBEMX */ #endif /* WOLFSSL_STM32F2 || WOLFSSL_STM32F4 || WOLFSSL_STM32L4 || - WOLFSSL_STM32L5 || WOLFSSL_STM32F7 || WOLFSSL_STMWB || WOLFSSL_STM32H7 */ + WOLFSSL_STM32L5 || WOLFSSL_STM32F7 || WOLFSSL_STMWB || WOLFSSL_STM32H7 */ #ifdef WOLFSSL_DEOS #include #include