Topic: STM32 Hard Faults
I have been struggling for the last few days to get wolfCrypt to work on a STM32L432 microcontroller. I am trying to first generate a Diffie Hellman keypair among other things. No matter what I've tried, I still get hard fault errors.
Here are the exact steps to replicate the problem:
Install STM32CubeIDE (version 1.12.0 at time of writing)
Create a new STM32 project for STM32L432KCU6
Install the STM32Cube pack for STM32CubeIDE under Manage Software Packs
Select wolfCrypt Core from Select Components
Enable the RNG in Security
Enable wolfSSL in Middleware and Software Packs
Automatically resolve any clock issues
Generate Project Code
Change the hardware platform to WOLFSSL_STM32L4 under wolfSSL.I-CUBE-wolfSSL_conf.h and comment out the warning
Build and debug the code to make sure it runs without issues (it does)
In main.c add #include <wolfssl/wolfcrypt/dh.h>
In main.c add wolfCrypt_Init();
Copy/paste the example code under wc_DhGenerateKeyPair() https://www.wolfssl.com/doxygen/group__ … 6fe9dc3b72
Build the project (builds without errors)
Debug the project
This is where the problems occur. The project immediately hard faults. The CFSR register sometimes shows UNDEFINSTR, while other times it shows NOCP. If I comment out the line with wc_DhGenerateKeyPair it runs fine, so I believe this problem is related to wolfCrypt in some way.
I've tried changing tons of options in CubeMX as well as the wolfSSL settings file. I have tried older versions of STM32CubeIDE as well as older versions of wolfSSL. Nothing seems to help.
Any suggestions?