cancel
Showing results for 
Search instead for 
Did you mean: 

How to use the crypto library on M4-core of the STM32H757?

Byann.1
Associate II

Hi,

I tried to use the crypto library "STM32CryptographicV3.1.1_STM32H7_IARv8_otnsc.a" on the M4-core of the STM32H757 but I got some troubles as explain below.

First of all, I'm using IAR 9.10 and I haven't problem when using the library on M7-core.

When using on M4, the IAR linker call a FPU double precision library instead of FPU single precision library. As a consequence, I got hard faults on some basics calcul such "f32Value * 2.5" because this calcul contains double precision instructions that are not support by M4.

I assume, IAR linker is calling FPU double precision library because the crypto library for STM32H7 has been compiled for M7 with FPU double-precision option activate. Is it correct?

If yes, is the crypto library exist with FPU single-precision option?

Thanks for answers

7 REPLIES 7

ST has classically provided M4 and M7 variants of the crypto libraries.

The H757 should have a hardware crypto unit, I'd expect both cores can access it, but honestly haven't tried at this point. Are you doing something that needs the SW, or wrappers?

Not sure what subset of the library uses/needs FPU-D, but sounds like it needs to be built or decomposed into simpler libraries/objects.

@Jocelyn RICARD​ 

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Byann.1
Associate II

Thanks for your answer.

There are indeed different libraries for M4 or M7. However, it seems the librairies are MCU dependents because they are using the CRC module. When I used the M4 crypto library "STM32CryptographicV3.1.1_CM4_IARv8_otnsc.a", I got another hard fault when calling the CRYPTO_AES_Cbc_Decrypt function because the CRC module is not map at the correct address (F4 - 0x4002'3000, H7 - 0x5802'4C00).

For the moment, I didn't use the crypto hardware of the H757 but I'm pretty sure that M4 could access it. I would like to test it and compare the result/performance with the crypto library.

I'm not sure to understand what you mean. Do you mean that I can get the source code of the crypto library and build only the usefull parts? If yes, do you know where I could find the source code?

For information, I also contact IAR in order to understand the behavior of the linker.

Best regards

Jocelyn RICARD
ST Employee

Hello @Byann.1​ ,

if you want to run the crypto lib on the Cortex M4 you should use a library compiled for it.

So, for instance, reuse the STM32CryptographicV3.0.0_CM4_IAR_otnsc.a from L4 or F4 repository (they are the same)

For your information, the latest release of X-CUBE-CRYPTOLIB version 4 is providing libraries that are only Cortex related. Compared to version 3.1, implementation has been optimized to get better performance and footprint. Also, there is no more dependency on the compiler used.

Last point raised by @Community member​  is that this chip embeds crypto hardware acceleration for symmetric crypto algorithms (AES,DES). This can be used thanks to H7 HAL either from M7 or M4 side.

Best regards

Jocelyn

Byann.1
Associate II

Hello @Jocelyn RICARD​ ,  @Community member​ 

I reused the STM32CryptographicV3.1.1_CM4_IARv8_otnsc.a & STM32CryptographicV3.0.0_CM4_IAR_otnsc.a.on the M4-core of the H757 but as I explained it seems to use the CRC module. The CRC module boundary address is different between a STM32H7 and a STM32F4. .As you can see in the enclosed picture, the register R2 contains the address of the CRC module of the F4 MCU (0x40023000). After this instruction an hardware fault occurs because the code try to access to unknown address/register. The CRC module on STM32H7 is mapped at 0x58024C00. It's the address implemented in STM32CryptographicV3.1.1_STM32H7_IARv8_otnsc.a library. (see embedded picture)

I will also try to use the last version of X-CUBE-CRYPTOLIB but for the moment I'm waiting the validation of my request. Is there different compilation options (FPU, size, speed) with this new version of the crypto library.

Thanks for your support

Yann

0693W00000D2fIbQAJ.png 

Jocelyn RICARD
ST Employee

Hello Yann,

well this is indeed an issue. I don't have the solution right now. I will check internally to understand how this can be addressed.

As new version 4.0 does not address dual core H7 in the implementation example and CRC is still used, I don't expect this will be solved either.

Regarding the Cryptolib request, the system is currently down. This will hopefully be fixed soon even if vacation period does not help !

Best regards

Jocelyn

Byann.1
Associate II

OK, in case, I will check the new version 4.0 and of course also the next version when available.

I assume that compile with FPU-single precision option could solve my problem.

Best regards

yann

Jocelyn RICARD
ST Employee

Hello Yann,

I paste you the developer's answer about how to solve your issue.

Regarding V4 usage, there is an autodetection of the running STM32.

If you use the CM4 version of the library and call cmox_initialize with pInitArg = NULL or pInitArg->target = CMOX_INIT_TARGET_AUTO, it will go to the detection process and determine it's running on an H7.

Thus use the right CRC address.

User can also directly set the STM32 in use by setting: pInitArg->target = CMOX_INIT_TARGET_H7

I didn't checked yet by myself but I'm sure it will work 🙂

Best regards

Jocelyn