2012-08-29 06:03 AM
Hi forum,
I'm having trouble getting the CRYP unit working on a ST32F407. First I've tried manually (failed) and -- thinking that I did something wrong -- tried with the ST provided libraries (which also don't work). I'm doing something wrong, I'm very sure, but I can't figure out what. First off: Yes, I have the device properly enabled: [code] RCC_AHB2PeriphClockCmd(RCC_AHB2Periph_CRYP, ENABLE); [/code] then, I use this: [code] CRYP_InitTypeDef x; memset(&x, 0, sizeof(x)); x.CRYP_AlgoDir = CRYP_AlgoDir_Encrypt; x.CRYP_AlgoMode = CRYP_AlgoMode_AES_ECB; x.CRYP_DataType = CRYP_DataType_32b; x.CRYP_KeySize = CRYP_KeySize_128b; CRYP_Init(&x); } { CRYP_KeyInitTypeDef x; memset(&x, 0, sizeof(x)); CRYP_KeyInit(&x); } CRYP_FIFOFlush(); CRYP_Cmd(ENABLE); /* Write input data */ for (int i = 0; i < 4; i++) { CRYP_DataIn(((uint32_t*)aSource)[i]); } printf(''Waiting...\r\n''); /* Wait until finished */ while (!CRYP_GetFlagStatus(CRYP_FLAG_OFNE)); [/code] (this never finishes, i.e. it's not yielding any data). Then I tried the ''high level'' function, which should do everything for me [code] printf(''Result: %d\r\n'', CRYP_AES_ECB(MODE_ENCRYPT, (unsigned char*)aKey, 128, (unsigned char*)aSource, 16, aDestination)); [/code] ...which fails with error 1. Any ideas? Best regards, Joe #stm32f407-cryp-aes1282012-08-29 06:25 AM
Ouch. This hurts.
The 407 doesn't have a CRYP unit. The 417 does. Sorry for the post, Best regards, Joe2012-08-29 06:57 AM
The 407 doesn't have a CRYP unit. The 417 does.
Yep, that's pretty much the problem. Avoids a lot of the ITAR/Export joy. You should be able to look at the RCC clock enable bit, and determine it never gets set. There are less 417 part choices, basically a 512KB and 1MB flash version, from a common die.
2012-08-29 09:13 AM
Ah, I didn't check if the bit in RCC actually got set. What got me curious was that CRYP->CR->CRYPEN never got set.
However, I somehow would've expected a fault. Accesses to that memory area on the 407 don't trap, but don't execute either. Interesting to know. But thanks for the tip, will check RCC next time, too.2013-08-23 02:16 AM
Hi I am Testing CRYP on STM32f407VG RCC also configured but in CRYP Registers are not loading.
thanks ..2013-08-23 05:08 AM
The 407 doesn't have a CRYP or HASH engine, so don't be surprised that it doesn't work. You will need a 417 part.