wolfSSL / wolfssl

The wolfSSL library is a small, fast, portable implementation of TLS/SSL for embedded devices to the cloud. wolfSSL supports up to TLS 1.3 and DTLS 1.3!
https://www.wolfssl.com
GNU General Public License v2.0
2.27k stars 812 forks source link

Native STM32WL Support #6386

Closed maxgerhardt closed 10 months ago

maxgerhardt commented 1 year ago

Version

5.6.0

Description

Currently, as per

https://github.com/wolfSSL/wolfssl/blob/62a4329f8eadff2b2b3459c4677d9a80f4a7f150/wolfssl/wolfcrypt/settings.h#L1361-L1366

WolfSSL supports a lot of STM32 series microcontrollers, but not STM32WL natively, per this.

When using STM32CubeMX to generate a project for the STM32WL(55JCI7, for example), and the wolfSSL.ICUBE component is activate, one just gets the error

../../wolfSSL/wolfSSL.I-CUBE-wolfSSL_conf.h:200:6: warning: #warning Please define a hardware platform! [-Wcpp]
..
../../Middlewares/Third_Party/wolfSSL_wolfSSL_wolfSSL/wolfssl/wolfssl/wolfcrypt/settings.h:1367:22: fatal error: stm32f4xx_hal.h: No such file or directory

since it seems to default to STM32F4xx then.

maxgerhardt commented 1 year ago

FYI, I've been playing around with this for a few hours now, and it seems it can be added fairly easily. Major added configuration options in the wolfSSL.I-CUBE-wolfSSL_conf.h are just

#elif defined(STM32WL55xx)
    #define HAL_CONSOLE_UART huart2
    #define STM32_HAL_V2
    #define WOLFSSL_STM32WL
        #define WOLFSSL_STM32_PKA
    #undef  NO_STM32_CRYPTO

(just before "Please define a hardware platform..") and in settings.h adding some || defined(WOLFSSL_STM32WL) in the above shown block, then ofc

    #ifdef WOLFSSL_STM32_CUBEMX
        #elif defined(WOLFSSL_STM32WL)
            #include "stm32wlxx_hal.h"
...
    #else
        #elif defined(WOLFSSL_STM32WL)
            #include "stm32wlxx.h"
        #endif

with a minor adjustment in stm32.c with respect to the used crypto instance

  hcryp->Instance = /*CRYP*/ AES;

and that gives me something that compiles and I think reasonable uses the STM32WL's hardware with regards to the Public Key Accelerator (PKA), AES accelerator and Hardware RNG. Still testing of course.

lealem47 commented 1 year ago

Hi @maxgerhardt,

Thanks for the suggested improvements to our STM32 support.

I'll track this issue so that the next STM32Cube Pack release contains support for at least the STM32WL55. Let me know how your testing goes.

Thanks.

dgarske commented 10 months ago

Hi @maxgerhardt ,

I've pushed fixes to support the STM32WLXX to https://github.com/wolfSSL/wolfssl/pull/6937

Thanks, David Garske, wolfSSL