2025-05-20 2:09 AM - edited 2025-05-20 4:55 AM
Hi,
I am using the STM32H7S78-DK. I want to upload an encrypted application to the external 1-Gbit Octo-SPI flash memory connected to XSPI2.
I am using the explanation in this video: https://www.youtube.com/watch?v=JxhKmVUB2Ws&list=PLnMKNibPkDnFQXYK0ztHV9iMVS6EAtKpD&index=10
as well as the example code linked in the video description: https://github.com/ST-TOMAS-Examples-ExtMem/stm32h7rs_ospi_mce?tab=readme-ov-file
As I am using XSPI2, I configure MCE2 to use the Noekeon encryption. My code looks like this:
MCE_HandleTypeDef hmce2;
uint32_t Key[4]= {0x23456789, 0xABCDEF01, 0x23456789, 0xABCDEF01};
hmce2.Instance = MCE2;
if (HAL_MCE_Init(&hmce2) != HAL_OK){
Error_Handler();
}
{
MCE_NoekeonConfigTypeDef NoekeonConfig ;
MCE_RegionConfigTypeDef RegionConfig ;
NoekeonConfig.KeyType = MCE_USE_MASTERKEYS;
NoekeonConfig.pKey = Key;
if (HAL_MCE_ConfigNoekeon(&hmce2, &NoekeonConfig) != HAL_OK){
Error_Handler();
}
/* Set the MCE Region configuration*/
RegionConfig.Mode = MCE_BLOCK_CIPHER;
RegionConfig.ContextID = MCE_CONTEXT1;
RegionConfig.StartAddress = 0x70000000;
RegionConfig.EndAddress = 0x78000000;
RegionConfig.PrivilegedAccess = MCE_REGION_NPRIV;
RegionConfig.AccessMode = MCE_REGION_READWRITE;
if (HAL_MCE_ConfigRegion(&hmce2, MCE_REGION1, &RegionConfig) != HAL_OK){
Error_Handler();
}
}
The application runs properly on the external flash as long as I do not use the MCE.
As soon as I use the MCE configuration above (in the external loader and the bootloader), I end up in the HardFault_Handler.
Is there anything wrong or missing in my MCE configuration?
Thanks for any help!