Skip to content

Commit 0a6a851

Browse files
authored
Merge pull request #8488 from dgarske/stm32h7s
Support for STM32H7S (tested on NUCLEO-H7S3L8)
2 parents a0d6afb + 557abcf commit 0a6a851

10 files changed

Lines changed: 259 additions & 54 deletions

File tree

.wolfssl_known_macro_extras

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,7 @@ STM32H723xx
460460
STM32H725xx
461461
STM32H743xx
462462
STM32H753xx
463+
STM32H7S3xx
463464
STM32L475xx
464465
STM32L4A6xx
465466
STM32L552xx

IDE/STM32Cube/README.md

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,30 +15,34 @@ You need both the STM32 IDE and the STM32 initialization code generator (STM32Cu
1515
* STM32CubeIDE: Integrated Development Environment for STM32 [https://www.st.com/en/development-tools/stm32cubeide.html](https://www.st.com/en/development-tools/stm32cubeide.html)
1616
* STM32CubeMX: STM32Cube initialization code generator [https://www.st.com/en/development-tools/stm32cubemx.html](https://www.st.com/en/development-tools/stm32cubemx.html)
1717

18-
## STM32 Cube Pack
18+
## STM32 Cube Pack Install
1919

20-
### STM32 Cube Pack Installation
20+
The STM32 Cube packs are integrated into the STM32CubeIDE and STM32CubeMX tools. You will find packs for wolfSSL, wolfSSH, wolfTPM and wolfMQTT.
21+
22+
If you need to manually install a Cube Pack you can do the following:
2123

2224
1. Download [wolfSSL Cube Pack](https://www.wolfssl.com/files/ide/I-CUBE-wolfSSL.pack)
23-
2. Run the STM32CubeMX tool.
24-
3. Under Manage software installations pane on the right, click INSTALL/REMOVE button. This can be also found by clicking "Help" -> "Managed embedded software packages"
25-
4. From Local and choose I-CUBE-wolfSSL.pack.
25+
2. Run the "STM32CubeMX" tool.
26+
3. Under "Manage software installations" pane on the right, click "INSTALL/REMOVE" button. This can be also found by clicking "Help" -> "Managed embedded software packages"
27+
4. From Local and choose "I-CUBE-wolfSSL.pack".
2628
5. Accept the GPLv2 license. Contact wolfSSL at sales@wolfssl.com for a commercial license and support/maintenance.
2729

2830
### STM32 Cube Pack Usage
2931

3032
1. Create or open a Cube Project based on your hardware. See the sections below for creating a project and finding the example projects.
31-
2. Under Software Packs choose Select Components.
33+
2. Under "Software Packs" choose "Select Components".
3234
3. Find and check all components for the wolfSSL.wolfSSL packs (wolfSSL / Core, wolfCrypt / Core and wolfCrypt / Test). Close
33-
4. Under the “Software Packs” section click on “wolfSSL.wolfSSL” and configure the parameters.
34-
5. For Cortex-M recommend “Math Configuration” -> “Single Precision Cortex-M Math” for the fastest option. If seeing `error: r7 cannot be used in 'asm` add `-fomit-frame-pointer` to the CFLAGS. This only happens in debug builds, because r7 is used for debug.
35+
4. Under the "Software Packs" section click on "wolfSSL.wolfSSL" and configure the parameters.
36+
5. For Cortex-M recommend "Math Configuration" -> "Single Precision Cortex-M Math" for the fastest option.
37+
- If seeing `error: r7 cannot be used in 'asm` add `-fomit-frame-pointer` to the CFLAGS. This only happens in debug builds, because `r7` is used for debug.
3538
6. Hit the "Generate Code" button
3639
7. Open the project in STM32CubeIDE
3740
8. The Benchmark example uses float. To enable go to "Project Properties" -> "C/C++ Build" -> "Settings" -> "Tool Settings" -> "MCU Settings" -> Check "Use float with printf".
3841
9. To enable printf make the `main.c` changes below in the [STM32 Printf](#stm32-printf) section.
3942

40-
41-
**Note:** The STM32MP13 will likely require you to use DDR RAM, as well as enabling MMU and caches for optimum performance. Please see the `STM32MP13.md` file in `wolfcrypt/src/port/st` for more information on how to do this.
43+
**Notes:**
44+
* The STM32MP13 will likely require you to use DDR RAM, as well as enabling MMU and caches for optimum performance. Please see the `STM32MP13.md` file in `wolfcrypt/src/port/st` for more information on how to do this.
45+
* The STM32H7S only has 64KB of onboard flash. Customers typically use an external SPI NOR flash with XIP. The `Template_XIP_Boot` project is flashed to onboard and it starts up the SPI Flash with XIP and loads the application. To use this you need to make sure the option byte `XSPI2_HSLB` is set to enable XSPIM_P2 high speed support, otherwise the MX_EXTMEM_MANAGER_Init() will timeout and fail.
4246

4347
### Creating your own STM32CubeMX configuration
4448

@@ -89,6 +93,7 @@ The section for "Hardware platform" may need to be adjusted depending on your pr
8993
* To enable STM32L4 support define `WOLFSSL_STM32L4`.
9094
* To enable STM32L5 support define `WOLFSSL_STM32L5`.
9195
* To enable STM32H7 support define `WOLFSSL_STM32H7`.
96+
* To enable STM32H7S support define `WOLFSSL_STM32H7S`.
9297
* To enable STM32WB support define `WOLFSSL_STM32WB`.
9398
* To enable STM32WL support define `WOLFSSL_STM32WL`.
9499
* To enable STM32U5 support define `WOLFSSL_STM32U5`.
@@ -110,6 +115,10 @@ To enable the latest Cube HAL support please define `STM32_HAL_V2`.
110115

111116
If you'd like to use the older Standard Peripheral library undefine `WOLFSSL_STM32_CUBEMX`.
112117

118+
## Workarounds
119+
120+
### STM32F7 AES GCM with pack v1.17.0 or older
121+
113122
With STM32 Cube HAL v2 some AES GCM hardware has a limitation for the AAD header, which must be a multiple of 4 bytes. If your HAL does not support `CRYP_HEADERWIDTHUNIT_BYTE` then consider adding `STM32_AESGCM_PARTIAL` if you are getting AES GCM authentication failures. This bug existed in v1.16.0 or later.
114123

115124
The STM32F7 v1.17.0 pack has a bug in the AES GCM code for handling of additional authentication data when not a multiple of 4 bytes. To patch see `stm32f7xx_hal_cryp.c` -> `CRYP_GCMCCM_SetHeaderPhase`:

IDE/STM32Cube/STM32_Benchmarks.md

Lines changed: 143 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
# STM Benchmarks
22

3-
* [STM32H753ZI](#stm32h753zi)
4-
* [STM32WB55](#stm32wb55)
5-
* [STM32WL55](#stm32wl55)
63
* [STM32F437](#stm32f437)
4+
* [STM32F777](#stm32f777)
5+
* [STM32G071RB](#stm32g071rb)
6+
* [STM32H563ZI](#stm32h563zi)
7+
* [STM32H753ZI](#stm32h753zi)
8+
* [STM32H7S3](#stm32h7s3)
79
* [STM32L4A6Z](#stm32l4a6z)
810
* [STM32L562E](#stm32l562e)
9-
* [STM32F777](#stm32f777)
1011
* [STM32U585](#stm32u585)
11-
* [STM32H563ZI](#stm32h563zi)
12-
* [STM32G071RB](#stm32g071rb)
13-
12+
* [STM32WB55](#stm32wb55)
13+
* [STM32WL55](#stm32wl55)
1414

1515
## STM32H753ZI
1616

@@ -172,6 +172,142 @@ Benchmark Test: Return code 0
172172
```
173173
174174
175+
## STM32H7S3
176+
177+
Supports RNG, PKA ECC P-256, AES-GCM/CCM/CTR/CBC and SHA-1/2 acceleration.
178+
179+
Board: NUCLEO-H7S3L8
180+
CPU: Cortex-M7 at 600 MHz
181+
IDE: STM32CubeIDE
182+
RTOS: Bare-metal
183+
184+
### STM32H7S3 (-Os, HW Crypto (AES/HASH/PKA), WOLF_CONF_MATH=3 (sp_c32.c))
185+
186+
```
187+
------------------------------------------------------------------------------
188+
wolfSSL version 5.7.6
189+
------------------------------------------------------------------------------
190+
wolfCrypt Benchmark (block bytes 1024, min 1.0 sec each)
191+
RNG 2 MiB took 1.004 seconds, 1.897 MiB/s
192+
AES-128-CBC-enc 16 MiB took 1.000 seconds, 15.747 MiB/s
193+
AES-128-CBC-dec 16 MiB took 1.000 seconds, 15.527 MiB/s
194+
AES-192-CBC-enc 16 MiB took 1.000 seconds, 15.723 MiB/s
195+
AES-192-CBC-dec 16 MiB took 1.000 seconds, 15.527 MiB/s
196+
AES-256-CBC-enc 16 MiB took 1.000 seconds, 15.698 MiB/s
197+
AES-256-CBC-dec 16 MiB took 1.000 seconds, 15.527 MiB/s
198+
AES-128-GCM-enc 1 MiB took 1.012 seconds, 1.037 MiB/s
199+
AES-128-GCM-dec 1 MiB took 1.012 seconds, 1.037 MiB/s
200+
AES-192-GCM-enc 1 MiB took 1.008 seconds, 1.041 MiB/s
201+
AES-192-GCM-dec 1 MiB took 1.012 seconds, 1.037 MiB/s
202+
AES-256-GCM-enc 1 MiB took 1.016 seconds, 1.033 MiB/s
203+
AES-256-GCM-dec 1 MiB took 1.016 seconds, 1.033 MiB/s
204+
AES-128-GCM-enc-no_AAD 1 MiB took 1.004 seconds, 1.046 MiB/s
205+
AES-128-GCM-dec-no_AAD 1 MiB took 1.000 seconds, 1.050 MiB/s
206+
AES-192-GCM-enc-no_AAD 1 MiB took 1.000 seconds, 1.050 MiB/s
207+
AES-192-GCM-dec-no_AAD 1 MiB took 1.019 seconds, 1.054 MiB/s
208+
AES-256-GCM-enc-no_AAD 1 MiB took 1.004 seconds, 1.046 MiB/s
209+
AES-256-GCM-dec-no_AAD 1 MiB took 1.008 seconds, 1.041 MiB/s
210+
GMAC Table 4-bit 2 MiB took 1.000 seconds, 1.716 MiB/s
211+
CHACHA 32 MiB took 1.000 seconds, 31.714 MiB/s
212+
CHA-POLY 15 MiB took 1.000 seconds, 15.308 MiB/s
213+
POLY1305 58 MiB took 1.000 seconds, 57.861 MiB/s
214+
SHA-256 88 MiB took 1.000 seconds, 88.062 MiB/s
215+
HMAC-SHA256 83 MiB took 1.000 seconds, 83.032 MiB/s
216+
RSA 2048 public 352 ops took 1.000 sec, avg 2.841 ms, 352.000 ops/sec
217+
RSA 2048 private 6 ops took 1.004 sec, avg 167.333 ms, 5.976 ops/sec
218+
DH 2048 key gen 15 ops took 1.027 sec, avg 68.467 ms, 14.606 ops/sec
219+
DH 2048 agree 16 ops took 1.113 sec, avg 69.563 ms, 14.376 ops/sec
220+
ECC [ SECP256R1] 256 key gen 60 ops took 1.012 sec, avg 16.867 ms, 59.289 ops/sec
221+
ECDHE [ SECP256R1] 256 agree 60 ops took 1.008 sec, avg 16.800 ms, 59.524 ops/sec
222+
ECDSA [ SECP256R1] 256 sign 106 ops took 1.008 sec, avg 9.509 ms, 105.159 ops/sec
223+
ECDSA [ SECP256R1] 256 verify 100 ops took 1.011 sec, avg 10.110 ms, 98.912 ops/sec
224+
```
225+
226+
### STM32H7S3 (-Os, No HW Crypto, WOLF_CONF_ARMASM=1, WOLF_CONF_MATH=6 (sp_int.c))
227+
228+
```
229+
------------------------------------------------------------------------------
230+
wolfSSL version 5.7.6
231+
------------------------------------------------------------------------------
232+
wolfCrypt Benchmark (block bytes 1024, min 1.0 sec each)
233+
RNG 4 MiB took 1.000 seconds, 3.516 MiB/s
234+
AES-128-CBC-enc 425 KiB took 1.027 seconds, 413.827 KiB/s
235+
AES-128-CBC-dec 425 KiB took 1.016 seconds, 418.307 KiB/s
236+
AES-192-CBC-enc 350 KiB took 1.015 seconds, 344.828 KiB/s
237+
AES-192-CBC-dec 350 KiB took 1.020 seconds, 343.137 KiB/s
238+
AES-256-CBC-enc 300 KiB took 1.015 seconds, 295.567 KiB/s
239+
AES-256-CBC-dec 300 KiB took 1.004 seconds, 298.805 KiB/s
240+
AES-128-GCM-enc 375 KiB took 1.067 seconds, 351.453 KiB/s
241+
AES-128-GCM-dec 375 KiB took 1.062 seconds, 353.107 KiB/s
242+
AES-192-GCM-enc 300 KiB took 1.004 seconds, 298.805 KiB/s
243+
AES-192-GCM-dec 300 KiB took 1.004 seconds, 298.805 KiB/s
244+
AES-256-GCM-enc 275 KiB took 1.047 seconds, 262.655 KiB/s
245+
AES-256-GCM-dec 275 KiB took 1.051 seconds, 261.656 KiB/s
246+
AES-128-GCM-enc-no_AAD 375 KiB took 1.067 seconds, 351.453 KiB/s
247+
AES-128-GCM-dec-no_AAD 375 KiB took 1.062 seconds, 353.107 KiB/s
248+
AES-192-GCM-enc-no_AAD 300 KiB took 1.004 seconds, 298.805 KiB/s
249+
AES-192-GCM-dec-no_AAD 300 KiB took 1.004 seconds, 298.805 KiB/s
250+
AES-256-GCM-enc-no_AAD 275 KiB took 1.051 seconds, 261.656 KiB/s
251+
AES-256-GCM-dec-no_AAD 275 KiB took 1.051 seconds, 261.656 KiB/s
252+
GMAC Table 4-bit 8 MiB took 1.000 seconds, 8.456 MiB/s
253+
CHACHA 51 MiB took 1.000 seconds, 50.879 MiB/s
254+
CHA-POLY 27 MiB took 1.000 seconds, 27.100 MiB/s
255+
POLY1305 165 MiB took 1.000 seconds, 164.990 MiB/s
256+
SHA-256 16 MiB took 1.000 seconds, 16.382 MiB/s
257+
HMAC-SHA256 16 MiB took 1.000 seconds, 16.187 MiB/s
258+
RSA 2048 public 358 ops took 1.004 sec, avg 2.804 ms, 356.574 ops/sec
259+
RSA 2048 private 6 ops took 1.004 sec, avg 167.333 ms, 5.976 ops/sec
260+
DH 2048 key gen 15 ops took 1.027 sec, avg 68.467 ms, 14.606 ops/sec
261+
DH 2048 agree 16 ops took 1.094 sec, avg 68.375 ms, 14.625 ops/sec
262+
ECC [ SECP256R1] 256 key gen 60 ops took 1.015 sec, avg 16.917 ms, 59.113 ops/sec
263+
ECDHE [ SECP256R1] 256 agree 60 ops took 1.012 sec, avg 16.867 ms, 59.289 ops/sec
264+
ECDSA [ SECP256R1] 256 sign 48 ops took 1.008 sec, avg 21.000 ms, 47.619 ops/sec
265+
ECDSA [ SECP256R1] 256 verify 28 ops took 1.019 sec, avg 36.393 ms, 27.478 ops/sec
266+
```
267+
268+
### STM32H7S3 (-Os, No HW Crypto, WOLF_CONF_ARMASM=1, WOLF_CONF_MATH=3 (sp_c32.c))
269+
270+
```
271+
------------------------------------------------------------------------------
272+
wolfSSL version 5.7.6
273+
------------------------------------------------------------------------------
274+
wolfCrypt Benchmark (block bytes 1024, min 1.0 sec each)
275+
RNG 4 MiB took 1.004 seconds, 3.939 MiB/s
276+
AES-128-CBC-enc 425 KiB took 1.028 seconds, 413.424 KiB/s
277+
AES-128-CBC-dec 425 KiB took 1.019 seconds, 417.076 KiB/s
278+
AES-192-CBC-enc 350 KiB took 1.016 seconds, 344.488 KiB/s
279+
AES-192-CBC-dec 350 KiB took 1.016 seconds, 344.488 KiB/s
280+
AES-256-CBC-enc 300 KiB took 1.012 seconds, 296.443 KiB/s
281+
AES-256-CBC-dec 300 KiB took 1.012 seconds, 296.443 KiB/s
282+
AES-128-GCM-enc 375 KiB took 1.066 seconds, 351.782 KiB/s
283+
AES-128-GCM-dec 375 KiB took 1.067 seconds, 351.453 KiB/s
284+
AES-192-GCM-enc 300 KiB took 1.004 seconds, 298.805 KiB/s
285+
AES-192-GCM-dec 300 KiB took 1.003 seconds, 299.103 KiB/s
286+
AES-256-GCM-enc 275 KiB took 1.051 seconds, 261.656 KiB/s
287+
AES-256-GCM-dec 275 KiB took 1.051 seconds, 261.656 KiB/s
288+
AES-128-GCM-enc-no_AAD 375 KiB took 1.067 seconds, 351.453 KiB/s
289+
AES-128-GCM-dec-no_AAD 375 KiB took 1.066 seconds, 351.782 KiB/s
290+
AES-192-GCM-enc-no_AAD 300 KiB took 1.000 seconds, 300.000 KiB/s
291+
AES-192-GCM-dec-no_AAD 300 KiB took 1.004 seconds, 298.805 KiB/s
292+
AES-256-GCM-enc-no_AAD 275 KiB took 1.047 seconds, 262.655 KiB/s
293+
AES-256-GCM-dec-no_AAD 275 KiB took 1.051 seconds, 261.656 KiB/s
294+
GMAC Table 4-bit 8 MiB took 1.000 seconds, 8.439 MiB/s
295+
CHACHA 51 MiB took 1.000 seconds, 51.147 MiB/s
296+
CHA-POLY 28 MiB took 1.000 seconds, 27.588 MiB/s
297+
POLY1305 168 MiB took 1.000 seconds, 168.140 MiB/s
298+
SHA-256 16 MiB took 1.000 seconds, 16.333 MiB/s
299+
HMAC-SHA256 16 MiB took 1.000 seconds, 16.016 MiB/s
300+
RSA 2048 public 360 ops took 1.004 sec, avg 2.789 ms, 358.566 ops/sec
301+
RSA 2048 private 6 ops took 1.008 sec, avg 168.000 ms, 5.952 ops/sec
302+
DH 2048 key gen 15 ops took 1.050 sec, avg 70.000 ms, 14.286 ops/sec
303+
DH 2048 agree 16 ops took 1.098 sec, avg 68.625 ms, 14.572 ops/sec
304+
ECC [ SECP256R1] 256 key gen 60 ops took 1.016 sec, avg 16.933 ms, 59.055 ops/sec
305+
ECDHE [ SECP256R1] 256 agree 60 ops took 1.012 sec, avg 16.867 ms, 59.289 ops/sec
306+
ECDSA [ SECP256R1] 256 sign 48 ops took 1.012 sec, avg 21.083 ms, 47.431 ops/sec
307+
ECDSA [ SECP256R1] 256 verify 28 ops took 1.020 sec, avg 36.429 ms, 27.451 ops/sec
308+
```
309+
310+
175311
## STM32WB55
176312
177313
Supports RNG, ECC P-256, AES-CBC and SHA-256 acceleration.

IDE/STM32Cube/default_conf.ftl

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,12 @@ extern ${variable.value} ${variable.name};
102102
#undef NO_STM32_CRYPTO
103103
#define STM32_HAL_V2
104104
#define HAL_CONSOLE_UART huart3
105+
#elif defined(STM32H7S3xx)
106+
#define WOLFSSL_STM32H7S
107+
#undef NO_STM32_HASH
108+
#undef NO_STM32_CRYPTO
109+
#define WOLFSSL_STM32_PKA
110+
#define HAL_CONSOLE_UART huart3
105111
#elif defined(STM32H753xx)
106112
#define WOLFSSL_STM32H7
107113
#undef NO_STM32_HASH
@@ -326,6 +332,10 @@ extern ${variable.value} ${variable.name};
326332
#if defined(WOLF_CONF_DTLS) && WOLF_CONF_DTLS == 1
327333
#define WOLFSSL_DTLS
328334
#endif
335+
#if defined(WOLF_CONF_DTLS13) && WOLF_CONF_DTLS13 == 1
336+
#define WOLFSSL_DTLS13
337+
#define WOLFSSL_SEND_HRR_COOKIE
338+
#endif
329339
#if defined(WOLF_CONF_PSK) && WOLF_CONF_PSK == 0
330340
#define NO_PSK
331341
#endif
@@ -575,25 +585,25 @@ extern ${variable.value} ${variable.name};
575585
/* NOTE: this is after the hashing section to override the potential SHA3 undef
576586
* above. */
577587
#if defined(WOLF_CONF_KYBER) && WOLF_CONF_KYBER == 1
578-
#undef WOLFSSL_EXPERIMENTAL_SETTINGS
579-
#define WOLFSSL_EXPERIMENTAL_SETTINGS
588+
#undef WOLFSSL_EXPERIMENTAL_SETTINGS
589+
#define WOLFSSL_EXPERIMENTAL_SETTINGS
580590

581-
#undef WOLFSSL_HAVE_KYBER
582-
#define WOLFSSL_HAVE_KYBER
591+
#undef WOLFSSL_HAVE_KYBER
592+
#define WOLFSSL_HAVE_KYBER
583593

584-
#undef WOLFSSL_WC_KYBER
585-
#define WOLFSSL_WC_KYBER
594+
#undef WOLFSSL_WC_KYBER
595+
#define WOLFSSL_WC_KYBER
586596

587-
#undef WOLFSSL_NO_SHAKE128
588-
#undef WOLFSSL_SHAKE128
589-
#define WOLFSSL_SHAKE128
597+
#undef WOLFSSL_NO_SHAKE128
598+
#undef WOLFSSL_SHAKE128
599+
#define WOLFSSL_SHAKE128
590600

591-
#undef WOLFSSL_NO_SHAKE256
592-
#undef WOLFSSL_SHAKE256
593-
#define WOLFSSL_SHAKE256
601+
#undef WOLFSSL_NO_SHAKE256
602+
#undef WOLFSSL_SHAKE256
603+
#define WOLFSSL_SHAKE256
594604

595-
#undef WOLFSSL_SHA3
596-
#define WOLFSSL_SHA3
605+
#undef WOLFSSL_SHA3
606+
#define WOLFSSL_SHA3
597607
#endif /* WOLF_CONF_KYBER */
598608

599609
/* ------------------------------------------------------------------------- */
@@ -608,6 +618,7 @@ extern ${variable.value} ${variable.name};
608618
#define WOLFSSL_ARMASM_INLINE
609619
#define WOLFSSL_ARMASM_NO_HW_CRYPTO
610620
#define WOLFSSL_ARMASM_NO_NEON
621+
#define WOLFSSL_ARMASM_THUMB2
611622
#define WOLFSSL_ARM_ARCH 7
612623
/* Disable H/W offloading if accelerating S/W crypto */
613624
#undef NO_STM32_HASH

0 commit comments

Comments
 (0)