Open lucasdietrich opened 2 days ago
@lucasdietrich Thanks for raising this point.
Following investigation, it appears that AES support for STM32L4 series was never implemented. Though, it seems that this PR, aes node has been added to L4 device tree description but was never enabled on a board, hence we failed to see that STM32 crypto driver was actually not compatible with L4 series.
To conclude, given the state of the driver, the fair thing to do would be to remove aes nodes from L4 device tree files. Then, unfortunately, after a quick look, L4 AES HAL (which is by the way same as L0 and L1) differs from currently supported cryto/aes HAL, while the actual hardware block is actually the same as WB for instance for which the HAL is compatible with the driver. Which means that supporting AES on L4 involves a complete new implementation of the stm32 crypto driver, which is not currently in the plans...
I understand that this answer doesn't solve your issue. If you don't want to implement a L4 compatible AES driver, what I can propose is to overwrite current L4 HAL crypto files with WB AES HAL. The hardware IP looks the same according to the reference manual and CMSIS description. I didn't had a try but it should work with minor tweaks.
@erwango Ok, thank you for your answer.
I managed to partially implement an AES driver for the STM32L462RE by adapting crypto_stm32.c
(ECB, CTR, and CBC only). The sample samples/drivers/crypto
works fine with it on my board, but I don't know if it is mature enough for integration into Zephyr. Draft PR: #78669
I still have concerns on the following points:
crypto_stm32l4.c
, and moving common parts to crypto_stm32_common.c
.Thanks for working on this. Adding the actual driver support would indeed be a great addition.
On your concerns, I agree that a dedicated crypto_stm32l4.c
would indeed be welcome.
I'll also try to provide direct feedback on the PR.
Describe the bug I am building a custom board based on the STM32L462RE and compilation of the
st,stm32-aes
device driver fails.To Reproduce To reproduce the issue, you will need to create a custom board based on the STM32L462, as no existing board uses this SoC in the current tree (as far as I know).
Then enable support for the
st,stm32-aes
device.And
I provided the following minimal example to reproduce the issue: demo app, build with
west build -b teal_caniot
Expected behavior If
st,stm32-aes
compatible device is present in the soc devicetree, the driver should compile successfully.Impact It is currently impossible to use AES on the STM32L462.
Logs and console output
The build fails with the following message
Environment (please complete the following information):
Additional context After a quick investigation, it seems that the HAL API for the AES device in the L0, L1, and L4 series differs from other series like the F4. As a result, the driver
crypto_stm32.c
cannot compile without modifications. It is likely that the driver needs to be adapted for the L4 series.For the F4 series: stm32f4xx_hal_cryp.h, the type
CRYP_ConfigTypeDef
and the symbolsHAL_CRYP_SetConfig
andHAL_CRYP_Encrypt
are defined.For the L4 series: stm32l4xx_hal_cryp.h, the type
CRYP_ConfigTypeDef
does not exist, but another type CRYP_InitTypeDef is used. The symbolsHAL_CRYP_SetConfig
andHAL_CRYP_Encrypt
do not exist in this series.